100 WARN_PRINTF2(_L("thread %d: Calling eglDestroySurface() from ~CTestEglSession..."), iThreadIdx); |
100 WARN_PRINTF2(_L("thread %d: Calling eglDestroySurface() from ~CTestEglSession..."), iThreadIdx); |
101 ret = eglDestroySurface(iDisplay, iSurface); |
101 ret = eglDestroySurface(iDisplay, iSurface); |
102 if(ret == EGL_FALSE) |
102 if(ret == EGL_FALSE) |
103 { |
103 { |
104 WARN_PRINTF3(_L("thread %d: eglDestroySurface returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError()); |
104 WARN_PRINTF3(_L("thread %d: eglDestroySurface returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError()); |
105 } |
105 } |
106 } |
106 } |
107 |
107 |
108 if (iTerminateDisplay) |
108 if (iTerminateDisplay) |
109 { |
109 { |
110 INFO_PRINTF1(_L("Calling eglTerminate...")); |
110 INFO_PRINTF1(_L("Calling eglTerminate...")); |
111 ret = eglTerminate(iDisplay); |
111 ret = eglTerminate(iDisplay); |
112 iDisplay = EGL_NO_DISPLAY; |
112 iDisplay = EGL_NO_DISPLAY; |
113 if(ret == EGL_FALSE) |
113 if(ret == EGL_FALSE) |
114 { |
114 { |
115 WARN_PRINTF3(_L("thread %d: eglTerminate returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError()); |
115 WARN_PRINTF3(_L("thread %d: eglTerminate returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError()); |
116 } |
116 } |
117 } |
117 } |
118 } |
118 } |
119 |
119 |
120 // Only destroy native resource after the surface and context that wraps it has been destroyed. |
120 // Only destroy native resource after the surface and context that wraps it has been destroyed. |
121 delete iFbsBitmap; |
121 delete iFbsBitmap; |
122 CloseFbsSession(); |
122 CloseFbsSession(); |
123 |
123 |
124 iSgImage.Close(); |
124 iSgImage.Close(); |
125 CloseSgDriver(); |
125 CloseSgDriver(); |
126 } |
126 } |
127 |
127 |
128 EXPORT_C void CTestEglSession::SetExpectedError(EGLint aExpectedErrorCode) |
128 EXPORT_C void CTestEglSession::SetExpectedError(EGLint aExpectedErrorCode) |
129 { |
129 { |
130 VERBOSE_INFO_PRINTF3(_L("thread %d: Setting the expected error code for the next EGL call to %x"), iThreadIdx, aExpectedErrorCode); |
130 VERBOSE_INFO_PRINTF3(_L("thread %d: Setting the expected error code for the next EGL call to %x"), iThreadIdx, aExpectedErrorCode); |
131 { |
131 { |
132 iExpectedErrorCode = aExpectedErrorCode; |
132 iExpectedErrorCode = aExpectedErrorCode; |
133 } |
133 } |
134 } |
134 } |
135 |
135 |
136 EXPORT_C void CTestEglSession::ResetExpectedError() |
136 EXPORT_C void CTestEglSession::ResetExpectedError() |
137 { |
137 { |
147 */ |
147 */ |
148 EXPORT_C TBool CTestEglSession::CheckExpectedError(EGLint aFunctionReturnValue) |
148 EXPORT_C TBool CTestEglSession::CheckExpectedError(EGLint aFunctionReturnValue) |
149 { |
149 { |
150 TBool isExpectedError = ETrue; |
150 TBool isExpectedError = ETrue; |
151 EGLint eglErr = eglGetError(); |
151 EGLint eglErr = eglGetError(); |
152 |
152 |
153 // First check that we got the correct return value |
153 // First check that we got the correct return value |
154 if ((iExpectedErrorCode == EGL_SUCCESS) && !aFunctionReturnValue) |
154 if ((iExpectedErrorCode == EGL_SUCCESS) && !aFunctionReturnValue) |
155 { |
155 { |
156 ERR_PRINTF3(_L("thread %d: Wrong function return value: %d"), iThreadIdx, aFunctionReturnValue); |
156 ERR_PRINTF3(_L("thread %d: Wrong function return value: %d"), iThreadIdx, aFunctionReturnValue); |
157 isExpectedError = EFalse; |
157 isExpectedError = EFalse; |
158 } |
158 } |
159 // Also check that we got the |
159 // Also check that we got the |
160 if (eglErr != iExpectedErrorCode) |
160 if (eglErr != iExpectedErrorCode) |
161 { |
161 { |
162 ERR_PRINTF4(_L("thread %d: eglGetError() returned %x, but expected %x"), iThreadIdx, eglErr, iExpectedErrorCode); |
162 ERR_PRINTF4(_L("thread %d: eglGetError() returned %x, but expected %x"), iThreadIdx, eglErr, iExpectedErrorCode); |
163 isExpectedError = EFalse; |
163 isExpectedError = EFalse; |
164 } |
164 } |
165 else if (eglErr != EGL_SUCCESS) |
165 else if (eglErr != EGL_SUCCESS) |
166 { |
166 { |
167 VERBOSE_INFO_PRINTF3(_L("thread %d: eglGetError() returned %x, as expected"), iThreadIdx, eglErr); |
167 VERBOSE_INFO_PRINTF3(_L("thread %d: eglGetError() returned %x, as expected"), iThreadIdx, eglErr); |
168 } |
168 } |
169 |
169 |
170 // Reset the expected error |
170 // Reset the expected error |
171 ResetExpectedError(); |
171 ResetExpectedError(); |
172 |
172 |
173 return isExpectedError; |
173 return isExpectedError; |
174 } |
174 } |
175 |
175 |
176 EXPORT_C void CTestEglSession::CheckExpectedErrorL(EGLint aExpectedErrorCode) |
176 EXPORT_C void CTestEglSession::CheckExpectedErrorL(EGLint aExpectedErrorCode) |
177 { |
177 { |
178 EGLint eglErr = eglGetError(); |
178 EGLint eglErr = eglGetError(); |
179 // check that we got the expected error |
179 // check that we got the expected error |
180 if (eglErr != aExpectedErrorCode) |
180 if (eglErr != aExpectedErrorCode) |
181 { |
181 { |
182 ERR_PRINTF4(_L("thread %d: eglGetError() returned %x, but expected %x"), iThreadIdx, eglErr, aExpectedErrorCode); |
182 ERR_PRINTF4(_L("thread %d: eglGetError() returned %x, but expected %x"), iThreadIdx, eglErr, aExpectedErrorCode); |
183 User::Leave(KErrTEFUnitFail); |
183 User::Leave(KErrTEFUnitFail); |
184 } |
184 } |
185 } |
185 } |
186 |
186 |
187 void CTestEglSession::QueryExtensionsL(TExtensionsGroups aExtensionBelongsTo) |
187 void CTestEglSession::QueryExtensionsL(TExtensionsGroups aExtensionBelongsTo) |
188 { |
188 { |
189 // reset the cached extensions |
189 // reset the cached extensions |
190 iExtensionStrings.Reset(); |
190 iExtensionStrings.Reset(); |
191 |
191 |
192 const char* extensionsString = NULL; |
192 const char* extensionsString = NULL; |
193 if(aExtensionBelongsTo == EIsEGL) |
193 if(aExtensionBelongsTo == EIsEGL) |
194 { |
194 { |
195 INFO_PRINTF2(_L("thread %d: Calling eglQueryString for EGL_EXTENSIONS)"), iThreadIdx); |
195 INFO_PRINTF2(_L("thread %d: Calling eglQueryString for EGL_EXTENSIONS)"), iThreadIdx); |
196 extensionsString = eglQueryString(iDisplay, EGL_EXTENSIONS); |
196 extensionsString = eglQueryString(iDisplay, EGL_EXTENSIONS); |
197 } |
197 } |
198 else if(aExtensionBelongsTo == EIsVG) |
198 else if(aExtensionBelongsTo == EIsVG) |
199 { |
199 { |
200 INFO_PRINTF2(_L("thread %d: Calling vgGetString for VG_EXTENSIONS)"), iThreadIdx); |
200 INFO_PRINTF2(_L("thread %d: Calling vgGetString for VG_EXTENSIONS)"), iThreadIdx); |
201 |
201 |
202 // OpenVG needs a current VG context before it will allow the call to vgGetString |
202 // OpenVG needs a current VG context before it will allow the call to vgGetString |
203 TSgImageInfoOpenVgTarget imageInfo; |
203 // The created surface will remain un-used, hence we create it with an arbitrary pixel format |
204 imageInfo.iSizeInPixels = KPixmapSize; |
204 EGLConfig currentConfig = GetConfigExactMatchL(EPBufferAttribsColor64K); |
205 imageInfo.iPixelFormat = EUidPixelFormatXRGB_8888; |
205 CreatePbufferSurfaceAndMakeCurrentL(currentConfig, TSize(1,1), EGL_OPENVG_API); |
206 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
|
207 imageInfo.iUsage = ESgUsageBitOpenVgSurface; |
|
208 #else |
|
209 imageInfo.iUsage = ESgUsageOpenVgTarget; |
|
210 #endif |
|
211 CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo,CTestEglSession::EResourceCloseSgImageEarly); |
|
212 |
206 |
213 extensionsString = (const char*) vgGetString(VG_EXTENSIONS); |
207 extensionsString = (const char*) vgGetString(VG_EXTENSIONS); |
214 |
208 |
215 //cleanup the context & surface |
209 //cleanup the context & surface |
216 CleanupSurfaceSgImageL(); |
210 CleanupSurfaceSgImageL(); |
379 #endif |
377 #endif |
380 eglGetConfigAttrib(iDisplay, configs[index], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value); |
378 eglGetConfigAttrib(iDisplay, configs[index], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value); |
381 |
379 |
382 TBool good = ETrue; |
380 TBool good = ETrue; |
383 |
381 |
384 INFO_PRINTF7(_L("(idx: %3d) RGBA=(%2d) %2d,%2d,%2d,%2d"), index, EGL_BUFFER_SIZE_value, |
382 INFO_PRINTF7(_L("(idx: %3d) RGBA=(%2d) %2d,%2d,%2d,%2d"), index, EGL_BUFFER_SIZE_value, |
385 EGL_RED_SIZE_value, EGL_GREEN_SIZE_value, EGL_BLUE_SIZE_value, |
383 EGL_RED_SIZE_value, EGL_GREEN_SIZE_value, EGL_BLUE_SIZE_value, |
386 EGL_ALPHA_SIZE_value); |
384 EGL_ALPHA_SIZE_value); |
387 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 0)) |
385 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 0)) |
388 { |
386 { |
389 continue; |
387 continue; |
390 } |
388 } |
391 |
389 |
392 INFO_PRINTF2(_L("\n\n^^^^^^ CONFIG [%d] VALUES ******"), index); |
390 INFO_PRINTF2(_L("\n\n^^^^^^ CONFIG [%d] VALUES ******"), index); |
393 if (EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT) |
391 if (EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT) |
394 { |
392 { |
395 INFO_PRINTF2(_L("EGL_SURFACE_TYPE=%d. <<< Has EGL_PIXMAP_BIT"), EGL_SURFACE_TYPE_value); |
393 INFO_PRINTF2(_L("EGL_SURFACE_TYPE=%d. <<< Has EGL_PIXMAP_BIT"), EGL_SURFACE_TYPE_value); |
396 } |
394 } |
397 else |
395 else |
398 { |
396 { |
399 INFO_PRINTF2(_L("EGL_SURFACE_TYPE=%d. <<< BAD (not pixmap)"), EGL_SURFACE_TYPE_value); |
397 INFO_PRINTF2(_L("EGL_SURFACE_TYPE=%d. <<< BAD (not pixmap)"), EGL_SURFACE_TYPE_value); |
400 good = EFalse; |
398 good = EFalse; |
401 } |
399 } |
402 |
400 |
403 if (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT) |
401 if (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT) |
404 { |
402 { |
405 INFO_PRINTF2(_L("EGL_RENDERABLE_TYPE=%d. <<< Has EGL_OPENVG_BIT"), EGL_RENDERABLE_TYPE_value); |
403 INFO_PRINTF2(_L("EGL_RENDERABLE_TYPE=%d. <<< Has EGL_OPENVG_BIT"), EGL_RENDERABLE_TYPE_value); |
406 } |
404 } |
407 else |
405 else |
408 { |
406 { |
409 INFO_PRINTF2(_L("EGL_RENDERABLE_TYPE=%d. <<< BAD (not open vg)"), EGL_RENDERABLE_TYPE_value); |
407 INFO_PRINTF2(_L("EGL_RENDERABLE_TYPE=%d. <<< BAD (not open vg)"), EGL_RENDERABLE_TYPE_value); |
410 good = EFalse; |
408 good = EFalse; |
411 } |
409 } |
412 |
410 |
413 if (good) |
411 if (good) |
414 { |
412 { |
415 INFO_PRINTF1(_L("^^^^^^^ GOOD ^^^^^^^")); |
413 INFO_PRINTF1(_L("^^^^^^^ GOOD ^^^^^^^")); |
416 } |
414 } |
417 |
415 |
559 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &blueSize)); |
557 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &blueSize)); |
560 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_COLOR_BUFFER_TYPE, &colorBufferType)); |
558 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_COLOR_BUFFER_TYPE, &colorBufferType)); |
561 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &surfaceType)); |
559 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &surfaceType)); |
562 |
560 |
563 INFO_PRINTF7(_L(">>>>> Config info: %d, %d, %d,%d,%d, 0x%x"), bufferSize, alphaSize, redSize, greenSize, blueSize, colorBufferType); |
561 INFO_PRINTF7(_L(">>>>> Config info: %d, %d, %d,%d,%d, 0x%x"), bufferSize, alphaSize, redSize, greenSize, blueSize, colorBufferType); |
564 |
562 |
565 for(TUint i=0; i<ConfigToPixelFormatTableLength(); i++) |
563 for(TUint i=0; i<ConfigToPixelFormatTableLength(); i++) |
566 { |
564 { |
567 if ((ConfigToPixelFormatTable(i).iBufferSize == bufferSize) |
565 if ((ConfigToPixelFormatTable(i).iBufferSize == bufferSize) |
568 && (ConfigToPixelFormatTable(i).iAlphaSize == alphaSize) |
566 && (ConfigToPixelFormatTable(i).iAlphaSize == alphaSize) |
569 && (ConfigToPixelFormatTable(i).iRedSize == redSize) |
567 && (ConfigToPixelFormatTable(i).iRedSize == redSize) |
630 if(aConfigAttribIndex >= EEglTestConfigMax ) |
628 if(aConfigAttribIndex >= EEglTestConfigMax ) |
631 { |
629 { |
632 ERR_PRINTF1(_L("Attribute index out of range, please check the INI file")); |
630 ERR_PRINTF1(_L("Attribute index out of range, please check the INI file")); |
633 User::Leave(KErrArgument); |
631 User::Leave(KErrArgument); |
634 } |
632 } |
635 |
633 |
636 EGLConfig configs[KMaxEglConfigs]; |
634 EGLConfig configs[KMaxEglConfigs]; |
637 EGLint numConfigs=0; |
635 EGLint numConfigs=0; |
638 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[aConfigAttribIndex], configs, KMaxEglConfigs, &numConfigs)); |
636 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[aConfigAttribIndex], configs, KMaxEglConfigs, &numConfigs)); |
639 if (numConfigs <= 0) |
637 if (numConfigs <= 0) |
640 { |
638 { |
641 // we just WARN, as we don't know if this is expected yet (if it is, then catch the leaving error) |
639 // we just WARN, as we don't know if this is expected yet (if it is, then catch the leaving error) |
642 WARN_PRINTF1(_L("GetConfigExactMatchL - Could not find a matching config, eglChooseConfig returned 0 configs!")); |
640 WARN_PRINTF1(_L("GetConfigExactMatchL - Could not find a matching config, eglChooseConfig returned 0 configs!")); |
643 User::Leave(KTestNoMatchingConfig); |
641 User::Leave(KTestNoMatchingConfig); |
644 } |
642 } |
645 |
643 |
646 // Check that any of the configs returned matches the desired attributes |
644 // Check that any of the configs returned matches the desired attributes |
647 TInt match = GetFullMatchConfigIndex(iDisplay, configs, numConfigs, KConfigAttribs[aConfigAttribIndex], aMatchRule); |
645 TInt match = GetFullMatchConfigIndex(iDisplay, configs, numConfigs, KConfigAttribs[aConfigAttribIndex], aMatchRule); |
648 if (match == KErrNotFound) |
646 if (match == KErrNotFound) |
649 { |
647 { |
650 // we just WARN, as we don't know if this is expected yet (if it is, then catch the leaving error) |
648 // we just WARN, as we don't know if this is expected yet (if it is, then catch the leaving error) |
718 imageInfo.iUserAttributes = NULL; |
716 imageInfo.iUserAttributes = NULL; |
719 imageInfo.iUserAttributeCount=0; |
717 imageInfo.iUserAttributeCount=0; |
720 #endif |
718 #endif |
721 CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, EResourceCloseSgImageLate); |
719 CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, EResourceCloseSgImageLate); |
722 DrawOpenVgL(); |
720 DrawOpenVgL(); |
723 |
721 |
724 // Wait for the drawing to complete |
722 // Wait for the drawing to complete |
725 eglWaitClient(); |
723 eglWaitClient(); |
726 |
724 |
727 //we can't retrieve data directly from the SgImage as |
725 //we can't retrieve data directly from the SgImage as |
728 //non-unified architecture doesn't allow readback from the GPU |
726 //non-unified architecture doesn't allow readback from the GPU |
729 CheckImageDataVgL(VG_sXRGB_8888); |
727 CheckImageDataVgL(VG_sXRGB_8888); |
730 CleanupSurfaceSgImageL(); |
728 CleanupSurfaceSgImageL(); |
731 CloseSgDriver(); |
729 CloseSgDriver(); |
732 } |
730 } |
733 |
731 |
734 EXPORT_C TBool CTestEglSession::TryUsePixmapRSgImageOpenGlesL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule, TInt aRenderVersion) |
732 EXPORT_C TBool CTestEglSession::TryUsePixmapRSgImageOpenGlesL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule, TInt aRenderVersion) |
735 { |
733 { |
736 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule ,EGL_OPENGL_ES_API, aRenderVersion); |
734 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule ,EGL_OPENGL_ES_API, aRenderVersion); |
737 |
735 |
738 DrawOpenGLesL(); |
736 DrawOpenGLesL(); |
739 |
737 |
740 // Wait for the drawing to complete |
738 // Wait for the drawing to complete |
741 eglWaitClient(); |
739 eglWaitClient(); |
742 |
740 |
743 //we can't retrieve data directly from SgImage as non-unified |
741 //we can't retrieve data directly from SgImage as non-unified |
744 //architecture doesn't allow readback from the GPU |
742 //architecture doesn't allow readback from the GPU |
745 |
743 |
746 if (aImageInfo.iPixelFormat == EUidPixelFormatXRGB_8888 || |
744 if (aImageInfo.iPixelFormat == EUidPixelFormatXRGB_8888 || |
747 aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) |
745 aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) |
748 { |
746 { |
749 CheckImageDataGLesL(); |
747 CheckImageDataGLesL(); |
750 } |
748 } |
751 |
749 |
752 CleanupSurfaceSgImageL(); |
750 CleanupSurfaceSgImageL(); |
753 CloseSgDriver(); |
751 CloseSgDriver(); |
765 @return Whether it was possible to create an iSgImage for the given aImageInfo |
763 @return Whether it was possible to create an iSgImage for the given aImageInfo |
766 */ |
764 */ |
767 EXPORT_C TBool CTestEglSession::TryUsePixmapRSgImageOpenVgL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule) |
765 EXPORT_C TBool CTestEglSession::TryUsePixmapRSgImageOpenVgL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule) |
768 { |
766 { |
769 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule); |
767 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule); |
770 |
768 |
771 DrawOpenVgL(); |
769 DrawOpenVgL(); |
772 |
770 |
773 // Wait for the drawing to complete |
771 // Wait for the drawing to complete |
774 eglWaitClient(); |
772 eglWaitClient(); |
775 |
773 |
776 //we can't retrieve data directly from the SgImage as |
774 //we can't retrieve data directly from the SgImage as |
777 //non-unified architecture doesn't allow readback from the GPU |
775 //non-unified architecture doesn't allow readback from the GPU |
778 CheckImageDataVgL(VG_sXRGB_8888); |
776 CheckImageDataVgL(VG_sXRGB_8888); |
779 CleanupSurfaceSgImageL(); |
777 CleanupSurfaceSgImageL(); |
780 CloseSgDriver(); |
778 CloseSgDriver(); |
781 return ETrue; |
779 return ETrue; |
782 } |
780 } |
783 |
781 |
784 EXPORT_C void CTestEglSession::CreateWindowSurfaceAndMakeCurrentL(EGLConfig aConfig, RWindow& aWindow, EGLenum aBindAPI, TInt aRenderVersionNumber) |
782 EXPORT_C void CTestEglSession::CreateWindowSurfaceAndMakeCurrentL(EGLConfig aConfig, RWindow& aWindow, TBool aVgAlphaFormatPre, EGLenum aBindAPI, TInt aRenderVersionNumber) |
785 { |
783 { |
786 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
784 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
787 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
785 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
788 |
786 |
789 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
787 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
790 |
788 |
791 // Create a Window surface from the native image |
789 // Create a Window surface from the native image |
792 EGLint EGL_RENDERABLE_TYPE_value = 0; |
790 const EGLint* windowAttribs = (aVgAlphaFormatPre && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
793 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
791 iSurface = eglCreateWindowSurface(iDisplay, aConfig, &aWindow, windowAttribs); |
794 const EGLint* pixmapAttribs = ((aWindow.DisplayMode() == EColor16MAP) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
|
795 iSurface = eglCreateWindowSurface(iDisplay, aConfig, &aWindow, pixmapAttribs); |
|
796 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
792 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
797 |
793 |
798 // Create a context for drawing to/reading from the pixmap surface and make it current |
794 // Create a context for drawing to/reading from the pixmap surface and make it current |
799 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
795 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
800 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
796 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
801 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
797 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
802 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
798 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
803 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
799 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
804 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
800 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
805 } |
801 } |
806 |
802 |
807 |
803 |
808 EXPORT_C TBool CTestEglSession::CongfigSupportsOpenVgL(EGLConfig aConfig) |
804 EXPORT_C TBool CTestEglSession::CongfigSupportsOpenVgL(EGLConfig aConfig) |
863 EGLint EGL_RENDERABLE_TYPE_value = 0; |
859 EGLint EGL_RENDERABLE_TYPE_value = 0; |
864 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, config, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
860 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, config, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
865 const EGLint* pixmapAttribs = ((aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
861 const EGLint* pixmapAttribs = ((aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
866 iSurface = eglCreatePixmapSurface(iDisplay, config, &iSgImage, pixmapAttribs); |
862 iSurface = eglCreatePixmapSurface(iDisplay, config, &iSgImage, pixmapAttribs); |
867 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
863 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
868 |
864 |
869 if (aResourceCloseRule == EResourceCloseSgImageEarly) |
865 if (aResourceCloseRule == EResourceCloseSgImageEarly) |
870 { |
866 { |
871 // EGL should have taken its own reference to the SgImage, so it should be able to continue |
867 // EGL should have taken its own reference to the SgImage, so it should be able to continue |
872 // to use the underlying data after this local image has been closed. |
868 // to use the underlying data after this local image has been closed. |
873 iSgImage.Close(); |
869 iSgImage.Close(); |
874 } |
870 } |
875 |
871 |
876 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly) |
872 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly) |
877 { |
873 { |
878 // EGL should have taken its own reference to the SgDriver, so it should be able to continue |
874 // EGL should have taken its own reference to the SgDriver, so it should be able to continue |
879 // to use its reference to the image resource after this local reference to the driver has |
875 // to use its reference to the image resource after this local reference to the driver has |
880 // been closed. |
876 // been closed. |
881 iSgImage.Close(); |
877 iSgImage.Close(); |
882 CloseSgDriver(); |
878 CloseSgDriver(); |
883 } |
879 } |
884 |
880 |
885 // Create a context for drawing to/reading from the pixmap surface and make it current |
881 // Create a context for drawing to/reading from the pixmap surface and make it current |
886 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
882 const EGLint KAttribsListCtxNone[] = { EGL_NONE }; |
887 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
883 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
888 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
884 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
889 iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx); |
885 iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx); |
890 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
886 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
891 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
887 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
892 } |
888 } |
893 |
889 |
894 /** |
890 /** |
895 Compound operation that constructs an RSgImage and uses it to create a pixmap suface. |
891 Compound operation that constructs an RSgImage and uses it to create a pixmap suface. |
896 It then makes it current to the thread. |
892 It then makes it current to the thread. |
897 @param aConfig The EGL config to be used when creating the pixmap surface |
893 @param aConfig The EGL config to be used when creating the pixmap surface |
898 @param aImageInfo Used to create the RSgImage pixmap |
894 @param aImageInfo Used to create the RSgImage pixmap |
899 @param aCloseNativeImageEarly When ETrue, the RSgImage is closed as soon as the pixmap surface has been |
895 @param aCloseNativeImageEarly When ETrue, the RSgImage is closed as soon as the pixmap surface has been |
900 created. Otherwise, the RSgImage is left to be destroyed later by some other method |
896 created. Otherwise, the RSgImage is left to be destroyed later by some other method |
901 - e.g at the same time as destroying the surface. |
897 - e.g at the same time as destroying the surface. |
902 @return Whether it was possible to create an iSgImage for the given aImageInfo |
898 @return Whether it was possible to create an iSgImage for the given aImageInfo |
903 */ |
899 */ |
904 EXPORT_C void CTestEglSession::CreatePixmapSurfaceAndMakeCurrentL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule, EGLenum aBindAPI, TInt aRenderVersionNumber) |
900 EXPORT_C void CTestEglSession::CreatePixmapSurfaceAndMakeCurrentL(EGLConfig aConfig, const TSgImageInfo& aImageInfo, TResourceCloseRule aResourceCloseRule, EGLenum aBindAPI, TInt aRenderVersionNumber) |
905 { |
901 { |
906 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
902 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
907 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
903 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
908 |
904 |
909 OpenSgDriverL(); |
905 OpenSgDriverL(); |
910 ASSERT_EQUALS(iSgImage.Create(aImageInfo, NULL, 0), KErrNone); |
906 ASSERT_EQUALS(iSgImage.Create(aImageInfo, NULL, 0), KErrNone); |
911 |
907 |
912 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
908 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
913 |
909 |
914 // Create a pixmap surface from the native image |
910 // Create a pixmap surface from the native image |
915 EGLint EGL_RENDERABLE_TYPE_value = 0; |
911 EGLint EGL_RENDERABLE_TYPE_value = 0; |
916 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
912 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
917 const EGLint* pixmapAttribs = ((aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
913 const EGLint* pixmapAttribs = ((aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
918 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, &iSgImage, pixmapAttribs); |
914 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, &iSgImage, pixmapAttribs); |
919 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
915 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
920 |
916 |
921 if (aResourceCloseRule == EResourceCloseSgImageEarly) |
917 if (aResourceCloseRule == EResourceCloseSgImageEarly) |
922 { |
918 { |
923 // EGL should have taken its own reference to the SgImage, so it should be able to continue |
919 // EGL should have taken its own reference to the SgImage, so it should be able to continue |
924 // to use the underlying data after this local image has been closed. |
920 // to use the underlying data after this local image has been closed. |
925 iSgImage.Close(); |
921 iSgImage.Close(); |
926 } |
922 } |
927 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly) |
923 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly) |
928 { |
924 { |
929 // EGL should have taken its own reference to the SgDriver, so it should be able to continue |
925 // EGL should have taken its own reference to the SgDriver, so it should be able to continue |
930 // to use its reference to the image resource after this local reference to the driver has |
926 // to use its reference to the image resource after this local reference to the driver has |
931 // been closed. |
927 // been closed. |
932 iSgImage.Close(); |
928 iSgImage.Close(); |
933 CloseSgDriver(); |
929 CloseSgDriver(); |
934 } |
930 } |
935 |
931 |
936 // Create a context for drawing to/reading from the pixmap surface and make it current |
932 // Create a context for drawing to/reading from the pixmap surface and make it current |
937 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
933 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
938 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
934 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
939 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
935 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
940 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
936 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
941 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
937 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
942 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
938 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
943 } |
939 } |
944 |
940 |
945 EXPORT_C TInt CTestEglSession::CreateBitmap(CFbsBitmap* aFbsBitmap, const TSize& aSize, TDisplayMode aDisplayMode) |
941 EXPORT_C TInt CTestEglSession::CreateBitmap(CFbsBitmap* aFbsBitmap, const TSize& aSize, TDisplayMode aDisplayMode) |
946 { |
942 { |
947 //Fist try with CreateHardwareBitmap to check whether we are on hardware |
943 //Fist try with CreateHardwareBitmap to check whether we are on hardware |
948 TInt result = aFbsBitmap->CreateHardwareBitmap(aSize, aDisplayMode, KUidEglTestServer); |
944 TInt result = aFbsBitmap->CreateHardwareBitmap(aSize, aDisplayMode, KUidEglTestServer); |
949 |
945 |
950 if(result == KErrNotSupported) |
946 if(result == KErrNotSupported) |
951 { |
947 { |
952 //we are not on hardware |
948 //we are not on hardware |
953 result = aFbsBitmap->Create(aSize, aDisplayMode); |
949 result = aFbsBitmap->Create(aSize, aDisplayMode); |
954 } |
950 } |
983 { |
979 { |
984 ERR_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentL - Unkown API requested!")); |
980 ERR_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentL - Unkown API requested!")); |
985 User::Leave(KErrArgument); |
981 User::Leave(KErrArgument); |
986 } |
982 } |
987 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
983 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
988 |
984 |
989 // Create a pixmap surface from the native image |
985 // Create a pixmap surface from the native image |
990 EGLint EGL_RENDERABLE_TYPE_value = 0; |
986 EGLint EGL_RENDERABLE_TYPE_value = 0; |
991 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
987 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
992 const EGLint* pixmapAttribs = ((displayMode == EColor16MAP) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
988 const EGLint* pixmapAttribs = ((displayMode == EColor16MAP) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
993 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, iFbsBitmap, pixmapAttribs); |
989 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, iFbsBitmap, pixmapAttribs); |
994 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
990 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
995 |
991 |
996 // Create a context for drawing to/reading from the pixmap surface and make it current |
992 // Create a context for drawing to/reading from the pixmap surface and make it current |
997 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list); |
993 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list); |
998 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
994 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
999 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
995 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1000 } |
996 } |
1001 |
997 |
1002 EXPORT_C void CTestEglSession::CreatePixmapSurfaceAndMakeCurrentAndMatchL(const TSize& aSize, TDisplayMode displayMode, EGLenum aBindAPI, TInt aRenderVersionNumber) |
998 EXPORT_C void CTestEglSession::CreatePixmapSurfaceAndMakeCurrentAndMatchL(const TSize& aSize, TDisplayMode aDisplayMode, EGLenum aBindAPI, TInt aRenderVersionNumber) |
1003 { |
999 { |
1004 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1000 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1005 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1001 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1006 |
1002 |
1007 OpenFbsSessionL(); |
1003 OpenFbsSessionL(); |
1008 iFbsBitmap = new(ELeave)CFbsBitmap; |
1004 iFbsBitmap = new(ELeave)CFbsBitmap; |
1009 ASSERT_EQUALS(CreateBitmap(iFbsBitmap, aSize, displayMode), KErrNone); |
1005 ASSERT_EQUALS(CreateBitmap(iFbsBitmap, aSize, aDisplayMode), KErrNone); |
1010 |
1006 |
1011 EGLint renderableType = 0; |
1007 EGLint renderableType = 0; |
1012 if(aBindAPI == EGL_OPENVG_API) |
1008 if(aBindAPI == EGL_OPENVG_API) |
1013 { |
1009 { |
1014 renderableType = EGL_OPENVG_BIT; |
1010 renderableType = EGL_OPENVG_BIT; |
1046 // Leave with a unique knonwn error code - useful to catch this error in negative tests |
1042 // Leave with a unique knonwn error code - useful to catch this error in negative tests |
1047 User::Leave(KTestNoMatchingConfig); |
1043 User::Leave(KTestNoMatchingConfig); |
1048 } |
1044 } |
1049 |
1045 |
1050 // Create a pixmap surface from the native image |
1046 // Create a pixmap surface from the native image |
1051 EGLint EGL_RENDERABLE_TYPE_value = 0; |
1047 const EGLint* pixmapAttribs = (aDisplayMode == EColor16MAP && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
1052 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, config, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
|
1053 const EGLint* pixmapAttribs = ((displayMode == EColor16MAP) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
|
1054 iSurface = eglCreatePixmapSurface(iDisplay, config, iFbsBitmap, pixmapAttribs); |
1048 iSurface = eglCreatePixmapSurface(iDisplay, config, iFbsBitmap, pixmapAttribs); |
1055 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
1049 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
1056 |
1050 |
1057 // Create a context for drawing to/reading from the pixmap surface and make it current |
1051 // Create a context for drawing to/reading from the pixmap surface and make it current |
1058 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
1052 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
1059 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
1053 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
1060 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
1054 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
1061 iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx); |
1055 iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx); |
1062 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
1056 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
1063 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1057 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1064 } |
1058 } |
1065 |
1059 |
1066 EXPORT_C void CTestEglSession::CreatePbufferSurfaceAndMakeCurrentL(EGLConfig aConfig, const TSize& aSize, EGLenum aBindAPI, TInt aRenderVersionNumber) |
1060 EXPORT_C void CTestEglSession::CreatePbufferSurfaceAndMakeCurrentL(EGLConfig aConfig, const TSize& aSize, EGLenum aBindAPI, TInt aRenderVersionNumber) |
1067 { |
1061 { |
1068 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1062 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1069 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1063 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1070 |
1064 |
1071 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1065 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1072 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1066 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1073 |
1067 |
1074 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
1068 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
1075 |
1069 |
1076 // PBuffer attribs options are: |
1070 // PBuffer attribs options are: |
1077 // EGL_WIDTH, EGL_HEIGHT, EGL_LARGEST_PBUFFER, |
1071 // EGL_WIDTH, EGL_HEIGHT, EGL_LARGEST_PBUFFER, |
1078 // EGL_TEXTURE_FORMAT, EGL_TEXTURE_TARGET, EGL_MIPMAP_TEXTURE, |
1072 // EGL_TEXTURE_FORMAT, EGL_TEXTURE_TARGET, EGL_MIPMAP_TEXTURE, |
1079 // EGL_VG_COLORSPACE, and EGL_VG_ALPHA_FORMAT |
1073 // EGL_VG_COLORSPACE, and EGL_VG_ALPHA_FORMAT |
1080 // Create a pbuffer surface of the given size |
1074 // Create a pbuffer surface of the given size |
1081 const EGLint KPbufferAttribs[] = { |
1075 const EGLint KPbufferAttribs[] = { |
1082 EGL_WIDTH, aSize.iWidth, |
1076 EGL_WIDTH, aSize.iWidth, |
1083 EGL_HEIGHT, aSize.iHeight, |
1077 EGL_HEIGHT, aSize.iHeight, |
1084 EGL_NONE }; |
1078 EGL_NONE }; |
1085 iSurface = eglCreatePbufferSurface(iDisplay, aConfig, KPbufferAttribs); |
1079 iSurface = eglCreatePbufferSurface(iDisplay, aConfig, KPbufferAttribs); |
1086 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
1080 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
1087 |
1081 |
1088 // Create a context for drawing to/reading from the pixmap surface and make it current |
1082 // Create a context for drawing to/reading from the pixmap surface and make it current |
1089 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
1083 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
1090 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
1084 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
1091 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
1085 const EGLint* attrib_list_ctx = (aBindAPI == EGL_OPENGL_ES_API && aRenderVersionNumber == 2) ? KAttribsListCtxGles2 : KAttribsListCtxNone; |
1092 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
1086 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
1093 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
1087 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
1094 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1088 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1095 } |
1089 } |
1096 |
1090 |
1097 EXPORT_C void CTestEglSession::DrawOpenVgL() |
1091 EXPORT_C void CTestEglSession::DrawOpenVgL() |
1098 { |
1092 { |
1099 ASSERT_TRUE(iSurface != EGL_NO_SURFACE); |
1093 ASSERT_TRUE(iSurface != EGL_NO_SURFACE); |
1100 ASSERT_TRUE(iContext != EGL_NO_CONTEXT); |
1094 ASSERT_TRUE(iContext != EGL_NO_CONTEXT); |
1101 |
1095 |
1102 // Draw to the pixmap surface |
1096 // Draw to the pixmap surface |
1103 // Clear it: redish |
1097 // Clear it: redish |
1104 VGfloat colorBackground[4]; |
1098 VGfloat colorBackground[4]; |
1105 ConvertColor(KRgbReddish, colorBackground); |
1099 ConvertColor(KRgbReddish, colorBackground); |
1106 vgSetfv(VG_CLEAR_COLOR, 4, colorBackground); |
1100 vgSetfv(VG_CLEAR_COLOR, 4, colorBackground); |
1107 vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); |
1101 vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); |
1108 |
1102 |
1109 // And add a square: greenish |
1103 // And add a square: greenish |
1110 VGfloat colorSquare[4]; |
1104 VGfloat colorSquare[4]; |
1111 ConvertColor(KRgbGreenish, colorSquare); |
1105 ConvertColor(KRgbGreenish, colorSquare); |
1112 vgSetfv(VG_CLEAR_COLOR, 4, colorSquare); |
1106 vgSetfv(VG_CLEAR_COLOR, 4, colorSquare); |
1113 vgClear(KPixmapSquare.iTl.iX, KPixmapSquare.iTl.iX, KPixmapSquare.Width(), KPixmapSquare.Height()); |
1107 vgClear(KPixmapSquare.iTl.iX, KPixmapSquare.iTl.iX, KPixmapSquare.Width(), KPixmapSquare.Height()); |
1124 const GLfloat glAlpha = KRgbReddish.Alpha(); |
1118 const GLfloat glAlpha = KRgbReddish.Alpha(); |
1125 const GLfloat glRedBits = 255.f; |
1119 const GLfloat glRedBits = 255.f; |
1126 const GLfloat glGreenBits = 255.f; |
1120 const GLfloat glGreenBits = 255.f; |
1127 const GLfloat glBlueBits = 255.f; |
1121 const GLfloat glBlueBits = 255.f; |
1128 const GLfloat glAlphaBits = 255.f; |
1122 const GLfloat glAlphaBits = 255.f; |
1129 |
1123 |
1130 // Disable cdither - when using exact comparison to reference bitmap |
1124 // Disable cdither - when using exact comparison to reference bitmap |
1131 // because reference bitmap cannot be created to match dither exactly |
1125 // because reference bitmap cannot be created to match dither exactly |
1132 glDisable(GL_DITHER); |
1126 glDisable(GL_DITHER); |
1133 // Clear the surface to the colour specified |
1127 // Clear the surface to the colour specified |
1134 glClearColor((glRed)/glRedBits, (glGreen)/glGreenBits, (glBlue)/glBlueBits, glAlpha/glAlphaBits); |
1128 glClearColor((glRed)/glRedBits, (glGreen)/glGreenBits, (glBlue)/glBlueBits, glAlpha/glAlphaBits); |
1135 |
1129 |
1136 //glColor3f(KRgbGreenish.Red(),KRgbGreenish.Green(),KRgbGreenish.Blue()); |
1130 //glColor3f(KRgbGreenish.Red(),KRgbGreenish.Green(),KRgbGreenish.Blue()); |
1137 //glRectf(KPixmapSquare.iTl.iX, KPixmapSquare.iTl.iY,KPixmapSquare.iTl.iX + KPixmapSquare.Width(),KPixmapSquare.iTl.iY + KPixmapSquare.Height()); |
1131 //glRectf(KPixmapSquare.iTl.iX, KPixmapSquare.iTl.iY,KPixmapSquare.iTl.iX + KPixmapSquare.Width(),KPixmapSquare.iTl.iY + KPixmapSquare.Height()); |
1138 |
1132 |
1139 glClear(GL_COLOR_BUFFER_BIT); |
1133 glClear(GL_COLOR_BUFFER_BIT); |
1140 } |
1134 } |
1141 |
1135 |
1142 EXPORT_C void CTestEglSession::CheckImageDataL(CFbsBitmap* aFbsBitmap) |
1136 EXPORT_C void CTestEglSession::CheckImageDataL(CFbsBitmap* aFbsBitmap) |
1143 { |
1137 { |
1182 switch(aDataFormat) |
1176 switch(aDataFormat) |
1183 { |
1177 { |
1184 case VG_sRGB_565: |
1178 case VG_sRGB_565: |
1185 { |
1179 { |
1186 TUint16 intPixelSample=0; |
1180 TUint16 intPixelSample=0; |
1187 |
1181 |
1188 // Outside the square |
1182 // Outside the square |
1189 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1183 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1190 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse)); |
1184 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse)); |
1191 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1185 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1192 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse)); |
1186 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse)); |
1193 |
1187 |
1194 // Inside the square |
1188 // Inside the square |
1195 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1189 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1196 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse)); |
1190 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse)); |
1197 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1191 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1198 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse)); |
1192 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse)); |
1199 break; |
1193 break; |
1200 } |
1194 } |
1201 case VG_sXRGB_8888: |
1195 case VG_sXRGB_8888: |
1202 { |
1196 { |
1203 TUint32 intPixelSample=0; |
1197 TUint32 intPixelSample=0; |
1204 |
1198 |
1205 // Outside the square |
1199 // Outside the square |
1206 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1200 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1207 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1201 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1208 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1202 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1209 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1203 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1210 |
1204 |
1211 // Inside the square |
1205 // Inside the square |
1212 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1206 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1213 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse)); |
1207 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse)); |
1214 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1208 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1215 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse)); |
1209 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse)); |
1216 break; |
1210 break; |
1217 } |
1211 } |
1218 case VG_sARGB_8888: |
1212 case VG_sARGB_8888: |
1219 { |
1213 { |
1220 TUint32 intPixelSample=0; |
1214 TUint32 intPixelSample=0; |
1221 |
1215 |
1222 // Outside the square |
1216 // Outside the square |
1223 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1217 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1224 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse)); |
1218 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse)); |
1225 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1219 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1226 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse)); |
1220 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse)); |
1227 |
1221 |
1228 // Inside the square |
1222 // Inside the square |
1229 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1223 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1230 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse)); |
1224 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse)); |
1231 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1225 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1232 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse)); |
1226 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse)); |
1245 EXPORT_C void CTestEglSession::CheckImageDataGLesL() |
1239 EXPORT_C void CTestEglSession::CheckImageDataGLesL() |
1246 { |
1240 { |
1247 TUint32 intPixelSample; |
1241 TUint32 intPixelSample; |
1248 glReadPixels(10,10,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1242 glReadPixels(10,10,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1249 SwapChannels(intPixelSample); |
1243 SwapChannels(intPixelSample); |
1250 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1244 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1251 |
1245 |
1252 glReadPixels(45,45,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1246 glReadPixels(45,45,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1253 SwapChannels(intPixelSample); |
1247 SwapChannels(intPixelSample); |
1254 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1248 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1255 |
1249 |
1256 glReadPixels(55,55,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1250 glReadPixels(55,55,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1288 /** |
1282 /** |
1289 Resets the internal surface and context handles without destroying them. |
1283 Resets the internal surface and context handles without destroying them. |
1290 Also closes the internal RSgImage handled that is associated to the surface. |
1284 Also closes the internal RSgImage handled that is associated to the surface. |
1291 |
1285 |
1292 EGL destroys all surface and context handles associated with a display when |
1286 EGL destroys all surface and context handles associated with a display when |
1293 eglTerminate() is called. |
1287 eglTerminate() is called. |
1294 */ |
1288 */ |
1295 EXPORT_C void CTestEglSession::ResetSurfaceAndContextSgImageL() |
1289 EXPORT_C void CTestEglSession::ResetSurfaceAndContextSgImageL() |
1296 { |
1290 { |
1297 INFO_PRINTF1(_L("CTestEglSession::ResetSurfaceAndContextSgImageL()")); |
1291 INFO_PRINTF1(_L("CTestEglSession::ResetSurfaceAndContextSgImageL()")); |
1298 |
1292 |
1299 iContext = EGL_NO_CONTEXT; |
1293 iContext = EGL_NO_CONTEXT; |
1300 iSurface = EGL_NO_SURFACE; |
1294 iSurface = EGL_NO_SURFACE; |
1301 iSgImage.Close(); |
1295 iSgImage.Close(); |
1302 } |
1296 } |
1303 |
1297 |
1304 /** |
1298 /** |
1305 Check that the pixel values match within a predefined tolerance |
1299 Check that the pixel values match within a predefined tolerance |
1306 @param aExpected the expected pixel colour vaule |
1300 @param aExpected the expected pixel colour vaule |
1307 @param aActual the actual pixel colour value |
1301 @param aActual the actual pixel colour value |
1308 @param aCheckAlpha Whether to check the alpha channel value |
1302 @param aCheckAlpha Whether to check the alpha channel value |
1309 @return Whether the pixel values match - within the allowed tolerance |
1303 @return Whether the pixel values match - within the allowed tolerance |
1310 */ |
1304 */ |
1311 EXPORT_C TBool CTestEglSession::PixelsMatch(const TRgb& aExpected, const TRgb& aActual, TBool aCheckAlpha) |
1305 EXPORT_C TBool CTestEglSession::PixelsMatch(const TRgb& aExpected, const TRgb& aActual, TBool aCheckAlpha) |
1312 { |
1306 { |
1313 // This value has been carefully selected. If it is too high it could be hidding genuine pixel value |
1307 // This value has been carefully selected. If it is too high it could be hidding genuine pixel value |
1314 // differences, while too low will be too strict to allow for pixel conversions, i.e. from 16bpp to 32bpp |
1308 // differences, while too low will be too strict to allow for pixel conversions, i.e. from 16bpp to 32bpp |
1315 const TInt KPixelTolerance = 8; |
1309 const TInt KPixelTolerance = 8; |
1316 |
1310 |
1317 if (aCheckAlpha && aExpected.Alpha()== 0 && |
1311 if (aCheckAlpha && aExpected.Alpha()== 0 && |
1318 aActual.Red() == 0 && |
1312 aActual.Red() == 0 && |
1319 aActual.Green() == 0 && |
1313 aActual.Green() == 0 && |
1320 aActual.Blue() == 0 && |
1314 aActual.Blue() == 0 && |
1321 aActual.Alpha() == 0) |
1315 aActual.Alpha() == 0) |
1322 { |
1316 { |
1323 // if the expected value for alpha is 0, all actual values should be 0 |
1317 // if the expected value for alpha is 0, all actual values should be 0 |
1324 return ETrue; |
1318 return ETrue; |
1325 } |
1319 } |
1442 EXPORT_C EGLImageKHR CTestEglSession::eglCreateImageKhrL(EGLDisplay aDisplay,EGLContext aContext,EGLenum aTarget,RSgImage* aSgImage,const EGLint *aAttr_List) |
1436 EXPORT_C EGLImageKHR CTestEglSession::eglCreateImageKhrL(EGLDisplay aDisplay,EGLContext aContext,EGLenum aTarget,RSgImage* aSgImage,const EGLint *aAttr_List) |
1443 { |
1437 { |
1444 TBool bSuccess = FetchProcEglCreateImageKhr(); |
1438 TBool bSuccess = FetchProcEglCreateImageKhr(); |
1445 ASSERT_TRUE(bSuccess); |
1439 ASSERT_TRUE(bSuccess); |
1446 VERBOSE_INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR"), iThreadIdx); |
1440 VERBOSE_INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR"), iThreadIdx); |
1447 EGLImageKHR eglImage = ipfnEglCreateImageKHR(aDisplay,aContext,aTarget,reinterpret_cast<EGLClientBuffer>(aSgImage),const_cast<EGLint *>(aAttr_List)); |
1441 EGLImageKHR eglImage = ipfnEglCreateImageKHR(aDisplay,aContext,aTarget,reinterpret_cast<EGLClientBuffer>(aSgImage),const_cast<EGLint *>(aAttr_List)); |
1448 return eglImage; |
1442 return eglImage; |
1449 } |
1443 } |
1450 |
1444 |
1451 EXPORT_C EGLImageKHR CTestEglSession::eglCreateImageKhrL(EGLDisplay aDisplay,EGLContext aContext,EGLenum aTarget,CFbsBitmap &aCFbsBitmap, const EGLint *aAttr_List) |
1445 EXPORT_C EGLImageKHR CTestEglSession::eglCreateImageKhrL(EGLDisplay aDisplay,EGLContext aContext,EGLenum aTarget,CFbsBitmap &aCFbsBitmap, const EGLint *aAttr_List) |
1452 { |
1446 { |
1453 TBool bSuccess = FetchProcEglCreateImageKhr(); |
1447 TBool bSuccess = FetchProcEglCreateImageKhr(); |
1454 ASSERT_TRUE(bSuccess); |
1448 ASSERT_TRUE(bSuccess); |
1455 INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR, with CFBsBitmap)"), iThreadIdx); |
1449 INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR, with CFBsBitmap)"), iThreadIdx); |
1456 //the following call to eglCreateImageKHR MUST fail, error handling is made outside |
1450 //the following call to eglCreateImageKHR MUST fail, error handling is made outside |
1457 EGLImageKHR eglImage = ipfnEglCreateImageKHR(aDisplay,aContext,aTarget,reinterpret_cast<EGLClientBuffer>(&aCFbsBitmap),const_cast<EGLint *>(aAttr_List)); |
1451 EGLImageKHR eglImage = ipfnEglCreateImageKHR(aDisplay,aContext,aTarget,reinterpret_cast<EGLClientBuffer>(&aCFbsBitmap),const_cast<EGLint *>(aAttr_List)); |
1458 return eglImage; |
1452 return eglImage; |
1459 } |
1453 } |
1460 |
1454 |
1461 EXPORT_C TBool CTestEglSession::FetchProcEglDestroyImageKhr() |
1455 EXPORT_C TBool CTestEglSession::FetchProcEglDestroyImageKhr() |
1462 { |
1456 { |
1512 EGLint EGL_GREEN_SIZE_value; |
1506 EGLint EGL_GREEN_SIZE_value; |
1513 EGLint EGL_RED_SIZE_value; |
1507 EGLint EGL_RED_SIZE_value; |
1514 EGLint EGL_SURFACE_TYPE_value; |
1508 EGLint EGL_SURFACE_TYPE_value; |
1515 EGLint EGL_RENDERABLE_TYPE_value; |
1509 EGLint EGL_RENDERABLE_TYPE_value; |
1516 EGLint EGL_CONFIG_ID_value; |
1510 EGLint EGL_CONFIG_ID_value; |
1517 |
1511 |
1518 eglGetConfigAttrib(iDisplay, aConfig, EGL_CONFIG_ID, &EGL_CONFIG_ID_value); |
1512 eglGetConfigAttrib(iDisplay, aConfig, EGL_CONFIG_ID, &EGL_CONFIG_ID_value); |
1519 eglGetConfigAttrib(iDisplay, aConfig, EGL_BUFFER_SIZE, &EGL_BUFFER_SIZE_value); |
1513 eglGetConfigAttrib(iDisplay, aConfig, EGL_BUFFER_SIZE, &EGL_BUFFER_SIZE_value); |
1520 eglGetConfigAttrib(iDisplay, aConfig, EGL_ALPHA_SIZE, &EGL_ALPHA_SIZE_value); |
1514 eglGetConfigAttrib(iDisplay, aConfig, EGL_ALPHA_SIZE, &EGL_ALPHA_SIZE_value); |
1521 eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &EGL_BLUE_SIZE_value); |
1515 eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &EGL_BLUE_SIZE_value); |
1522 eglGetConfigAttrib(iDisplay, aConfig, EGL_GREEN_SIZE, &EGL_GREEN_SIZE_value); |
1516 eglGetConfigAttrib(iDisplay, aConfig, EGL_GREEN_SIZE, &EGL_GREEN_SIZE_value); |
1523 eglGetConfigAttrib(iDisplay, aConfig, EGL_RED_SIZE, &EGL_RED_SIZE_value); |
1517 eglGetConfigAttrib(iDisplay, aConfig, EGL_RED_SIZE, &EGL_RED_SIZE_value); |
1524 eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &EGL_SURFACE_TYPE_value); |
1518 eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &EGL_SURFACE_TYPE_value); |
1525 eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value); |
1519 eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value); |
1526 #ifdef PRINTG_CONFIGS_LOG |
1520 #ifdef PRINTG_CONFIGS_LOG |
1527 INFO_PRINTF7(_L("(Config: %3d) RGBA=(%2d) %2d,%2d,%2d,%2d"), EGL_CONFIG_ID_value, EGL_BUFFER_SIZE_value, |
1521 INFO_PRINTF7(_L("(Config: %3d) RGBA=(%2d) %2d,%2d,%2d,%2d"), EGL_CONFIG_ID_value, EGL_BUFFER_SIZE_value, |
1528 EGL_RED_SIZE_value, EGL_GREEN_SIZE_value, EGL_BLUE_SIZE_value, |
1522 EGL_RED_SIZE_value, EGL_GREEN_SIZE_value, EGL_BLUE_SIZE_value, |
1529 EGL_ALPHA_SIZE_value); |
1523 EGL_ALPHA_SIZE_value); |
1530 INFO_PRINTF2(_L("RENDERABLE_TYPE %d"),EGL_RENDERABLE_TYPE_value); |
1524 INFO_PRINTF2(_L("RENDERABLE_TYPE %d"),EGL_RENDERABLE_TYPE_value); |
1531 #endif |
1525 #endif |
1532 |
1526 |
1533 if(!(EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT)) |
1527 if(!(EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT)) |
1534 { |
1528 { |
1535 return EFalse; |
1529 return EFalse; |
1536 } |
1530 } |
1537 |
1531 |
1538 TBool good = ETrue; |
1532 TBool good = ETrue; |
1539 //requested usage bits |
1533 //requested usage bits |
1540 TSgImageInfo requestedImageInfo; |
1534 TSgImageInfo requestedImageInfo; |
1541 aImage.GetInfo(requestedImageInfo); |
1535 aImage.GetInfo(requestedImageInfo); |
1542 |
1536 |
1543 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
1537 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
1544 //potential usage bits |
1538 //potential usage bits |
1545 RSgImage potential; |
1539 RSgImage potential; |
1546 potential.Open(aImage.Id(),ESgDoNotRestrictUsage); |
1540 potential.Open(aImage.Id(),ESgDoNotRestrictUsage); |
1547 TSgImageInfo potentialImageInfo; |
1541 TSgImageInfo potentialImageInfo; |
1548 potential.GetInfo(potentialImageInfo); |
1542 potential.GetInfo(potentialImageInfo); |
1549 potential.Close(); |
1543 potential.Close(); |
1550 #endif |
1544 #endif |
1551 |
1545 |
1552 switch(requestedImageInfo.iPixelFormat) |
1546 switch(requestedImageInfo.iPixelFormat) |
1553 { |
1547 { |
1554 case EUidPixelFormatRGB_565: |
1548 case EUidPixelFormatRGB_565: |
1555 if (!(EGL_RED_SIZE_value == 5 && EGL_GREEN_SIZE_value == 6 && EGL_BLUE_SIZE_value == 5 && EGL_ALPHA_SIZE_value == 0)) |
1549 if (!(EGL_RED_SIZE_value == 5 && EGL_GREEN_SIZE_value == 6 && EGL_BLUE_SIZE_value == 5 && EGL_ALPHA_SIZE_value == 0)) |
1556 { |
1550 { |
1557 good = EFalse; |
1551 good = EFalse; |
1558 } |
1552 } |
1559 break; |
1553 break; |
1560 case EUidPixelFormatXRGB_8888: |
1554 case EUidPixelFormatXRGB_8888: |
1561 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 0)) |
1555 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 0)) |
1562 { |
1556 { |
1563 good = EFalse; |
1557 good = EFalse; |
1564 } |
1558 } |
1565 break; |
1559 break; |
1566 case EUidPixelFormatARGB_8888_PRE: |
1560 case EUidPixelFormatARGB_8888_PRE: |
1567 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 8)) |
1561 if (!(EGL_RED_SIZE_value == 8 && EGL_GREEN_SIZE_value == 8 && EGL_BLUE_SIZE_value == 8 && EGL_ALPHA_SIZE_value == 8)) |
1568 { |
1562 { |
1569 good = EFalse; |
1563 good = EFalse; |
1570 } |
1564 } |
1921 TInt width = aReferenceBitmap->SizeInPixels().iWidth; |
1915 TInt width = aReferenceBitmap->SizeInPixels().iWidth; |
1922 |
1916 |
1923 switch(aDataFormat) |
1917 switch(aDataFormat) |
1924 { |
1918 { |
1925 case VG_sRGB_565: |
1919 case VG_sRGB_565: |
1926 { |
1920 { |
1927 TUint16* vgPixel = new(ELeave) TUint16[width]; |
1921 TUint16* vgPixel = new(ELeave) TUint16[width]; |
1928 CleanupArrayDeletePushL(vgPixel); |
1922 CleanupArrayDeletePushL(vgPixel); |
1929 for (TInt y=0; y < height; y++) |
1923 for (TInt y=0; y < height; y++) |
1930 { |
1924 { |
1931 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1925 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1932 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1926 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1933 |
1927 |
1934 for (TInt x=0; x < width; x++) |
1928 for (TInt x=0; x < width; x++) |
1935 { |
1929 { |
1936 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1930 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1937 if(!PixelsMatch(refPixel, TRgb::Color64K(vgPixel[x]), EFalse)) |
1931 if(!PixelsMatch(refPixel, TRgb::Color64K(vgPixel[x]), EFalse)) |
1938 { |
1932 { |
1939 User::Leave(KErrTEFUnitFail); |
1933 User::Leave(KErrTEFUnitFail); |
1940 } |
1934 } |
1941 } |
1935 } |
1942 } |
1936 } |
1943 CleanupStack::PopAndDestroy(vgPixel); |
1937 CleanupStack::PopAndDestroy(vgPixel); |
1944 break; |
1938 break; |
1945 } |
1939 } |
1946 |
1940 |
1947 case VG_sXRGB_8888: |
1941 case VG_sXRGB_8888: |
1948 { |
1942 { |
1949 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1943 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1950 CleanupArrayDeletePushL(vgPixel); |
1944 CleanupArrayDeletePushL(vgPixel); |
1951 for (TInt y=0; y < height; y++) |
1945 for (TInt y=0; y < height; y++) |
1952 { |
1946 { |
1953 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1947 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1954 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1948 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1955 |
1949 |
1956 for (TInt x=0; x < width; x++) |
1950 for (TInt x=0; x < width; x++) |
1957 { |
1951 { |
1958 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1952 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1959 if(!PixelsMatch(refPixel, TRgb::Color16MU(vgPixel[x]), EFalse)) |
1953 if(!PixelsMatch(refPixel, TRgb::Color16MU(vgPixel[x]), EFalse)) |
1960 { |
1954 { |
1961 User::Leave(KErrTEFUnitFail); |
1955 User::Leave(KErrTEFUnitFail); |
1962 } |
1956 } |
1963 } |
1957 } |
1964 } |
1958 } |
1965 CleanupStack::PopAndDestroy(vgPixel); |
1959 CleanupStack::PopAndDestroy(vgPixel); |
1966 break; |
1960 break; |
1967 } |
1961 } |
1968 |
1962 |
1969 case VG_sARGB_8888: |
1963 case VG_sARGB_8888: |
1970 { |
1964 { |
1971 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1965 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1972 CleanupArrayDeletePushL(vgPixel); |
1966 CleanupArrayDeletePushL(vgPixel); |
1973 for (TInt y=0; y < height; y++) |
1967 for (TInt y=0; y < height; y++) |
1974 { |
1968 { |
1975 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1969 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1976 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1970 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1977 |
1971 |
1978 for (TInt x=0; x < width; x++) |
1972 for (TInt x=0; x < width; x++) |
1979 { |
1973 { |
1980 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1974 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1981 if(!PixelsMatch(refPixel, TRgb::Color16MA(vgPixel[x]), ETrue)) |
1975 if(!PixelsMatch(refPixel, TRgb::Color16MA(vgPixel[x]), ETrue)) |
1982 { |
1976 { |
1983 User::Leave(KErrTEFUnitFail); |
1977 User::Leave(KErrTEFUnitFail); |
1984 } |
1978 } |
1985 } |
1979 } |
1986 } |
1980 } |
1987 CleanupStack::PopAndDestroy(vgPixel); |
1981 CleanupStack::PopAndDestroy(vgPixel); |
1988 break; |
1982 break; |
1989 } |
1983 } |
1990 |
1984 |
1991 case VG_sARGB_8888_PRE: |
1985 case VG_sARGB_8888_PRE: |
1992 { |
1986 { |
1993 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1987 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1994 CleanupArrayDeletePushL(vgPixel); |
1988 CleanupArrayDeletePushL(vgPixel); |
1995 for (TInt y=0; y < height; y++) |
1989 for (TInt y=0; y < height; y++) |
1996 { |
1990 { |
1997 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1991 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1998 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1992 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1999 |
1993 |
2000 for (TInt x=0; x < width; x++) |
1994 for (TInt x=0; x < width; x++) |
2001 { |
1995 { |
2002 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1996 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
2003 if(!PixelsMatch(refPixel, TRgb::Color16MAP(vgPixel[x]), ETrue)) |
1997 if(!PixelsMatch(refPixel, TRgb::Color16MAP(vgPixel[x]), ETrue)) |
2004 { |
1998 { |
2005 User::Leave(KErrTEFUnitFail); |
1999 User::Leave(KErrTEFUnitFail); |
2006 } |
2000 } |
2007 } |
2001 } |
2008 } |
2002 } |
2009 CleanupStack::PopAndDestroy(vgPixel); |
2003 CleanupStack::PopAndDestroy(vgPixel); |
2010 break; |
2004 break; |
2011 } |
2005 } |
2012 |
2006 |
2013 default: |
2007 default: |
2014 // We should not get here - colour mode not supported by these tests |
2008 // We should not get here - colour mode not supported by these tests |
2015 ERR_PRINTF1(_L("CTestEglSession::CheckVgDrawingL - Colour mode not supported!")); |
2009 ERR_PRINTF1(_L("CTestEglSession::CheckVgDrawingL - Colour mode not supported!")); |
2016 ASSERT(FALSE); |
2010 ASSERT(FALSE); |
2017 break; |
2011 break; |
2018 } |
2012 } |
2019 } |
2013 } |
2020 |
2014 |
2021 EXPORT_C TBool CTestEglSession::IsOpenGLESSupported() |
2015 EXPORT_C TBool CTestEglSession::IsOpenGLESSupported() |
2022 { |
2016 { |
2023 if(!iIsSupportedRenderInitialized) |
2017 if(!iIsSupportedRenderInitialized) |
2024 { |
2018 { |
2025 CheckAllAvailableRenders(); |
2019 CheckAllAvailableRenders(); |
2026 } |
2020 } |
2027 return iIsOpenGLESSupported; |
2021 return iIsOpenGLESSupported; |
2028 } |
2022 } |
2029 |
2023 |
2030 EXPORT_C TBool CTestEglSession::IsOpenGLES2Supported() |
2024 EXPORT_C TBool CTestEglSession::IsOpenGLES2Supported() |
2031 { |
2025 { |
2032 if(!iIsSupportedRenderInitialized) |
2026 if(!iIsSupportedRenderInitialized) |
2033 { |
2027 { |
2034 CheckAllAvailableRenders(); |
2028 CheckAllAvailableRenders(); |
2035 } |
2029 } |
2036 return iIsOpenGLES2Supported; |
2030 return iIsOpenGLES2Supported; |
2037 } |
2031 } |
2038 EXPORT_C TBool CTestEglSession::IsOpenVGSupported() |
2032 EXPORT_C TBool CTestEglSession::IsOpenVGSupported() |
2039 { |
2033 { |
2040 if(!iIsSupportedRenderInitialized) |
2034 if(!iIsSupportedRenderInitialized) |
2041 { |
2035 { |
2042 CheckAllAvailableRenders(); |
2036 CheckAllAvailableRenders(); |
2043 } |
2037 } |