os/graphics/graphicsdeviceinterface/directgdiadaptation/hwsrc/directgdidriverprocessstate.h
Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // directhdidriverprocessstate.h
18 #ifndef _DIRECTGDIDRIVERPROCESSSTATE_H_
19 #define _DIRECTGDIDRIVERPROCESSSTATE_H_
26 #include "directgdiadapter.h"
27 #include <graphics/sgimage.h>
29 #include <VG/openvg.h>
34 Function pointers for use with eglGetProcAddress for creation and deletion of EGLImages and creation of VGImages
36 typedef EGLImageKHR (*TeglCreateImageKHRTypefPtr) (EGLDisplay dpy, EGLContext ctx, EGLenum aTarget, EGLClientBuffer buffer, EGLint*attrib_list);
37 typedef EGLBoolean (*TeglDestroyImageKHRTypefPtr) (EGLDisplay dpy, EGLImageKHR image);
38 typedef EGLBoolean (*TvgCreateEGLImageTargetKHRTypefPtr) (VGeglImageKHR image);
41 Helper class used by CDirectGdiDriverProcessState to group together related EGL and VG images.
43 NONSHARABLE_CLASS(CImageSourceData): public CBase
46 CImageSourceData(const TSgDrawableId& aSgImageId, EGLImageKHR aEglImage, VGImage aVgImage);
47 virtual ~CImageSourceData();
49 inline const TSgDrawableId& SgImageId() const;
50 inline EGLImageKHR EglImage() const;
51 inline VGImage VgImage() const;
56 TSgDrawableId iSgImageId;
57 EGLImageKHR iEglImage;
65 Class for storing the state of CDirectGdiDriver objects within the current process. This class is
66 responsible for maintaining an instance count of the number of drivers open in this process. There may
67 be more than one thread that creates and opens a driver in this process. This class initializes EGL and
68 terminates it using an instance count, as EGL terminate should not be called until all drivers in this
69 process have been closed, not when each thread closes as another thread may be using EGL in the same
72 This class is also responsible for storing a list of all EGLImageKHR objects and associated RSgImage IDs
73 created in this process, as there is a restriction that an EGLImageKHR can only be created
74 from a particular RSgImage once per process. This allows EGL images that have already been created
75 from RSgImages to be shared among threads. The list of EGL images is created on a shared process heap
76 so that it can be shared between all threads.
78 Users of this class should call CreateVGImageFromSgImage
80 NONSHARABLE_CLASS(XDirectGdiDriverProcessState): public CBase
83 XDirectGdiDriverProcessState();
84 virtual ~XDirectGdiDriverProcessState();
86 TInt Initialize(EGLDisplay aDisplay);
87 TInt CreateVgImage(EGLDisplay aDisplay, VGImage& aVgImageRet, const RSgImage& aSgImage);
88 TInt DestroyVgImage(EGLDisplay aDisplay, VGImage aVgImage);
91 void CloseDriver(EGLDisplay& aDriverEglDisplay);
93 inline TInt MutexCreationStatus() const;
96 TInt CheckAllEglExtensions(EGLDisplay aDisplay) const ;
97 TInt CheckForEglExtension(EGLDisplay aDisplay, const TDesC8& aExtensionString) const;
99 // Always use the mutex iImagesMutex around the following methods
100 TBool ImageExists(const RSgImage& aSgImage, VGImage& aVgImageRet);
101 CImageSourceData* FindImage(const RSgImage& aSgImage);
102 TInt AddImage(const RSgImage& aSgImage, EGLImageKHR aEglImage, VGImage aVgImage);
103 TInt RemoveImage(EGLDisplay aDisplay, VGImage aVgImage);
105 TInt iDriverInstanceCount;
107 RPointerArray<CImageSourceData> iImages;
109 // Holds the error state for creating the mutex in the constructor, so that it can be reported
110 // outside of the constructor.
111 TInt iCreateMutexErr;
112 TBool iCheckedExtensionsAvailable;
114 // Function pointers for creation and destruction of EGLImageKHR and creation of VGImage
115 TeglCreateImageKHRTypefPtr iPfnEglCreateImageKHR;
116 TeglDestroyImageKHRTypefPtr iPfnEglDestroyImageKHR;
117 TvgCreateEGLImageTargetKHRTypefPtr iPfnVgCreateImageTargetKHR;
121 #include "directgdidriverprocessstate.inl"
123 #endif // _DIRECTGDIDRIVERPROCESSSTATE_H_