|
1 // Copyright (c) 2010 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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef DRIVERAPIWRAPPER_H |
|
17 #define DRIVERAPIWRAPPER_H |
|
18 |
|
19 #include <list> |
|
20 |
|
21 #include "apiwrapper.h" |
|
22 #include "graphicsvhwcallback.h" //callback interface Wrapper=>Virtual HW |
|
23 #include "khronosapiwrapperdefs.h" |
|
24 #include "driverrfc.h" |
|
25 |
|
26 #include "eglapiwrapper.h"//needed to request thread switch for egl during some big operations |
|
27 class KhronosAPIWrapper; |
|
28 |
|
29 #ifndef __PIXELFORMATS_H__ |
|
30 #define __PIXELFORMATS_H__ |
|
31 /* |
|
32 typedef enum |
|
33 { |
|
34 VG_sXRGB_8888 = 0 | (1 << 6), |
|
35 VG_sARGB_8888 = 1 | (1 << 6), |
|
36 VG_sARGB_8888_PRE = 2 | (1 << 6), |
|
37 VG_sRGB_565 = 3, |
|
38 VG_A_8 = 11, |
|
39 } VGImageFormat;*///TODO: get these from somewhere (copy sgconst.h and pixelformats.h maybe) |
|
40 |
|
41 typedef enum |
|
42 { |
|
43 /** |
|
44 32-bit RGB pixel format without alpha, with 8 bits are reserved for each color |
|
45 */ |
|
46 EUidPixelFormatXRGB_8888 = 0x10275496, |
|
47 /** |
|
48 32-bit ARGB pixel format with alpha, using 8 bits per channel |
|
49 */ |
|
50 EUidPixelFormatARGB_8888 = 0x10275498, |
|
51 /** |
|
52 32-bit ARGB pixel format with alpha (pre-multiplied), using 8 bits per channel |
|
53 */ |
|
54 EUidPixelFormatARGB_8888_PRE = 0x1027549A, |
|
55 /** |
|
56 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for |
|
57 blue |
|
58 */ |
|
59 EUidPixelFormatRGB_565 = 0x1027549E, |
|
60 /** |
|
61 8-bit alpha only |
|
62 */ |
|
63 EUidPixelFormatA_8 = 0x102754A3, |
|
64 |
|
65 |
|
66 } TUidPixelFormat;//TODO: get these from somewhere (copy sgconst.h and pixelformats.h maybe) |
|
67 |
|
68 #endif |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 class DriverAPIWrapper: public APIWrapper |
|
74 { |
|
75 public: |
|
76 DriverAPIWrapper( RemoteFunctionCallData& currentFunctionCallData, APIWrapperStack* stack, |
|
77 void* result, |
|
78 MGraphicsVHWCallback* serviceIf, |
|
79 KhronosAPIWrapper* aAPIWrapper ): |
|
80 APIWrapper( currentFunctionCallData, stack, result, serviceIf ), |
|
81 m_currentFunctionCall( m_currentFunctionCallData ), |
|
82 m_APIWrapper( aAPIWrapper ), |
|
83 m_Dpy( EGL_NO_DISPLAY ), |
|
84 m_PoolConfig( 0 ), |
|
85 m_PoolContext( EGL_NO_CONTEXT ), |
|
86 m_ContextWithFormatARGB_8888_PRE( EGL_NO_CONTEXT ), |
|
87 m_ContextWithFormatARGB_8888( EGL_NO_CONTEXT ), |
|
88 m_ContextWithFormatXRGB_8888( EGL_NO_CONTEXT ), |
|
89 m_ContextWithFormatRGB_565( EGL_NO_CONTEXT ), |
|
90 m_ContextWithFormatA_8( EGL_NO_CONTEXT ), |
|
91 m_DudSurface( EGL_NO_SURFACE ) |
|
92 { |
|
93 m_initialized = false; |
|
94 } |
|
95 |
|
96 bool IsSgBackingVGImage( VGImage aImage ); |
|
97 |
|
98 bool IsSgBackingPBuffer( EGLSurface aSurface ); |
|
99 |
|
100 void SetProcessInformation( TUint32 aProcess, TUint32 aThread ) |
|
101 { |
|
102 } |
|
103 |
|
104 void Cleanup( TUint32 aProcess, TUint32 aThread ) |
|
105 { |
|
106 } |
|
107 |
|
108 int DispatchRequest( unsigned long aCode ) |
|
109 { |
|
110 TRACE("DriverAPIWrapper DispatchRequest() in proc/thread %u / %u \n", m_currentFunctionCall.Data().Header().iProcessId, m_currentFunctionCall.Data().Header().iProcessId ); |
|
111 int ret(0); |
|
112 switch ( aCode ) |
|
113 { |
|
114 case DriverRFC::EDrvCreatePoolContext: |
|
115 { |
|
116 ret = CreatePoolContext(); |
|
117 break; |
|
118 } |
|
119 case DriverRFC::EDrvCreatePbufferSg: |
|
120 { |
|
121 ret = CreatePbufferSg(); |
|
122 break; |
|
123 } |
|
124 case DriverRFC::EDrvCreateVGImageSg: |
|
125 { |
|
126 ret = CreateVGImageSg(); |
|
127 break; |
|
128 } |
|
129 case DriverRFC::EDrvDeleteSgImage: |
|
130 { |
|
131 ret = DeleteSgImage(); |
|
132 break; |
|
133 } |
|
134 case DriverRFC::EDrvSyncVGImageFromPBuffer: |
|
135 { |
|
136 //ret = SyncVGImageFromPBuffer(); |
|
137 break; |
|
138 } |
|
139 default: |
|
140 { |
|
141 ASSERT( FALSE ); |
|
142 break; |
|
143 } |
|
144 } |
|
145 return ret; |
|
146 } |
|
147 EGLContext GetPoolContext(){ return m_PoolContext; } |
|
148 |
|
149 //API for external users, such as the egl wrapper |
|
150 void SyncVGImageFromPBuffer( EGLSurface aPbuffer, VGImage aVGImage ); |
|
151 int SyncPBufferFromVGImage( VGImage aSrc, VGint aWidth, VGint aHeight ); |
|
152 |
|
153 EGLint* getColorAttributes( int aPixelFormat, int& aRed, int& aGreen, int& aBlue, int& aAlpha ); |
|
154 EGLDisplay getDisplay(){ if( !m_initialized ){ CreatePoolContext(); }return m_Dpy; } |
|
155 |
|
156 protected: |
|
157 //Request handlers |
|
158 int ClientShutdown() |
|
159 { |
|
160 TRACE("KhronosAPIWrapper ClientShutdown()\n"); |
|
161 return WriteReply(); |
|
162 } |
|
163 |
|
164 int CreatePoolContext(); |
|
165 |
|
166 int CreatePbufferSg(); |
|
167 |
|
168 int CreateVGImageSg(); |
|
169 |
|
170 int DeleteSgImage(); |
|
171 |
|
172 |
|
173 VGImageFormat getVGColorFormat( int aPixelFormat ); |
|
174 |
|
175 private: |
|
176 DriverRFC m_currentFunctionCall; |
|
177 KhronosAPIWrapper* m_APIWrapper;//not owned here |
|
178 |
|
179 std::list<VGImage> m_SgImageVGImages; |
|
180 std::list<EGLSurface> m_SgImagePbuffers; |
|
181 |
|
182 bool m_initialized; |
|
183 |
|
184 EGLDisplay m_Dpy; |
|
185 EGLConfig m_PoolConfig; |
|
186 EGLContext m_PoolContext; |
|
187 EGLContext m_ContextWithFormatARGB_8888_PRE; |
|
188 EGLContext m_ContextWithFormatARGB_8888; |
|
189 EGLContext m_ContextWithFormatXRGB_8888; |
|
190 EGLContext m_ContextWithFormatRGB_565; |
|
191 EGLContext m_ContextWithFormatA_8; |
|
192 EGLSurface m_DudSurface; |
|
193 }; |
|
194 #endif//DRIVERAPIWRAPPER |