|
1 /* |
|
2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of CHuiVg10PBufferSurface. CHuiGles10PBufferSurface is |
|
15 * an OpenVG PBuffer surface object that implements the MHuiRenderSurface |
|
16 * interface. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #include "HuiVg10RenderPlugin.h" |
|
23 #include "HuiVg10PBufferSurface.h" |
|
24 #include "uiacceltk/HuiStatic.h" |
|
25 #include "uiacceltk/HuiUtil.h" |
|
26 #include "uiacceltk/HuiSegmentedTexture.h" |
|
27 #include <EGL/egl.h> |
|
28 |
|
29 #include <coemain.h> |
|
30 |
|
31 struct THuiColorModeData |
|
32 { |
|
33 TInt iColorMode; |
|
34 TInt iBitCount; |
|
35 TInt iRed; |
|
36 TInt iGreen; |
|
37 TInt iBlue; |
|
38 TInt iAlpha; |
|
39 }; |
|
40 |
|
41 const THuiColorModeData KHuiColorModeData[] = |
|
42 { |
|
43 {0, EGL_DONT_CARE, 0, 0, 0, 8}, // Do not use ENone as there might be many of those in headers |
|
44 {EColor4K, 12, 4, 4, 4, 0}, |
|
45 {EColor64K, 16, 5, 6, 5, 0}, |
|
46 {EColor16M, 24, 8, 8, 8, 0}, |
|
47 {EColor16MU, 32, 8, 8, 8, 0}, |
|
48 #ifndef __NVG |
|
49 {EColor16MA, 32, 8, 8, 8, 8} |
|
50 #else |
|
51 {EColor16MA, 32, 8, 8, 8, 8}, |
|
52 {EColor16MAP, 32, 8, 8, 8, 8} |
|
53 #endif |
|
54 }; |
|
55 |
|
56 |
|
57 CHuiVg10PBufferSurface* CHuiVg10PBufferSurface::NewLC(CHuiVg10RenderPlugin& aRenderer, |
|
58 const TSize& aSize, |
|
59 TInt aAlphaBits, |
|
60 TInt aEglBufferType, |
|
61 TInt aBufferColorMode) |
|
62 { |
|
63 CHuiVg10PBufferSurface* self = new (ELeave) CHuiVg10PBufferSurface( |
|
64 aRenderer, aSize, aAlphaBits, aEglBufferType, aBufferColorMode); |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 CHuiVg10PBufferSurface* CHuiVg10PBufferSurface::NewLC(CHuiVg10RenderPlugin& aRenderer, |
|
72 const TSize& aSize, |
|
73 TInt aAlphaBits) |
|
74 { |
|
75 return NewLC(aRenderer, aSize, aAlphaBits, EGL_PBUFFER_BIT, 0); |
|
76 } |
|
77 |
|
78 |
|
79 CHuiVg10PBufferSurface* CHuiVg10PBufferSurface::NewL(const TSize& aSize, TInt aAlphaBits) |
|
80 { |
|
81 CHuiVg10PBufferSurface* self = CHuiVg10PBufferSurface::NewLC(aSize, aAlphaBits); |
|
82 CleanupStack::Pop(self); |
|
83 return self; |
|
84 } |
|
85 |
|
86 |
|
87 CHuiVg10PBufferSurface* CHuiVg10PBufferSurface::NewLC(const TSize& aSize, TInt aAlphaBits) |
|
88 { |
|
89 CHuiVg10RenderPlugin& render = CHuiStatic::Vg10Renderer(); |
|
90 return NewLC(render, aSize, aAlphaBits); |
|
91 } |
|
92 |
|
93 |
|
94 CHuiVg10PBufferSurface::CHuiVg10PBufferSurface(CHuiVg10RenderPlugin& aRenderer, |
|
95 const TSize& aSize, |
|
96 TInt aAlphaBits, |
|
97 TInt aEglBufferType, |
|
98 TInt aBufferColorMode) |
|
99 : iSize(aSize), iEglBufferType(aEglBufferType), iBufferColorMode(aBufferColorMode), |
|
100 iAlphaBits(aAlphaBits),iRenderer(aRenderer) |
|
101 { |
|
102 } |
|
103 |
|
104 |
|
105 void CHuiVg10PBufferSurface::ConstructL() |
|
106 { |
|
107 HUI_DEBUG(_L("CHuiVg10PBufferSurface::ConstructL() - Constructing OpenVG 1.0 PBuffer Rendering surface.")); |
|
108 |
|
109 // Create egl context and rendering surface |
|
110 iEglContext = iEglSurface = NULL; |
|
111 iIsHardwareAccelerated = EFalse; |
|
112 RestoreL(); |
|
113 |
|
114 HUI_DEBUG(_L("CHuiVg10PBufferSurface::ConstructL() - Construction exited OK.")); |
|
115 } |
|
116 |
|
117 |
|
118 CHuiVg10PBufferSurface::~CHuiVg10PBufferSurface() |
|
119 { |
|
120 Release(); |
|
121 } |
|
122 |
|
123 |
|
124 TBool CHuiVg10PBufferSurface::GetScreenOrigin(TPoint& /*aOrigin*/) const |
|
125 { |
|
126 // This class does only off-screen rendering, so the on-screen origin |
|
127 // cannot be determined. |
|
128 return EFalse; |
|
129 } |
|
130 |
|
131 |
|
132 EGLConfig CHuiVg10PBufferSurface::DetermineConfig() |
|
133 { |
|
134 HUI_DEBUG1(_L("CHuiVg10PBufferSurface::DetermineConfig() enter. iBufferColorMode=%d"), iBufferColorMode); |
|
135 // Define properties for the wanted EGLSurface. To get the best possible |
|
136 // performance, choose an EGLConfig with a buffersize matching |
|
137 // the current window's display mode. |
|
138 |
|
139 // Determine the buffer size |
|
140 #ifdef __WINSCW__ |
|
141 if (iBufferColorMode == ENone) |
|
142 { |
|
143 |
|
144 // Determine the natively supported display mode |
|
145 CWsScreenDevice* screenDevice = CHuiStatic::ScreenDevice(); |
|
146 if(screenDevice) |
|
147 { |
|
148 screenDevice->DisplayMode(); |
|
149 } |
|
150 } |
|
151 #endif |
|
152 |
|
153 // Find color mode data |
|
154 THuiColorModeData cmData = KHuiColorModeData[0]; |
|
155 //Mem::Copy(&cmData, (&KHuiColorModeData[0]), sizeof(THuiColorModeData)); // default mode |
|
156 for (TInt colorModeIndex = 0; |
|
157 colorModeIndex < (sizeof(KHuiColorModeData) / sizeof(THuiColorModeData)); |
|
158 colorModeIndex++) |
|
159 { |
|
160 if (iBufferColorMode == KHuiColorModeData[colorModeIndex].iColorMode) |
|
161 { |
|
162 Mem::Copy(&cmData, &(KHuiColorModeData[colorModeIndex]), sizeof(THuiColorModeData)); |
|
163 } |
|
164 } |
|
165 |
|
166 // Define properties for the wanted EGLSurface. |
|
167 EGLint attribListDefault[15]; // reserve enough space for configurations |
|
168 int tmp = 0; |
|
169 |
|
170 attribListDefault[tmp++] = EGL_BUFFER_SIZE; |
|
171 attribListDefault[tmp++] = cmData.iBitCount; |
|
172 |
|
173 attribListDefault[tmp++] = EGL_SURFACE_TYPE; |
|
174 attribListDefault[tmp++] = iEglBufferType; |
|
175 |
|
176 attribListDefault[tmp++] = EGL_RENDERABLE_TYPE; |
|
177 attribListDefault[tmp++] = EGL_OPENVG_BIT; |
|
178 |
|
179 attribListDefault[tmp++] = EGL_ALPHA_SIZE; |
|
180 attribListDefault[tmp++] = cmData.iAlpha; |
|
181 |
|
182 /* |
|
183 #ifndef __WINSCW__ |
|
184 if( iIsHardwareAccelerated ) |
|
185 { |
|
186 // Emulator renders in software, so it does not antialias. |
|
187 // MBX is efficient in supersampling. |
|
188 attribListDefault[tmp++] = EGL_SAMPLE_BUFFERS; |
|
189 attribListDefault[tmp++] = 1; |
|
190 |
|
191 attribListDefault[tmp++] = EGL_SAMPLES; |
|
192 attribListDefault[tmp++] = 4; |
|
193 } |
|
194 #endif // __WINSCW__ |
|
195 */ |
|
196 |
|
197 // Terminate attribute list |
|
198 attribListDefault[tmp++] = EGL_NONE; |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 // Define properties for the wanted EGLSurface. |
|
204 EGLint attribListCustom[25]; // reserve enough space for configurations |
|
205 tmp = 0; |
|
206 |
|
207 attribListCustom[tmp++] = EGL_BUFFER_SIZE; |
|
208 attribListCustom[tmp++] = cmData.iBitCount; |
|
209 |
|
210 attribListCustom[tmp++] = EGL_RED_SIZE; |
|
211 attribListCustom[tmp++] = cmData.iRed; |
|
212 |
|
213 attribListCustom[tmp++] = EGL_GREEN_SIZE; |
|
214 attribListCustom[tmp++] = cmData.iGreen; |
|
215 |
|
216 attribListCustom[tmp++] = EGL_BLUE_SIZE; |
|
217 attribListCustom[tmp++] = cmData.iBlue; |
|
218 |
|
219 attribListCustom[tmp++] = EGL_RENDERABLE_TYPE; |
|
220 attribListCustom[tmp++] = EGL_OPENVG_BIT; |
|
221 |
|
222 attribListCustom[tmp++] = EGL_SURFACE_TYPE; |
|
223 attribListCustom[tmp++] = iEglBufferType; |
|
224 |
|
225 attribListCustom[tmp++] = EGL_ALPHA_SIZE; |
|
226 attribListCustom[tmp++] = cmData.iAlpha; |
|
227 |
|
228 /* |
|
229 if( iIsHardwareAccelerated ) |
|
230 { |
|
231 // Emulator renders in software, so it does not antialias. |
|
232 // MBX is efficient in supersampling. |
|
233 attribListCustom[tmp++] = EGL_SAMPLE_BUFFERS; |
|
234 attribListCustom[tmp++] = 1; |
|
235 |
|
236 attribListCustom[tmp++] = EGL_SAMPLES; |
|
237 attribListCustom[tmp++] = 4; |
|
238 } |
|
239 */ |
|
240 // Terminate attribute list |
|
241 attribListCustom[tmp++] = EGL_NONE; |
|
242 |
|
243 |
|
244 // Choose an EGLConfig that best matches to the properties in attribList. |
|
245 TInt numOfConfigs = 0; |
|
246 if (iBufferColorMode == 0) |
|
247 { |
|
248 // No explicit color mode. Vg chooses the best mode. |
|
249 numOfConfigs = iRenderer.EglChooseConfig(attribListDefault); |
|
250 } |
|
251 else |
|
252 { |
|
253 numOfConfigs = iRenderer.EglChooseConfig(attribListCustom); |
|
254 } |
|
255 |
|
256 if(!numOfConfigs) |
|
257 { |
|
258 #ifdef _DEBUG |
|
259 TInt eglerr = eglGetError(); |
|
260 HUI_DEBUG2(_L("CHuiVg10PBufferSurface::DetermineConfig() - eglChooseConfig failed, no required EGL configuration found. Cause: %S (error %i). Panicking."), &CHuiVg10RenderSurface::EglErrorMessage(eglerr), eglerr); |
|
261 #endif |
|
262 HUI_PANIC(THuiPanic::ERenderSurfaceUnknownDisplayMode) |
|
263 } |
|
264 |
|
265 HUI_DEBUG1(_L("CHuiVg10PBufferSurface::DetermineConfig() - Got %i configs."), numOfConfigs); |
|
266 |
|
267 // Print the attributes of the selected config to log file. |
|
268 iRenderer.EglPrintConfig(0); |
|
269 |
|
270 if (iBufferColorMode == 0) |
|
271 { |
|
272 // Set color mode based on parameters |
|
273 |
|
274 // Update color mode struct |
|
275 TInt cfg = iRenderer.EglConfig(0); |
|
276 eglGetConfigAttrib(iEglDisplay, cfg, EGL_BUFFER_SIZE, &(cmData.iBitCount)); |
|
277 eglGetConfigAttrib(iEglDisplay, cfg, EGL_RED_SIZE, &(cmData.iRed)); |
|
278 eglGetConfigAttrib(iEglDisplay, cfg, EGL_GREEN_SIZE, &(cmData.iGreen)); |
|
279 eglGetConfigAttrib(iEglDisplay, cfg, EGL_BLUE_SIZE, &(cmData.iBlue)); |
|
280 eglGetConfigAttrib(iEglDisplay, cfg, EGL_ALPHA_SIZE, &(cmData.iAlpha)); |
|
281 |
|
282 // Find color mode from array |
|
283 for (TInt colorModeIndex = 0; |
|
284 colorModeIndex < (sizeof(KHuiColorModeData) / sizeof(THuiColorModeData)); |
|
285 colorModeIndex++) |
|
286 { |
|
287 if ( |
|
288 (cmData.iBitCount == KHuiColorModeData[colorModeIndex].iBitCount) && |
|
289 (cmData.iRed == KHuiColorModeData[colorModeIndex].iRed) && |
|
290 (cmData.iGreen == KHuiColorModeData[colorModeIndex].iGreen) && |
|
291 (cmData.iBlue == KHuiColorModeData[colorModeIndex].iBlue) && |
|
292 (cmData.iAlpha == KHuiColorModeData[colorModeIndex].iAlpha) ) |
|
293 { |
|
294 iBufferColorMode = KHuiColorModeData[colorModeIndex].iColorMode; |
|
295 } |
|
296 } |
|
297 } |
|
298 |
|
299 // Choose the best EGLConfig. EGLConfigs returned by eglChooseConfig |
|
300 // are sorted so that the best matching EGLConfig is first in the list. |
|
301 return iRenderer.EglConfig(0); |
|
302 } |
|
303 |
|
304 |
|
305 EGLSurface CHuiVg10PBufferSurface::CreateSurface(EGLConfig aConfig) |
|
306 { |
|
307 EGLSurface surface = EGL_NO_SURFACE; |
|
308 if (iEglBufferType == EGL_PBUFFER_BIT) |
|
309 { |
|
310 // Create a Pbuffer surface. |
|
311 EGLint pbufferAttribList[] = |
|
312 { |
|
313 EGL_WIDTH, iSize.iWidth, |
|
314 EGL_HEIGHT, iSize.iHeight, |
|
315 EGL_NONE |
|
316 }; |
|
317 |
|
318 HUI_DEBUG(_L("CHuiVg10PBufferSurface::CreateSurface() - Attempting to create a PBuffer surface.")); |
|
319 surface = eglCreatePbufferSurface(iEglDisplay, aConfig, pbufferAttribList); |
|
320 } |
|
321 |
|
322 else if (iEglBufferType == EGL_PIXMAP_BIT) |
|
323 { |
|
324 delete(iBuffer); |
|
325 iBuffer = NULL; |
|
326 iBuffer = new CWsBitmap( CHuiStatic::WsSession() ); |
|
327 if (iBuffer && (iBufferColorMode > 0)) |
|
328 { |
|
329 iBuffer->Create( iSize, (TDisplayMode)iBufferColorMode); |
|
330 HUI_DEBUG(_L("CHuiVg10PBufferSurface::CreateSurface() - Attempting to create a Pixmap surface.")); |
|
331 surface = eglCreatePixmapSurface(iEglDisplay, aConfig, iBuffer, NULL); |
|
332 } |
|
333 } |
|
334 else |
|
335 { |
|
336 // For PC-lint |
|
337 } |
|
338 |
|
339 return surface; |
|
340 } |
|
341 |
|
342 |
|
343 TSize CHuiVg10PBufferSurface::Size() const |
|
344 { |
|
345 return iSize; |
|
346 } |
|
347 |
|
348 |
|
349 void CHuiVg10PBufferSurface::SetSizeL(const TSize& aSize) |
|
350 { |
|
351 iSize = aSize; |
|
352 |
|
353 // Recreate pbuffer surfaces. |
|
354 eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
|
355 |
|
356 // Recreate the rendering surface. |
|
357 eglDestroySurface(iEglDisplay, iEglSurface); |
|
358 |
|
359 iEglSurface = CreateSurface(DetermineConfig()); |
|
360 if(iEglSurface == EGL_NO_SURFACE) |
|
361 { |
|
362 TInt eglerr = eglGetError(); |
|
363 switch (eglerr) |
|
364 { |
|
365 case EGL_BAD_ALLOC: |
|
366 HUI_DEBUG2(_L("CHuiVg10PBufferSurface::SetSizeL() - ERROR! Failed to (re)create surface having size (%ix%i). Out of memory."), |
|
367 aSize.iWidth, aSize.iHeight); |
|
368 User::Leave(KErrNoMemory); |
|
369 default: |
|
370 HUI_DEBUG4(_L("CHuiVg10PBufferSurface::SetSizeL() - ERROR! Failed to (re)create surface having size (%ix%i).Cause: %S (EGL error code: %i). Leaving."), |
|
371 aSize.iWidth, aSize.iHeight, |
|
372 &CHuiVg10RenderSurface::EglErrorMessage(eglerr), eglerr); |
|
373 case EGL_SUCCESS: // indicates that no error was recorded, but still the CreateSurface call failed (=> unable to continue!) |
|
374 User::Leave(KErrNotSupported); |
|
375 } |
|
376 } |
|
377 |
|
378 MakeCurrent(); |
|
379 } |
|
380 |
|
381 |
|
382 void CHuiVg10PBufferSurface::MakeCurrent() |
|
383 { |
|
384 if (iEglSurface == NULL || iEglContext == NULL) |
|
385 { |
|
386 // we can't makeCurrent on a released surface |
|
387 return; |
|
388 } |
|
389 |
|
390 // No need to change the current render surface if this render surface is current already. |
|
391 if(CHuiStatic::CurrentRenderSurface() != ((MHuiRenderSurface*)this)) |
|
392 { |
|
393 eglMakeCurrent(iEglDisplay, iEglSurface, iEglSurface, iEglContext); |
|
394 |
|
395 TInt eglerr = eglGetError(); |
|
396 if(eglerr != EGL_SUCCESS) |
|
397 { |
|
398 HUI_DEBUG2(_L("CHuiVg10PBufferSurface::MakeCurrent() - Could not switch this rendering surface on. Cause: %S (EGL error code: %i). Panicking."), |
|
399 &CHuiVg10RenderSurface::EglErrorMessage(eglerr), eglerr); |
|
400 HUI_PANIC(THuiPanic::ERenderSurfaceActivationFailed) |
|
401 } |
|
402 CHuiStatic::SetCurrentRenderSurface(this); |
|
403 } |
|
404 } |
|
405 |
|
406 |
|
407 void CHuiVg10PBufferSurface::SwapBuffers() |
|
408 { |
|
409 // Pbuffers consist of a single buffer only (no front/back buffers to swap). |
|
410 } |
|
411 |
|
412 |
|
413 void CHuiVg10PBufferSurface::BindTexture(TInt aTextureUnit, |
|
414 const MHuiSegmentedTexture& aTexture, |
|
415 TInt aSegment) |
|
416 { |
|
417 (void)aTextureUnit; |
|
418 (void)aTexture; |
|
419 (void)aSegment; |
|
420 } |
|
421 |
|
422 void CHuiVg10PBufferSurface::HandleVisibilityEvent(TBool /* aIsVisible */ ) |
|
423 { |
|
424 // dummy method, does not handle the events in any way.. |
|
425 } |
|
426 |
|
427 void CHuiVg10PBufferSurface::Release() |
|
428 { |
|
429 |
|
430 HUI_DEBUG( _L("CHuiVg10PBufferSurface::Release() - Releasing EGL surface and context..") ); |
|
431 if (iEglSurface != NULL) |
|
432 { |
|
433 eglDestroySurface(iEglDisplay, iEglSurface); |
|
434 TInt eglerr = eglGetError(); |
|
435 if(eglerr != EGL_SUCCESS) |
|
436 { |
|
437 HUI_DEBUG2(_L("CHuiVg10PBufferSurface::Release() - WARNING! Could not destroy EGL surface. Cause: %S (EGL error code: %i)."), |
|
438 &CHuiVg10RenderSurface::EglErrorMessage(eglerr), eglerr); |
|
439 } |
|
440 iEglSurface = NULL; |
|
441 } |
|
442 |
|
443 // Delete pixmap if exists |
|
444 delete(iBuffer); |
|
445 iBuffer = NULL; |
|
446 |
|
447 if (iEglContext != NULL) |
|
448 { |
|
449 // Unshare this context if it was |
|
450 // set as shared.. |
|
451 if(iRenderer.EglSharedContext() == iEglContext) |
|
452 { |
|
453 HUI_DEBUG(_L("CHuiVg10PBufferSurface::Release() - Unsharing this render context.")); |
|
454 iRenderer.EglSetSharedContext(EGL_NO_CONTEXT); |
|
455 } |
|
456 |
|
457 eglDestroyContext(iEglDisplay, iEglContext); |
|
458 TInt eglerr = eglGetError(); |
|
459 if(eglerr != EGL_SUCCESS) |
|
460 { |
|
461 HUI_DEBUG2(_L("CHuiVg10PBufferSurface::Release() - WARNING! Could not destroy EGL context. Cause: %S (EGL error code: %i)."), |
|
462 &CHuiVg10RenderSurface::EglErrorMessage(eglerr), eglerr); |
|
463 } |
|
464 iEglContext = NULL; |
|
465 } |
|
466 |
|
467 } |
|
468 |
|
469 void CHuiVg10PBufferSurface::RestoreL() |
|
470 { |
|
471 |
|
472 HUI_DEBUG( _L("CHuiVg10PBufferSurface::RestoreL() - Restoring render surface.") ); |
|
473 |
|
474 if((iEglSurface != NULL) && (iEglContext != NULL)) |
|
475 { |
|
476 HUI_DEBUG( _L("CHuiVg10RenderSurface::RestoreL() - Render surface and context already in place, no need to restore.") ); |
|
477 } |
|
478 iEglDisplay = iRenderer.EglDisplay(); |
|
479 |
|
480 // Create an EGL rendering surface. |
|
481 EGLConfig config = DetermineConfig(); |
|
482 iEglSurface = CreateSurface(config); |
|
483 if(iEglSurface == EGL_NO_SURFACE) |
|
484 { |
|
485 TInt eglerr = eglGetError(); |
|
486 switch (eglerr) |
|
487 { |
|
488 case EGL_BAD_ALLOC: |
|
489 HUI_DEBUG2(_L("CHuiVg10PBufferSurface::RestoreL() - ERROR! Failed to create pbuffer surface having size (%ix%i). Out of memory."), |
|
490 iSize.iWidth, iSize.iHeight); |
|
491 User::Leave(KErrNoMemory); |
|
492 default: |
|
493 HUI_DEBUG4(_L("CHuiVg10PBufferSurface::RestoreL() - ERROR! Failed to create pbuffer surface having size (%ix%i). Cause: %S (EGL error code: %i)."), |
|
494 iSize.iWidth, iSize.iHeight, |
|
495 &CHuiVg10RenderSurface::EglErrorMessage(eglerr), eglerr); |
|
496 case EGL_SUCCESS: // indicates that no error was recorded, but still the CreateSurface call failed (=> unable to continue!) |
|
497 User::Leave(KErrNotSupported); |
|
498 } |
|
499 } |
|
500 |
|
501 // Create rendering context for PBuffer rendering. |
|
502 // There is only a single texture manager in the environment, so textures |
|
503 // need to shared between all contexts. |
|
504 iEglContext = eglCreateContext(iEglDisplay, config, |
|
505 iRenderer.EglSharedContext(), NULL); |
|
506 if(iEglContext == EGL_NO_CONTEXT) |
|
507 { |
|
508 TInt eglerr = eglGetError(); |
|
509 switch (eglerr) |
|
510 { |
|
511 case EGL_BAD_ALLOC: |
|
512 HUI_DEBUG(_L("CHuiVg10PBufferSurface::RestoreL() - ERROR! Failed to create rendering context. Out of memory.")); |
|
513 User::Leave(KErrNoMemory); |
|
514 default: |
|
515 HUI_DEBUG2(_L("CHuiVg10PBufferSurface::RestoreL() - ERROR! Failed to create rendering context. Cause: %S (EGL error code: %i)."), |
|
516 &CHuiVg10RenderSurface::EglErrorMessage(eglerr), eglerr); |
|
517 case EGL_SUCCESS: // indicates that no error was recorded, but still the CreateSurface call failed (=> unable to continue!) |
|
518 User::Leave(KErrNotSupported); |
|
519 } |
|
520 } |
|
521 |
|
522 // Share this context if there was not already a shared context for texture |
|
523 // management |
|
524 if(iRenderer.EglSharedContext() == EGL_NO_CONTEXT) |
|
525 { |
|
526 HUI_DEBUG(_L("CHuiVg10PBufferSurface::ConstructL() - Making this surface shared.")); |
|
527 // Now that there is a context, make sure the renderer knows of it. |
|
528 iRenderer.EglSetSharedContext(iEglContext); |
|
529 } |
|
530 eglMakeCurrent(iEglDisplay, iEglSurface, iEglSurface, iEglContext); |
|
531 } |
|
532 |
|
533 EGLSurface CHuiVg10PBufferSurface::EglSurface() |
|
534 { |
|
535 return iEglSurface; |
|
536 } |
|
537 |
|
538 void CHuiVg10PBufferSurface::BindToM3G() |
|
539 { |
|
540 } |
|
541 |
|
542 void CHuiVg10PBufferSurface::ReleaseFromM3G() |
|
543 { |
|
544 } |
|
545 |
|
546 CFbsBitmap* CHuiVg10PBufferSurface::Buffer() |
|
547 { |
|
548 return iBuffer; |
|
549 } |
|
550 |
|
551 TInt CHuiVg10PBufferSurface::BufferColorMode() const |
|
552 { |
|
553 return iBufferColorMode; |
|
554 } |
|
555 |
|
556 TUint CHuiVg10PBufferSurface::Flags() const |
|
557 { |
|
558 // ToDo: Is some flag needed? |
|
559 return MHuiRenderSurface::EFlagNone; |
|
560 } |
|
561 |
|
562 void CHuiVg10PBufferSurface::HandleDisplayUsageChangeL() |
|
563 { |
|
564 // Nothing to do |
|
565 } |
|
566 |
|
567 void CHuiVg10PBufferSurface::SetDirtyRect(const TRect& /*aRect*/) |
|
568 { |
|
569 // Nothing to do |
|
570 } |
|
571 |
|
572 MHuiTargetBitmap* CHuiVg10PBufferSurface::BackBuffer() |
|
573 { |
|
574 // Nothing to do |
|
575 return NULL; |
|
576 } |
|
577 |
|
578 CFbsBitGc* CHuiVg10PBufferSurface::Gc() |
|
579 { |
|
580 // Nothing to do |
|
581 return NULL; |
|
582 } |
|
583 |
|
584 void CHuiVg10PBufferSurface::RenderSurfaceExtension(const TUid& /*aExtensionUid*/, TAny** aExtensionParams) |
|
585 { |
|
586 *aExtensionParams = NULL; |
|
587 } |