gdip-pixbuf-loader r25 - in trunk: . src
- From: tml svn gnome org
- To: svn-commits-list gnome org
- Subject: gdip-pixbuf-loader r25 - in trunk: . src
- Date: Tue, 19 Feb 2008 23:27:33 +0000 (GMT)
Author: tml
Date: Tue Feb 19 23:27:32 2008
New Revision: 25
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=25&view=rev
Log:
2008-02-20 Tor Lillqvist <tml novell com>
* src/io-gdip-utils.c: Drop the wrapper functions that each call
GetProcAddress(). Instead just use a bunch of function pointers
and initialise them at the same time in io_gdip_init().
Modified:
trunk/ChangeLog
trunk/src/io-gdip-utils.c
Modified: trunk/src/io-gdip-utils.c
==============================================================================
--- trunk/src/io-gdip-utils.c (original)
+++ trunk/src/io-gdip-utils.c Tue Feb 19 23:27:32 2008
@@ -26,215 +26,61 @@
#include "io-gdip-propertytags.h"
#include <ole2.h>
-static HINSTANCE gdipluslib = NULL;
-
-/* ////// WRAPPER FUNCTIONS /////// */
-
-GpStatus WINGDIPAPI
-GdiplusStartup (ULONG_PTR *token, const GdiplusStartupInput *input, gpointer *output)
-{
- static GdiplusStartupFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdiplusStartupFunc) GetProcAddress(gdipluslib, "GdiplusStartup");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (token, (gpointer)input, output);
-}
-
-GpStatus WINGDIPAPI
-GdipCreateBitmapFromStream (gpointer stream, GpBitmap** bitmap)
-{
- static GdipCreateBitmapFromStreamFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipCreateBitmapFromStreamFunc) GetProcAddress(gdipluslib, "GdipCreateBitmapFromStream");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (stream, bitmap);
-}
-
-GpStatus WINGDIPAPI
-GdipBitmapGetPixel(GpBitmap* bitmap, gint x, gint y, ARGB *color)
-{
- static GdipBitmapGetPixelFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipBitmapGetPixelFunc) GetProcAddress(gdipluslib, "GdipBitmapGetPixel");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (bitmap, x, y, color);
-}
-
-GpStatus WINGDIPAPI
-GdipGetImageHeight (GpImage* image, guint* height)
-{
- static GdipGetImageHeightFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipGetImageHeightFunc) GetProcAddress(gdipluslib, "GdipGetImageHeight");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, height);
-}
-
-GpStatus WINGDIPAPI
-GdipDisposeImage (GpImage* image)
-{
- static GdipDisposeImageFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipDisposeImageFunc) GetProcAddress(gdipluslib, "GdipDisposeImage");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image);
-}
-
-GpStatus WINGDIPAPI
-GdipGetImageFlags (GpImage *image, guint *flags)
-{
- static GdipGetImageFlagsFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipGetImageFlagsFunc) GetProcAddress(gdipluslib, "GdipGetImageFlags");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, flags);
-}
-
-GpStatus WINGDIPAPI
-GdipGetImageWidth (GpImage* image, guint* width)
-{
- static GdipGetImageWidthFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipGetImageWidthFunc) GetProcAddress(gdipluslib, "GdipGetImageWidth");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, width);
-}
+static GdiplusStartupFunc GdiplusStartup;
+static GdipCreateBitmapFromStreamFunc GdipCreateBitmapFromStream;
+static GdipBitmapGetPixelFunc GdipBitmapGetPixel;
+static GdipGetImageHeightFunc GdipGetImageHeight;
+static GdipDisposeImageFunc GdipDisposeImage;
+static GdipGetImageFlagsFunc GdipGetImageFlags;
+static GdipGetImageWidthFunc GdipGetImageWidth;
+static GdipImageGetFrameCountFunc GdipImageGetFrameCount;
+static GdipImageSelectActiveFrameFunc GdipImageSelectActiveFrame;
+static GdipGetPropertyItemSizeFunc GdipGetPropertyItemSize;
+static GdipGetPropertyItemFunc GdipGetPropertyItem;
+static GdipGetPropertyCountFunc GdipGetPropertyCount;
+static GdipGetPropertyIdListFunc GdipGetPropertyIdList;
DEFINE_GUID(FrameDimensionTime, 0x6aedbd6d,0x3fb5,0x418a,0x83,0xa6,0x7f,0x45,0x22,0x9d,0xc8,0x72);
DEFINE_GUID(FrameDimensionPage, 0x7462dc86,0x6180,0x4c7e,0x8e,0x3f,0xee,0x73,0x33,0xa7,0xa4,0x83);
-GpStatus WINGDIPAPI
-GdipImageGetFrameCount (GpImage* image, const GUID* dimensionID, guint* count)
-{
- static GdipImageGetFrameCountFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipImageGetFrameCountFunc) GetProcAddress(gdipluslib, "GdipImageGetFrameCount");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, dimensionID, count);
-}
-
-GpStatus WINGDIPAPI
-GdipImageSelectActiveFrame (GpImage* image, const GUID* dimensionID, guint frameIndex)
-{
- static GdipImageSelectActiveFrameFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipImageSelectActiveFrameFunc) GetProcAddress(gdipluslib, "GdipImageSelectActiveFrame");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, dimensionID, frameIndex);
-}
-
-GpStatus WINGDIPAPI
-GdipGetPropertyItemSize (GpImage *image, PROPID propId, guint* size)
-{
- static GdipGetPropertyItemSizeFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipGetPropertyItemSizeFunc) GetProcAddress(gdipluslib, "GdipGetPropertyItemSize");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, propId, size);
-}
-
-GpStatus WINGDIPAPI
-GdipGetPropertyItem (GpImage *image, int propId, guint propSize, PropertyItem* buffer)
-{
- static GdipGetPropertyItemFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipGetPropertyItemFunc) GetProcAddress(gdipluslib, "GdipGetPropertyItem");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, propId, propSize, buffer);
-}
-
-GpStatus WINGDIPAPI
-GdipGetPropertyCount (GpImage *image, guint* numOfProperty)
-{
- static GdipGetPropertyCountFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipGetPropertyCountFunc) GetProcAddress(gdipluslib, "GdipGetPropertyCount");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, numOfProperty);
-}
-
-GpStatus WINGDIPAPI
-GdipGetPropertyIdList (GpImage *image, guint numOfProperty, PROPID* list)
-{
- static GdipGetPropertyIdListFunc proc = NULL;
-
- if (gdipluslib && !proc)
- proc = (GdipGetPropertyIdListFunc) GetProcAddress(gdipluslib, "GdipGetPropertyIdList");
-
- if (!proc)
- return GenericError;
-
- return (*proc) (image, numOfProperty, list);
-}
-
-/*
- * END OF WRAPPER FUCNTIONS
- */
-
gboolean
io_gdip_init (void)
{
GdiplusStartupInput input;
ULONG_PTR gdiplusToken = 0;
+ static HINSTANCE gdipluslib = NULL;
input.GdiplusVersion = 1;
input.DebugEventCallback = NULL;
input.SuppressBackgroundThread = input.SuppressExternalCodecs = FALSE;
if (!gdipluslib)
- gdipluslib = LoadLibrary (TEXT("gdiplus.dll"));
+ gdipluslib = LoadLibrary ("gdiplus.dll");
if (!gdipluslib)
return FALSE;
+#define LOOKUP(func) \
+ func = (func##Func) GetProcAddress(gdipluslib, #func); \
+ if (!func) \
+ return FALSE
+
+ LOOKUP (GdiplusStartup);
+ LOOKUP (GdipCreateBitmapFromStream);
+ LOOKUP (GdipBitmapGetPixel);
+ LOOKUP (GdipGetImageHeight);
+ LOOKUP (GdipDisposeImage);
+ LOOKUP (GdipGetImageFlags);
+ LOOKUP (GdipGetImageWidth);
+ LOOKUP (GdipImageGetFrameCount);
+ LOOKUP (GdipImageSelectActiveFrame);
+ LOOKUP (GdipGetPropertyItemSize);
+ LOOKUP (GdipGetPropertyItem);
+ LOOKUP (GdipGetPropertyCount);
+ LOOKUP (GdipGetPropertyIdList);
+
+#undef LOOKUP
+
return (GdiplusStartup (&gdiplusToken, &input, NULL) == 0 ? TRUE : FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]