Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
17 #include "vg_vgibridge.h"
20 #include <VG/openvg.h>
22 #define VGI_API_CALL __declspec(dllexport)
24 #define VGI_GET_BRIDGE VGIBridge *bridge = vgiGetBridge(); if(!bridge) return;
25 #define VGI_GET_BRIDGE_RET VGIBridge *bridge = vgiGetBridge(); if(!bridge) return 0;
28 #if defined __SYMBIAN32__
30 static void vgiSetCurrentBridge( VGIBridge* bridge )
32 Dll::SetTls( bridge );
35 static VGIBridge* vgiGetCurrentBridge()
37 return (VGIBridge*)Dll::Tls();
44 VGIBridge *currBridge = NULL;
46 static void vgiSetCurrentBridge( VGIBridge* bridge )
51 static VGIBridge* vgiGetCurrentBridge()
58 static VGIBridge* vgiGetBridge()
60 VGIBridge *bridge = vgiGetCurrentBridge();
63 VGIBridgeFunc vgiVGIBridge = NULL;
65 bridge = (VGIBridge *)malloc( sizeof(VGIBridge) );
69 memset( bridge, 0, sizeof(VGIBridge) );
71 #if defined __SYMBIAN32__
74 #ifdef OPENVG_VERSION_1_1
75 if( lib.Load( _L("libOpenVG_SW.dll") ) == KErrNone )
76 vgiVGIBridge = (VGIBridgeFunc)lib.Lookup( 89 ); // <- 89 is a hardcoded ordinal, refer to libopenvgu.def in bwins and eabi folders
77 #else // OPENVG_VERSION_1_0 and OPENVG_VERSION_1_0_1
78 if( lib.Load( _L("libOpenVG.dll") ) == KErrNone )
79 vgiVGIBridge = (VGIBridgeFunc)lib.Lookup( 1 ); // <- 1 is a hardcoded ordinal, refer to libopenvgu.def in bwins and eabi folders
81 bridge->libHandle = lib;
85 HMODULE hModule = LoadLibrary( "libOpenVG.dll" );
87 vgiVGIBridge = (VGIBridgeFunc)GetProcAddress( hModule, "vgiVGIBridge" );
97 vgiVGIBridge( bridge );
98 vgiSetCurrentBridge( bridge );
104 VGI_API_CALL int VGIInitialize( int width, int height, VGIColorSpace colorSpace )
108 return bridge->VGIInitialize( width, height, colorSpace );
111 VGI_API_CALL int VGIInitializeEx( int width, int height, VGIColorSpace colorSpace, int premultiplied, int conformant )
115 return bridge->VGIInitializeEx( width, height, colorSpace, premultiplied, conformant );
118 VGI_API_CALL int VGICopyToTarget( VGIColorBufferFormat format, int bufferStride, void *buffer, int maskStride, void *mask, VGICopyToTargetHint hint )
122 return bridge->VGICopyToTarget( format, bufferStride, buffer, maskStride, mask, hint );
125 VGI_API_CALL void VGITerminate( void )
129 bridge->VGITerminate();
131 #if defined __SYMBIAN32__
132 bridge->libHandle.Close();
136 vgiSetCurrentBridge( NULL );
139 VGI_API_CALL int VGIResize( int width, int height )
143 return bridge->VGIResize( width, height );
146 VGI_API_CALL int VGIBindToImage( VGImage image )
150 return bridge->VGIBindToImage( image );
153 VGI_API_CALL int VGIUnBindImage( void )
157 return bridge->VGIUnBindImage();
162 EXPORT_C TInt VGISymbianInitialize( TSize aSize, VGIColorSpace aColorSpace )
166 return bridge->VGISymbianInitialize( aSize, aColorSpace );
169 EXPORT_C TInt VGISymbianInitializeEx( TSize aSize, VGIColorSpace aColorSpace, TBool aPremultiplied, TBool aConformant )
173 return bridge->VGISymbianInitializeEx( aSize, aColorSpace, aPremultiplied, aConformant );
176 EXPORT_C TInt VGISymbianCopyToBitmap( CFbsBitmap *aBitmap, CFbsBitmap *aMaskBitmap, VGICopyToTargetHint aHint )
180 return bridge->VGISymbianCopyToBitmap( aBitmap, aMaskBitmap, aHint );
183 EXPORT_C void VGISymbianTerminate()
187 bridge->VGISymbianTerminate();
189 bridge->libHandle.Close();
192 vgiSetCurrentBridge( NULL );
195 EXPORT_C TInt VGISymbianResize( TSize aSize )
199 return bridge->VGISymbianResize( aSize );
202 EXPORT_C TInt VGISymbianBindToImage( VGImage aImage )
206 return bridge->VGISymbianBindToImage( aImage );
209 EXPORT_C TInt VGISymbianUnBindImage()
213 return bridge->VGISymbianUnBindImage();