80 ret = eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
80 ret = eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
81 if(ret == EGL_FALSE) |
81 if(ret == EGL_FALSE) |
82 { |
82 { |
83 WARN_PRINTF3(_L("thread %d: eglMakeCurrent returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError()); |
83 WARN_PRINTF3(_L("thread %d: eglMakeCurrent returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError()); |
84 } |
84 } |
85 |
85 |
86 // Warn because this should be done by the test, rather than relying on the d'tor |
86 // Warn because this should be done by the test, rather than relying on the d'tor |
87 // which may not leave if there is an error (so no CHECK_EXPECTED_ERROR) |
87 // which may not leave if there is an error (so no CHECK_EXPECTED_ERROR) |
88 WARN_PRINTF2(_L("thread %d: Calling eglDestroyContext() from ~CTestEglSession..."), iThreadIdx); |
88 WARN_PRINTF2(_L("thread %d: Calling eglDestroyContext() from ~CTestEglSession..."), iThreadIdx); |
89 ret = eglDestroyContext(iDisplay, iContext); |
89 ret = eglDestroyContext(iDisplay, iContext); |
90 if(ret == EGL_FALSE) |
90 if(ret == EGL_FALSE) |
91 { |
91 { |
92 WARN_PRINTF3(_L("thread %d: eglDestroyContext returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError()); |
92 WARN_PRINTF3(_L("thread %d: eglDestroyContext returned error = %x ~CTestEglSession..."), iThreadIdx, eglGetError()); |
93 } |
93 } |
94 } |
94 } |
95 |
95 |
96 if (iSurface != EGL_NO_SURFACE) |
96 if (iSurface != EGL_NO_SURFACE) |
97 { |
97 { |
98 // Warn because this should be done by the test, rather than relying on the d'tor |
98 // Warn because this should be done by the test, rather than relying on the d'tor |
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 // The created surface will remain un-used, hence we create it with an arbitrary pixel format |
203 EGLConfig currentConfig = GetConfigExactMatchL(EPBufferAttribsColor64K); |
204 EGLConfig currentConfig = GetConfigExactMatchL(EPBufferAttribsColor64K); |
204 CreatePbufferSurfaceAndMakeCurrentL(currentConfig, TSize(1,1), EGL_OPENVG_API); |
205 CreatePbufferSurfaceAndMakeCurrentL(currentConfig, TSize(1,1), EGL_OPENVG_API); |
205 |
206 |
206 extensionsString = (const char*) vgGetString(VG_EXTENSIONS); |
207 extensionsString = (const char*) vgGetString(VG_EXTENSIONS); |
207 |
208 |
372 #endif |
377 #endif |
373 eglGetConfigAttrib(iDisplay, configs[index], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value); |
378 eglGetConfigAttrib(iDisplay, configs[index], EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value); |
374 |
379 |
375 TBool good = ETrue; |
380 TBool good = ETrue; |
376 |
381 |
377 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, |
378 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, |
379 EGL_ALPHA_SIZE_value); |
384 EGL_ALPHA_SIZE_value); |
380 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)) |
381 { |
386 { |
382 continue; |
387 continue; |
383 } |
388 } |
384 |
389 |
385 INFO_PRINTF2(_L("\n\n^^^^^^ CONFIG [%d] VALUES ******"), index); |
390 INFO_PRINTF2(_L("\n\n^^^^^^ CONFIG [%d] VALUES ******"), index); |
386 if (EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT) |
391 if (EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT) |
387 { |
392 { |
388 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); |
389 } |
394 } |
390 else |
395 else |
391 { |
396 { |
392 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); |
393 good = EFalse; |
398 good = EFalse; |
394 } |
399 } |
395 |
400 |
396 if (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT) |
401 if (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT) |
397 { |
402 { |
398 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); |
399 } |
404 } |
400 else |
405 else |
401 { |
406 { |
402 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); |
403 good = EFalse; |
408 good = EFalse; |
404 } |
409 } |
405 |
410 |
406 if (good) |
411 if (good) |
407 { |
412 { |
408 INFO_PRINTF1(_L("^^^^^^^ GOOD ^^^^^^^")); |
413 INFO_PRINTF1(_L("^^^^^^^ GOOD ^^^^^^^")); |
409 } |
414 } |
410 |
415 |
552 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &blueSize)); |
557 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &blueSize)); |
553 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_COLOR_BUFFER_TYPE, &colorBufferType)); |
558 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_COLOR_BUFFER_TYPE, &colorBufferType)); |
554 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &surfaceType)); |
559 CHECK_EXPECTED_ERROR(eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &surfaceType)); |
555 |
560 |
556 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); |
557 |
562 |
558 for(TUint i=0; i<ConfigToPixelFormatTableLength(); i++) |
563 for(TUint i=0; i<ConfigToPixelFormatTableLength(); i++) |
559 { |
564 { |
560 if ((ConfigToPixelFormatTable(i).iBufferSize == bufferSize) |
565 if ((ConfigToPixelFormatTable(i).iBufferSize == bufferSize) |
561 && (ConfigToPixelFormatTable(i).iAlphaSize == alphaSize) |
566 && (ConfigToPixelFormatTable(i).iAlphaSize == alphaSize) |
562 && (ConfigToPixelFormatTable(i).iRedSize == redSize) |
567 && (ConfigToPixelFormatTable(i).iRedSize == redSize) |
623 if(aConfigAttribIndex >= EEglTestConfigMax ) |
628 if(aConfigAttribIndex >= EEglTestConfigMax ) |
624 { |
629 { |
625 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")); |
626 User::Leave(KErrArgument); |
631 User::Leave(KErrArgument); |
627 } |
632 } |
628 |
633 |
629 EGLConfig configs[KMaxEglConfigs]; |
634 EGLConfig configs[KMaxEglConfigs]; |
630 EGLint numConfigs=0; |
635 EGLint numConfigs=0; |
631 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[aConfigAttribIndex], configs, KMaxEglConfigs, &numConfigs)); |
636 ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KConfigAttribs[aConfigAttribIndex], configs, KMaxEglConfigs, &numConfigs)); |
632 if (numConfigs <= 0) |
637 if (numConfigs <= 0) |
633 { |
638 { |
634 // 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) |
635 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!")); |
636 User::Leave(KTestNoMatchingConfig); |
641 User::Leave(KTestNoMatchingConfig); |
637 } |
642 } |
638 |
643 |
639 // Check that any of the configs returned matches the desired attributes |
644 // Check that any of the configs returned matches the desired attributes |
640 TInt match = GetFullMatchConfigIndex(iDisplay, configs, numConfigs, KConfigAttribs[aConfigAttribIndex], aMatchRule); |
645 TInt match = GetFullMatchConfigIndex(iDisplay, configs, numConfigs, KConfigAttribs[aConfigAttribIndex], aMatchRule); |
641 if (match == KErrNotFound) |
646 if (match == KErrNotFound) |
642 { |
647 { |
643 // 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) |
711 imageInfo.iUserAttributes = NULL; |
716 imageInfo.iUserAttributes = NULL; |
712 imageInfo.iUserAttributeCount=0; |
717 imageInfo.iUserAttributeCount=0; |
713 #endif |
718 #endif |
714 CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, EResourceCloseSgImageLate); |
719 CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo, EResourceCloseSgImageLate); |
715 DrawOpenVgL(); |
720 DrawOpenVgL(); |
716 |
721 |
717 // Wait for the drawing to complete |
722 // Wait for the drawing to complete |
718 eglWaitClient(); |
723 eglWaitClient(); |
719 |
724 |
720 //we can't retrieve data directly from the SgImage as |
725 //we can't retrieve data directly from the SgImage as |
721 //non-unified architecture doesn't allow readback from the GPU |
726 //non-unified architecture doesn't allow readback from the GPU |
722 CheckImageDataVgL(VG_sXRGB_8888); |
727 CheckImageDataVgL(VG_sXRGB_8888); |
723 CleanupSurfaceSgImageL(); |
728 CleanupSurfaceSgImageL(); |
724 CloseSgDriver(); |
729 CloseSgDriver(); |
725 } |
730 } |
726 |
731 |
727 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) |
728 { |
733 { |
729 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule ,EGL_OPENGL_ES_API, aRenderVersion); |
734 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule ,EGL_OPENGL_ES_API, aRenderVersion); |
730 |
735 |
731 DrawOpenGLesL(); |
736 DrawOpenGLesL(); |
732 |
737 |
733 // Wait for the drawing to complete |
738 // Wait for the drawing to complete |
734 eglWaitClient(); |
739 eglWaitClient(); |
735 |
740 |
736 //we can't retrieve data directly from SgImage as non-unified |
741 //we can't retrieve data directly from SgImage as non-unified |
737 //architecture doesn't allow readback from the GPU |
742 //architecture doesn't allow readback from the GPU |
738 |
743 |
739 if (aImageInfo.iPixelFormat == EUidPixelFormatXRGB_8888 || |
744 if (aImageInfo.iPixelFormat == EUidPixelFormatXRGB_8888 || |
740 aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) |
745 aImageInfo.iPixelFormat == EUidPixelFormatARGB_8888_PRE) |
741 { |
746 { |
742 CheckImageDataGLesL(); |
747 CheckImageDataGLesL(); |
743 } |
748 } |
744 |
749 |
745 CleanupSurfaceSgImageL(); |
750 CleanupSurfaceSgImageL(); |
746 CloseSgDriver(); |
751 CloseSgDriver(); |
758 @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 |
759 */ |
764 */ |
760 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) |
761 { |
766 { |
762 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule); |
767 CreatePixmapSurfaceAndMakeCurrentL(aConfig, aImageInfo, aResourceCloseRule); |
763 |
768 |
764 DrawOpenVgL(); |
769 DrawOpenVgL(); |
765 |
770 |
766 // Wait for the drawing to complete |
771 // Wait for the drawing to complete |
767 eglWaitClient(); |
772 eglWaitClient(); |
768 |
773 |
769 //we can't retrieve data directly from the SgImage as |
774 //we can't retrieve data directly from the SgImage as |
770 //non-unified architecture doesn't allow readback from the GPU |
775 //non-unified architecture doesn't allow readback from the GPU |
771 CheckImageDataVgL(VG_sXRGB_8888); |
776 CheckImageDataVgL(VG_sXRGB_8888); |
772 CleanupSurfaceSgImageL(); |
777 CleanupSurfaceSgImageL(); |
773 CloseSgDriver(); |
778 CloseSgDriver(); |
774 return ETrue; |
779 return ETrue; |
775 } |
780 } |
776 |
781 |
777 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) |
778 { |
783 { |
779 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
784 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
780 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
785 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
781 |
786 |
782 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
787 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
783 |
788 |
784 // Create a Window surface from the native image |
789 // Create a Window surface from the native image |
785 EGLint EGL_RENDERABLE_TYPE_value = 0; |
790 const EGLint* windowAttribs = (aVgAlphaFormatPre && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
786 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
791 iSurface = eglCreateWindowSurface(iDisplay, aConfig, &aWindow, windowAttribs); |
787 const EGLint* pixmapAttribs = ((aWindow.DisplayMode() == EColor16MAP) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
|
788 iSurface = eglCreateWindowSurface(iDisplay, aConfig, &aWindow, pixmapAttribs); |
|
789 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
792 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
790 |
793 |
791 // 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 |
792 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
795 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
793 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
796 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
794 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; |
795 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
798 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
796 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
799 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
797 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
800 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
798 } |
801 } |
799 |
802 |
800 |
803 |
801 EXPORT_C TBool CTestEglSession::CongfigSupportsOpenVgL(EGLConfig aConfig) |
804 EXPORT_C TBool CTestEglSession::CongfigSupportsOpenVgL(EGLConfig aConfig) |
856 EGLint EGL_RENDERABLE_TYPE_value = 0; |
859 EGLint EGL_RENDERABLE_TYPE_value = 0; |
857 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)); |
858 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; |
859 iSurface = eglCreatePixmapSurface(iDisplay, config, &iSgImage, pixmapAttribs); |
862 iSurface = eglCreatePixmapSurface(iDisplay, config, &iSgImage, pixmapAttribs); |
860 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
863 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
861 |
864 |
862 if (aResourceCloseRule == EResourceCloseSgImageEarly) |
865 if (aResourceCloseRule == EResourceCloseSgImageEarly) |
863 { |
866 { |
864 // 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 |
865 // 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. |
866 iSgImage.Close(); |
869 iSgImage.Close(); |
867 } |
870 } |
868 |
871 |
869 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly) |
872 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly) |
870 { |
873 { |
871 // 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 |
872 // 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 |
873 // been closed. |
876 // been closed. |
874 iSgImage.Close(); |
877 iSgImage.Close(); |
875 CloseSgDriver(); |
878 CloseSgDriver(); |
876 } |
879 } |
877 |
880 |
878 // 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 |
879 const EGLint KAttribsListCtxNone[] = { EGL_NONE }; |
882 const EGLint KAttribsListCtxNone[] = { EGL_NONE }; |
880 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
883 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
883 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
886 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
884 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
887 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
885 } |
888 } |
886 |
889 |
887 /** |
890 /** |
888 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. |
889 It then makes it current to the thread. |
892 It then makes it current to the thread. |
890 @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 |
891 @param aImageInfo Used to create the RSgImage pixmap |
894 @param aImageInfo Used to create the RSgImage pixmap |
892 @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 |
893 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 |
894 - e.g at the same time as destroying the surface. |
897 - e.g at the same time as destroying the surface. |
895 @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 |
896 */ |
899 */ |
897 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) |
898 { |
901 { |
899 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
902 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
900 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
903 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
901 |
904 |
902 OpenSgDriverL(); |
905 OpenSgDriverL(); |
903 ASSERT_EQUALS(iSgImage.Create(aImageInfo, NULL, 0), KErrNone); |
906 ASSERT_EQUALS(iSgImage.Create(aImageInfo, NULL, 0), KErrNone); |
904 |
907 |
905 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
908 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
906 |
909 |
907 // Create a pixmap surface from the native image |
910 // Create a pixmap surface from the native image |
908 EGLint EGL_RENDERABLE_TYPE_value = 0; |
911 EGLint EGL_RENDERABLE_TYPE_value = 0; |
909 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)); |
910 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; |
911 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, &iSgImage, pixmapAttribs); |
914 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, &iSgImage, pixmapAttribs); |
912 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
915 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
913 |
916 |
914 if (aResourceCloseRule == EResourceCloseSgImageEarly) |
917 if (aResourceCloseRule == EResourceCloseSgImageEarly) |
915 { |
918 { |
916 // 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 |
917 // 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. |
918 iSgImage.Close(); |
921 iSgImage.Close(); |
919 } |
922 } |
920 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly) |
923 if (aResourceCloseRule == EResourceCloseSgDriverAndImageEarly) |
921 { |
924 { |
922 // 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 |
923 // 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 |
924 // been closed. |
927 // been closed. |
925 iSgImage.Close(); |
928 iSgImage.Close(); |
926 CloseSgDriver(); |
929 CloseSgDriver(); |
927 } |
930 } |
928 |
931 |
929 // 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 |
930 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
933 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
931 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
934 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
932 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; |
933 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
936 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
934 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
937 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
935 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
938 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
936 } |
939 } |
937 |
940 |
938 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) |
939 { |
942 { |
940 //Fist try with CreateHardwareBitmap to check whether we are on hardware |
943 //Fist try with CreateHardwareBitmap to check whether we are on hardware |
941 TInt result = aFbsBitmap->CreateHardwareBitmap(aSize, aDisplayMode, KUidEglTestServer); |
944 TInt result = aFbsBitmap->CreateHardwareBitmap(aSize, aDisplayMode, KUidEglTestServer); |
942 |
945 |
943 if(result == KErrNotSupported) |
946 if(result == KErrNotSupported) |
944 { |
947 { |
945 //we are not on hardware |
948 //we are not on hardware |
946 result = aFbsBitmap->Create(aSize, aDisplayMode); |
949 result = aFbsBitmap->Create(aSize, aDisplayMode); |
947 } |
950 } |
976 { |
979 { |
977 ERR_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentL - Unkown API requested!")); |
980 ERR_PRINTF1(_L("CreatePixmapSurfaceAndMakeCurrentL - Unkown API requested!")); |
978 User::Leave(KErrArgument); |
981 User::Leave(KErrArgument); |
979 } |
982 } |
980 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
983 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
981 |
984 |
982 // Create a pixmap surface from the native image |
985 // Create a pixmap surface from the native image |
983 EGLint EGL_RENDERABLE_TYPE_value = 0; |
986 EGLint EGL_RENDERABLE_TYPE_value = 0; |
984 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)); |
985 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; |
986 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, iFbsBitmap, pixmapAttribs); |
989 iSurface = eglCreatePixmapSurface(iDisplay, aConfig, iFbsBitmap, pixmapAttribs); |
987 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
990 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
988 |
991 |
989 // 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 |
990 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list); |
993 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list); |
991 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
994 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
992 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
995 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
993 } |
996 } |
994 |
997 |
995 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) |
996 { |
999 { |
997 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1000 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
998 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1001 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
999 |
1002 |
1000 OpenFbsSessionL(); |
1003 OpenFbsSessionL(); |
1001 iFbsBitmap = new(ELeave)CFbsBitmap; |
1004 iFbsBitmap = new(ELeave)CFbsBitmap; |
1002 ASSERT_EQUALS(CreateBitmap(iFbsBitmap, aSize, displayMode), KErrNone); |
1005 ASSERT_EQUALS(CreateBitmap(iFbsBitmap, aSize, aDisplayMode), KErrNone); |
1003 |
1006 |
1004 EGLint renderableType = 0; |
1007 EGLint renderableType = 0; |
1005 if(aBindAPI == EGL_OPENVG_API) |
1008 if(aBindAPI == EGL_OPENVG_API) |
1006 { |
1009 { |
1007 renderableType = EGL_OPENVG_BIT; |
1010 renderableType = EGL_OPENVG_BIT; |
1039 // 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 |
1040 User::Leave(KTestNoMatchingConfig); |
1043 User::Leave(KTestNoMatchingConfig); |
1041 } |
1044 } |
1042 |
1045 |
1043 // Create a pixmap surface from the native image |
1046 // Create a pixmap surface from the native image |
1044 EGLint EGL_RENDERABLE_TYPE_value = 0; |
1047 const EGLint* pixmapAttribs = (aDisplayMode == EColor16MAP && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
1045 ASSERT_EGL_TRUE(eglGetConfigAttrib(iDisplay, config, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value)); |
|
1046 const EGLint* pixmapAttribs = ((displayMode == EColor16MAP) && (EGL_RENDERABLE_TYPE_value & EGL_OPENVG_BIT)) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone; |
|
1047 iSurface = eglCreatePixmapSurface(iDisplay, config, iFbsBitmap, pixmapAttribs); |
1048 iSurface = eglCreatePixmapSurface(iDisplay, config, iFbsBitmap, pixmapAttribs); |
1048 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
1049 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
1049 |
1050 |
1050 // 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 |
1051 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
1052 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
1052 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
1053 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
1053 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; |
1054 iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx); |
1055 iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx); |
1055 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
1056 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
1056 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1057 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1057 } |
1058 } |
1058 |
1059 |
1059 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) |
1060 { |
1061 { |
1061 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1062 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1062 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1063 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1063 |
1064 |
1064 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1065 ASSERT_EQUALS(iSurface, EGL_NO_SURFACE); |
1065 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1066 ASSERT_EQUALS(iContext, EGL_NO_CONTEXT); |
1066 |
1067 |
1067 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
1068 ASSERT_EGL_TRUE(eglBindAPI(aBindAPI)); |
1068 |
1069 |
1069 // PBuffer attribs options are: |
1070 // PBuffer attribs options are: |
1070 // EGL_WIDTH, EGL_HEIGHT, EGL_LARGEST_PBUFFER, |
1071 // EGL_WIDTH, EGL_HEIGHT, EGL_LARGEST_PBUFFER, |
1071 // EGL_TEXTURE_FORMAT, EGL_TEXTURE_TARGET, EGL_MIPMAP_TEXTURE, |
1072 // EGL_TEXTURE_FORMAT, EGL_TEXTURE_TARGET, EGL_MIPMAP_TEXTURE, |
1072 // EGL_VG_COLORSPACE, and EGL_VG_ALPHA_FORMAT |
1073 // EGL_VG_COLORSPACE, and EGL_VG_ALPHA_FORMAT |
1073 // Create a pbuffer surface of the given size |
1074 // Create a pbuffer surface of the given size |
1074 const EGLint KPbufferAttribs[] = { |
1075 const EGLint KPbufferAttribs[] = { |
1075 EGL_WIDTH, aSize.iWidth, |
1076 EGL_WIDTH, aSize.iWidth, |
1076 EGL_HEIGHT, aSize.iHeight, |
1077 EGL_HEIGHT, aSize.iHeight, |
1077 EGL_NONE }; |
1078 EGL_NONE }; |
1078 iSurface = eglCreatePbufferSurface(iDisplay, aConfig, KPbufferAttribs); |
1079 iSurface = eglCreatePbufferSurface(iDisplay, aConfig, KPbufferAttribs); |
1079 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
1080 ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE); |
1080 |
1081 |
1081 // 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 |
1082 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
1083 const EGLint KAttribsListCtxNone[] = { EGL_NONE };; |
1083 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
1084 const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE }; |
1084 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; |
1085 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
1086 iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx); |
1086 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
1087 ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT); |
1087 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1088 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext)); |
1088 } |
1089 } |
1089 |
1090 |
1090 EXPORT_C void CTestEglSession::DrawOpenVgL() |
1091 EXPORT_C void CTestEglSession::DrawOpenVgL() |
1091 { |
1092 { |
1092 ASSERT_TRUE(iSurface != EGL_NO_SURFACE); |
1093 ASSERT_TRUE(iSurface != EGL_NO_SURFACE); |
1093 ASSERT_TRUE(iContext != EGL_NO_CONTEXT); |
1094 ASSERT_TRUE(iContext != EGL_NO_CONTEXT); |
1094 |
1095 |
1095 // Draw to the pixmap surface |
1096 // Draw to the pixmap surface |
1096 // Clear it: redish |
1097 // Clear it: redish |
1097 VGfloat colorBackground[4]; |
1098 VGfloat colorBackground[4]; |
1098 ConvertColor(KRgbReddish, colorBackground); |
1099 ConvertColor(KRgbReddish, colorBackground); |
1099 vgSetfv(VG_CLEAR_COLOR, 4, colorBackground); |
1100 vgSetfv(VG_CLEAR_COLOR, 4, colorBackground); |
1100 vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); |
1101 vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); |
1101 |
1102 |
1102 // And add a square: greenish |
1103 // And add a square: greenish |
1103 VGfloat colorSquare[4]; |
1104 VGfloat colorSquare[4]; |
1104 ConvertColor(KRgbGreenish, colorSquare); |
1105 ConvertColor(KRgbGreenish, colorSquare); |
1105 vgSetfv(VG_CLEAR_COLOR, 4, colorSquare); |
1106 vgSetfv(VG_CLEAR_COLOR, 4, colorSquare); |
1106 vgClear(KPixmapSquare.iTl.iX, KPixmapSquare.iTl.iX, KPixmapSquare.Width(), KPixmapSquare.Height()); |
1107 vgClear(KPixmapSquare.iTl.iX, KPixmapSquare.iTl.iX, KPixmapSquare.Width(), KPixmapSquare.Height()); |
1117 const GLfloat glAlpha = KRgbReddish.Alpha(); |
1118 const GLfloat glAlpha = KRgbReddish.Alpha(); |
1118 const GLfloat glRedBits = 255.f; |
1119 const GLfloat glRedBits = 255.f; |
1119 const GLfloat glGreenBits = 255.f; |
1120 const GLfloat glGreenBits = 255.f; |
1120 const GLfloat glBlueBits = 255.f; |
1121 const GLfloat glBlueBits = 255.f; |
1121 const GLfloat glAlphaBits = 255.f; |
1122 const GLfloat glAlphaBits = 255.f; |
1122 |
1123 |
1123 // Disable cdither - when using exact comparison to reference bitmap |
1124 // Disable cdither - when using exact comparison to reference bitmap |
1124 // because reference bitmap cannot be created to match dither exactly |
1125 // because reference bitmap cannot be created to match dither exactly |
1125 glDisable(GL_DITHER); |
1126 glDisable(GL_DITHER); |
1126 // Clear the surface to the colour specified |
1127 // Clear the surface to the colour specified |
1127 glClearColor((glRed)/glRedBits, (glGreen)/glGreenBits, (glBlue)/glBlueBits, glAlpha/glAlphaBits); |
1128 glClearColor((glRed)/glRedBits, (glGreen)/glGreenBits, (glBlue)/glBlueBits, glAlpha/glAlphaBits); |
1128 |
1129 |
1129 //glColor3f(KRgbGreenish.Red(),KRgbGreenish.Green(),KRgbGreenish.Blue()); |
1130 //glColor3f(KRgbGreenish.Red(),KRgbGreenish.Green(),KRgbGreenish.Blue()); |
1130 //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()); |
1131 |
1132 |
1132 glClear(GL_COLOR_BUFFER_BIT); |
1133 glClear(GL_COLOR_BUFFER_BIT); |
1133 } |
1134 } |
1134 |
1135 |
1135 EXPORT_C void CTestEglSession::CheckImageDataL(CFbsBitmap* aFbsBitmap) |
1136 EXPORT_C void CTestEglSession::CheckImageDataL(CFbsBitmap* aFbsBitmap) |
1136 { |
1137 { |
1139 // Outside the square |
1140 // Outside the square |
1140 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(10,10)); |
1141 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(10,10)); |
1141 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1142 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1142 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(90,90)); |
1143 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(90,90)); |
1143 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1144 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1144 |
1145 |
1145 // Inside the square |
1146 // Inside the square |
1146 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(30,30)); |
1147 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(30,30)); |
1147 ASSERT_TRUE(PixelsMatch(KRgbGreenish, rgbPixelSample, EFalse)); |
1148 ASSERT_TRUE(PixelsMatch(KRgbGreenish, rgbPixelSample, EFalse)); |
1148 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(70,70)); |
1149 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(70,70)); |
1149 ASSERT_TRUE(PixelsMatch(KRgbGreenish, rgbPixelSample, EFalse)); |
1150 ASSERT_TRUE(PixelsMatch(KRgbGreenish, rgbPixelSample, EFalse)); |
1156 // Outside the square |
1157 // Outside the square |
1157 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(10,10)); |
1158 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(10,10)); |
1158 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1159 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1159 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(90,90)); |
1160 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(90,90)); |
1160 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1161 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1161 |
1162 |
1162 // Inside the square |
1163 // Inside the square |
1163 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(30,30)); |
1164 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(30,30)); |
1164 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1165 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1165 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(70,70)); |
1166 aFbsBitmap->GetPixel(rgbPixelSample, TPoint(70,70)); |
1166 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1167 ASSERT_TRUE(PixelsMatch(KRgbReddish, rgbPixelSample, EFalse)); |
1175 switch(aDataFormat) |
1176 switch(aDataFormat) |
1176 { |
1177 { |
1177 case VG_sRGB_565: |
1178 case VG_sRGB_565: |
1178 { |
1179 { |
1179 TUint16 intPixelSample=0; |
1180 TUint16 intPixelSample=0; |
1180 |
1181 |
1181 // Outside the square |
1182 // Outside the square |
1182 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1183 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1183 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse)); |
1184 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse)); |
1184 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1185 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1185 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse)); |
1186 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color64K(intPixelSample), EFalse)); |
1186 |
1187 |
1187 // Inside the square |
1188 // Inside the square |
1188 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1189 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1189 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse)); |
1190 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse)); |
1190 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1191 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1191 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse)); |
1192 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color64K(intPixelSample), EFalse)); |
1192 break; |
1193 break; |
1193 } |
1194 } |
1194 case VG_sXRGB_8888: |
1195 case VG_sXRGB_8888: |
1195 { |
1196 { |
1196 TUint32 intPixelSample=0; |
1197 TUint32 intPixelSample=0; |
1197 |
1198 |
1198 // Outside the square |
1199 // Outside the square |
1199 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1200 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1200 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1201 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1201 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1202 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1202 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1203 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1203 |
1204 |
1204 // Inside the square |
1205 // Inside the square |
1205 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1206 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1206 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse)); |
1207 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse)); |
1207 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1208 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1208 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse)); |
1209 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MU(intPixelSample), EFalse)); |
1209 break; |
1210 break; |
1210 } |
1211 } |
1211 case VG_sARGB_8888: |
1212 case VG_sARGB_8888: |
1212 { |
1213 { |
1213 TUint32 intPixelSample=0; |
1214 TUint32 intPixelSample=0; |
1214 |
1215 |
1215 // Outside the square |
1216 // Outside the square |
1216 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1217 vgReadPixels(&intPixelSample, 1, aDataFormat, 10,10, 1,1); |
1217 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse)); |
1218 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse)); |
1218 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1219 vgReadPixels(&intPixelSample, 1, aDataFormat, 90,90, 1,1); |
1219 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse)); |
1220 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MA(intPixelSample), EFalse)); |
1220 |
1221 |
1221 // Inside the square |
1222 // Inside the square |
1222 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1223 vgReadPixels(&intPixelSample, 1, aDataFormat, 30,30, 1,1); |
1223 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse)); |
1224 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse)); |
1224 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1225 vgReadPixels(&intPixelSample, 1, aDataFormat, 70,70, 1,1); |
1225 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse)); |
1226 ASSERT_TRUE(PixelsMatch(KRgbGreenish, TRgb::Color16MA(intPixelSample), EFalse)); |
1238 EXPORT_C void CTestEglSession::CheckImageDataGLesL() |
1239 EXPORT_C void CTestEglSession::CheckImageDataGLesL() |
1239 { |
1240 { |
1240 TUint32 intPixelSample; |
1241 TUint32 intPixelSample; |
1241 glReadPixels(10,10,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1242 glReadPixels(10,10,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1242 SwapChannels(intPixelSample); |
1243 SwapChannels(intPixelSample); |
1243 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1244 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1244 |
1245 |
1245 glReadPixels(45,45,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1246 glReadPixels(45,45,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1246 SwapChannels(intPixelSample); |
1247 SwapChannels(intPixelSample); |
1247 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1248 ASSERT_TRUE(PixelsMatch(KRgbReddish, TRgb::Color16MU(intPixelSample), EFalse)); |
1248 |
1249 |
1249 glReadPixels(55,55,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1250 glReadPixels(55,55,1,1,GL_RGBA,GL_UNSIGNED_BYTE ,&intPixelSample); |
1281 /** |
1282 /** |
1282 Resets the internal surface and context handles without destroying them. |
1283 Resets the internal surface and context handles without destroying them. |
1283 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. |
1284 |
1285 |
1285 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 |
1286 eglTerminate() is called. |
1287 eglTerminate() is called. |
1287 */ |
1288 */ |
1288 EXPORT_C void CTestEglSession::ResetSurfaceAndContextSgImageL() |
1289 EXPORT_C void CTestEglSession::ResetSurfaceAndContextSgImageL() |
1289 { |
1290 { |
1290 INFO_PRINTF1(_L("CTestEglSession::ResetSurfaceAndContextSgImageL()")); |
1291 INFO_PRINTF1(_L("CTestEglSession::ResetSurfaceAndContextSgImageL()")); |
1291 |
1292 |
1292 iContext = EGL_NO_CONTEXT; |
1293 iContext = EGL_NO_CONTEXT; |
1293 iSurface = EGL_NO_SURFACE; |
1294 iSurface = EGL_NO_SURFACE; |
1294 iSgImage.Close(); |
1295 iSgImage.Close(); |
1295 } |
1296 } |
1296 |
1297 |
1297 /** |
1298 /** |
1298 Check that the pixel values match within a predefined tolerance |
1299 Check that the pixel values match within a predefined tolerance |
1299 @param aExpected the expected pixel colour vaule |
1300 @param aExpected the expected pixel colour vaule |
1300 @param aActual the actual pixel colour value |
1301 @param aActual the actual pixel colour value |
1301 @param aCheckAlpha Whether to check the alpha channel value |
1302 @param aCheckAlpha Whether to check the alpha channel value |
1302 @return Whether the pixel values match - within the allowed tolerance |
1303 @return Whether the pixel values match - within the allowed tolerance |
1303 */ |
1304 */ |
1304 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) |
1305 { |
1306 { |
1306 // 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 |
1307 // 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 |
1308 const TInt KPixelTolerance = 8; |
1309 const TInt KPixelTolerance = 8; |
1309 |
1310 |
1310 if (aCheckAlpha && aExpected.Alpha()== 0 && |
1311 if (aCheckAlpha && aExpected.Alpha()== 0 && |
1311 aActual.Red() == 0 && |
1312 aActual.Red() == 0 && |
1312 aActual.Green() == 0 && |
1313 aActual.Green() == 0 && |
1313 aActual.Blue() == 0 && |
1314 aActual.Blue() == 0 && |
1314 aActual.Alpha() == 0) |
1315 aActual.Alpha() == 0) |
1315 { |
1316 { |
1316 // 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 |
1317 return ETrue; |
1318 return ETrue; |
1318 } |
1319 } |
1435 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) |
1436 { |
1437 { |
1437 TBool bSuccess = FetchProcEglCreateImageKhr(); |
1438 TBool bSuccess = FetchProcEglCreateImageKhr(); |
1438 ASSERT_TRUE(bSuccess); |
1439 ASSERT_TRUE(bSuccess); |
1439 VERBOSE_INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR"), iThreadIdx); |
1440 VERBOSE_INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR"), iThreadIdx); |
1440 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)); |
1441 return eglImage; |
1442 return eglImage; |
1442 } |
1443 } |
1443 |
1444 |
1444 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) |
1445 { |
1446 { |
1446 TBool bSuccess = FetchProcEglCreateImageKhr(); |
1447 TBool bSuccess = FetchProcEglCreateImageKhr(); |
1447 ASSERT_TRUE(bSuccess); |
1448 ASSERT_TRUE(bSuccess); |
1448 INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR, with CFBsBitmap)"), iThreadIdx); |
1449 INFO_PRINTF2(_L("thread %d: Calling eglCreateImageKHR, with CFBsBitmap)"), iThreadIdx); |
1449 //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 |
1450 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)); |
1451 return eglImage; |
1452 return eglImage; |
1452 } |
1453 } |
1453 |
1454 |
1454 EXPORT_C TBool CTestEglSession::FetchProcEglDestroyImageKhr() |
1455 EXPORT_C TBool CTestEglSession::FetchProcEglDestroyImageKhr() |
1455 { |
1456 { |
1505 EGLint EGL_GREEN_SIZE_value; |
1506 EGLint EGL_GREEN_SIZE_value; |
1506 EGLint EGL_RED_SIZE_value; |
1507 EGLint EGL_RED_SIZE_value; |
1507 EGLint EGL_SURFACE_TYPE_value; |
1508 EGLint EGL_SURFACE_TYPE_value; |
1508 EGLint EGL_RENDERABLE_TYPE_value; |
1509 EGLint EGL_RENDERABLE_TYPE_value; |
1509 EGLint EGL_CONFIG_ID_value; |
1510 EGLint EGL_CONFIG_ID_value; |
1510 |
1511 |
1511 eglGetConfigAttrib(iDisplay, aConfig, EGL_CONFIG_ID, &EGL_CONFIG_ID_value); |
1512 eglGetConfigAttrib(iDisplay, aConfig, EGL_CONFIG_ID, &EGL_CONFIG_ID_value); |
1512 eglGetConfigAttrib(iDisplay, aConfig, EGL_BUFFER_SIZE, &EGL_BUFFER_SIZE_value); |
1513 eglGetConfigAttrib(iDisplay, aConfig, EGL_BUFFER_SIZE, &EGL_BUFFER_SIZE_value); |
1513 eglGetConfigAttrib(iDisplay, aConfig, EGL_ALPHA_SIZE, &EGL_ALPHA_SIZE_value); |
1514 eglGetConfigAttrib(iDisplay, aConfig, EGL_ALPHA_SIZE, &EGL_ALPHA_SIZE_value); |
1514 eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &EGL_BLUE_SIZE_value); |
1515 eglGetConfigAttrib(iDisplay, aConfig, EGL_BLUE_SIZE, &EGL_BLUE_SIZE_value); |
1515 eglGetConfigAttrib(iDisplay, aConfig, EGL_GREEN_SIZE, &EGL_GREEN_SIZE_value); |
1516 eglGetConfigAttrib(iDisplay, aConfig, EGL_GREEN_SIZE, &EGL_GREEN_SIZE_value); |
1516 eglGetConfigAttrib(iDisplay, aConfig, EGL_RED_SIZE, &EGL_RED_SIZE_value); |
1517 eglGetConfigAttrib(iDisplay, aConfig, EGL_RED_SIZE, &EGL_RED_SIZE_value); |
1517 eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &EGL_SURFACE_TYPE_value); |
1518 eglGetConfigAttrib(iDisplay, aConfig, EGL_SURFACE_TYPE, &EGL_SURFACE_TYPE_value); |
1518 eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value); |
1519 eglGetConfigAttrib(iDisplay, aConfig, EGL_RENDERABLE_TYPE, &EGL_RENDERABLE_TYPE_value); |
1519 #ifdef PRINTG_CONFIGS_LOG |
1520 #ifdef PRINTG_CONFIGS_LOG |
1520 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, |
1521 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, |
1522 EGL_ALPHA_SIZE_value); |
1523 EGL_ALPHA_SIZE_value); |
1523 INFO_PRINTF2(_L("RENDERABLE_TYPE %d"),EGL_RENDERABLE_TYPE_value); |
1524 INFO_PRINTF2(_L("RENDERABLE_TYPE %d"),EGL_RENDERABLE_TYPE_value); |
1524 #endif |
1525 #endif |
1525 |
1526 |
1526 if(!(EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT)) |
1527 if(!(EGL_SURFACE_TYPE_value & EGL_PIXMAP_BIT)) |
1527 { |
1528 { |
1528 return EFalse; |
1529 return EFalse; |
1529 } |
1530 } |
1530 |
1531 |
1531 TBool good = ETrue; |
1532 TBool good = ETrue; |
1532 //requested usage bits |
1533 //requested usage bits |
1533 TSgImageInfo requestedImageInfo; |
1534 TSgImageInfo requestedImageInfo; |
1534 aImage.GetInfo(requestedImageInfo); |
1535 aImage.GetInfo(requestedImageInfo); |
1535 |
1536 |
1536 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
1537 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
1537 //potential usage bits |
1538 //potential usage bits |
1538 RSgImage potential; |
1539 RSgImage potential; |
1539 potential.Open(aImage.Id(),ESgDoNotRestrictUsage); |
1540 potential.Open(aImage.Id(),ESgDoNotRestrictUsage); |
1540 TSgImageInfo potentialImageInfo; |
1541 TSgImageInfo potentialImageInfo; |
1541 potential.GetInfo(potentialImageInfo); |
1542 potential.GetInfo(potentialImageInfo); |
1542 potential.Close(); |
1543 potential.Close(); |
1543 #endif |
1544 #endif |
1544 |
1545 |
1545 switch(requestedImageInfo.iPixelFormat) |
1546 switch(requestedImageInfo.iPixelFormat) |
1546 { |
1547 { |
1547 case EUidPixelFormatRGB_565: |
1548 case EUidPixelFormatRGB_565: |
1548 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)) |
1549 { |
1550 { |
1550 good = EFalse; |
1551 good = EFalse; |
1551 } |
1552 } |
1552 break; |
1553 break; |
1553 case EUidPixelFormatXRGB_8888: |
1554 case EUidPixelFormatXRGB_8888: |
1554 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)) |
1555 { |
1556 { |
1556 good = EFalse; |
1557 good = EFalse; |
1557 } |
1558 } |
1558 break; |
1559 break; |
1559 case EUidPixelFormatARGB_8888_PRE: |
1560 case EUidPixelFormatARGB_8888_PRE: |
1560 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)) |
1561 { |
1562 { |
1562 good = EFalse; |
1563 good = EFalse; |
1563 } |
1564 } |
1914 TInt width = aReferenceBitmap->SizeInPixels().iWidth; |
1915 TInt width = aReferenceBitmap->SizeInPixels().iWidth; |
1915 |
1916 |
1916 switch(aDataFormat) |
1917 switch(aDataFormat) |
1917 { |
1918 { |
1918 case VG_sRGB_565: |
1919 case VG_sRGB_565: |
1919 { |
1920 { |
1920 TUint16* vgPixel = new(ELeave) TUint16[width]; |
1921 TUint16* vgPixel = new(ELeave) TUint16[width]; |
1921 CleanupArrayDeletePushL(vgPixel); |
1922 CleanupArrayDeletePushL(vgPixel); |
1922 for (TInt y=0; y < height; y++) |
1923 for (TInt y=0; y < height; y++) |
1923 { |
1924 { |
1924 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1925 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1925 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1926 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1926 |
1927 |
1927 for (TInt x=0; x < width; x++) |
1928 for (TInt x=0; x < width; x++) |
1928 { |
1929 { |
1929 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1930 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1930 if(!PixelsMatch(refPixel, TRgb::Color64K(vgPixel[x]), EFalse)) |
1931 if(!PixelsMatch(refPixel, TRgb::Color64K(vgPixel[x]), EFalse)) |
1931 { |
1932 { |
1932 User::Leave(KErrTEFUnitFail); |
1933 User::Leave(KErrTEFUnitFail); |
1933 } |
1934 } |
1934 } |
1935 } |
1935 } |
1936 } |
1936 CleanupStack::PopAndDestroy(vgPixel); |
1937 CleanupStack::PopAndDestroy(vgPixel); |
1937 break; |
1938 break; |
1938 } |
1939 } |
1939 |
1940 |
1940 case VG_sXRGB_8888: |
1941 case VG_sXRGB_8888: |
1941 { |
1942 { |
1942 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1943 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1943 CleanupArrayDeletePushL(vgPixel); |
1944 CleanupArrayDeletePushL(vgPixel); |
1944 for (TInt y=0; y < height; y++) |
1945 for (TInt y=0; y < height; y++) |
1945 { |
1946 { |
1946 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1947 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1947 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1948 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1948 |
1949 |
1949 for (TInt x=0; x < width; x++) |
1950 for (TInt x=0; x < width; x++) |
1950 { |
1951 { |
1951 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1952 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1952 if(!PixelsMatch(refPixel, TRgb::Color16MU(vgPixel[x]), EFalse)) |
1953 if(!PixelsMatch(refPixel, TRgb::Color16MU(vgPixel[x]), EFalse)) |
1953 { |
1954 { |
1954 User::Leave(KErrTEFUnitFail); |
1955 User::Leave(KErrTEFUnitFail); |
1955 } |
1956 } |
1956 } |
1957 } |
1957 } |
1958 } |
1958 CleanupStack::PopAndDestroy(vgPixel); |
1959 CleanupStack::PopAndDestroy(vgPixel); |
1959 break; |
1960 break; |
1960 } |
1961 } |
1961 |
1962 |
1962 case VG_sARGB_8888: |
1963 case VG_sARGB_8888: |
1963 { |
1964 { |
1964 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1965 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1965 CleanupArrayDeletePushL(vgPixel); |
1966 CleanupArrayDeletePushL(vgPixel); |
1966 for (TInt y=0; y < height; y++) |
1967 for (TInt y=0; y < height; y++) |
1967 { |
1968 { |
1968 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1969 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1969 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1970 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1970 |
1971 |
1971 for (TInt x=0; x < width; x++) |
1972 for (TInt x=0; x < width; x++) |
1972 { |
1973 { |
1973 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1974 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1974 if(!PixelsMatch(refPixel, TRgb::Color16MA(vgPixel[x]), ETrue)) |
1975 if(!PixelsMatch(refPixel, TRgb::Color16MA(vgPixel[x]), ETrue)) |
1975 { |
1976 { |
1976 User::Leave(KErrTEFUnitFail); |
1977 User::Leave(KErrTEFUnitFail); |
1977 } |
1978 } |
1978 } |
1979 } |
1979 } |
1980 } |
1980 CleanupStack::PopAndDestroy(vgPixel); |
1981 CleanupStack::PopAndDestroy(vgPixel); |
1981 break; |
1982 break; |
1982 } |
1983 } |
1983 |
1984 |
1984 case VG_sARGB_8888_PRE: |
1985 case VG_sARGB_8888_PRE: |
1985 { |
1986 { |
1986 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1987 TUint32* vgPixel = new(ELeave) TUint32[width]; |
1987 CleanupArrayDeletePushL(vgPixel); |
1988 CleanupArrayDeletePushL(vgPixel); |
1988 for (TInt y=0; y < height; y++) |
1989 for (TInt y=0; y < height; y++) |
1989 { |
1990 { |
1990 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1991 // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! |
1991 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1992 vgReadPixels(vgPixel, 1, aDataFormat, 0,height-y-1, width,1); |
1992 |
1993 |
1993 for (TInt x=0; x < width; x++) |
1994 for (TInt x=0; x < width; x++) |
1994 { |
1995 { |
1995 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1996 aReferenceBitmap->GetPixel(refPixel, TPoint(x,y)); |
1996 if(!PixelsMatch(refPixel, TRgb::Color16MAP(vgPixel[x]), ETrue)) |
1997 if(!PixelsMatch(refPixel, TRgb::Color16MAP(vgPixel[x]), ETrue)) |
1997 { |
1998 { |
1998 User::Leave(KErrTEFUnitFail); |
1999 User::Leave(KErrTEFUnitFail); |
1999 } |
2000 } |
2000 } |
2001 } |
2001 } |
2002 } |
2002 CleanupStack::PopAndDestroy(vgPixel); |
2003 CleanupStack::PopAndDestroy(vgPixel); |
2003 break; |
2004 break; |
2004 } |
2005 } |
2005 |
2006 |
2006 default: |
2007 default: |
2007 // 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 |
2008 ERR_PRINTF1(_L("CTestEglSession::CheckVgDrawingL - Colour mode not supported!")); |
2009 ERR_PRINTF1(_L("CTestEglSession::CheckVgDrawingL - Colour mode not supported!")); |
2009 ASSERT(FALSE); |
2010 ASSERT(FALSE); |
2010 break; |
2011 break; |
2011 } |
2012 } |
2012 } |
2013 } |
2013 |
2014 |
2014 EXPORT_C TBool CTestEglSession::IsOpenGLESSupported() |
2015 EXPORT_C TBool CTestEglSession::IsOpenGLESSupported() |
2015 { |
2016 { |
2016 if(!iIsSupportedRenderInitialized) |
2017 if(!iIsSupportedRenderInitialized) |
2017 { |
2018 { |
2018 CheckAllAvailableRenders(); |
2019 CheckAllAvailableRenders(); |
2019 } |
2020 } |
2020 return iIsOpenGLESSupported; |
2021 return iIsOpenGLESSupported; |
2021 } |
2022 } |
2022 |
2023 |
2023 EXPORT_C TBool CTestEglSession::IsOpenGLES2Supported() |
2024 EXPORT_C TBool CTestEglSession::IsOpenGLES2Supported() |
2024 { |
2025 { |
2025 if(!iIsSupportedRenderInitialized) |
2026 if(!iIsSupportedRenderInitialized) |
2026 { |
2027 { |
2027 CheckAllAvailableRenders(); |
2028 CheckAllAvailableRenders(); |
2028 } |
2029 } |
2029 return iIsOpenGLES2Supported; |
2030 return iIsOpenGLES2Supported; |
2030 } |
2031 } |
2031 EXPORT_C TBool CTestEglSession::IsOpenVGSupported() |
2032 EXPORT_C TBool CTestEglSession::IsOpenVGSupported() |
2032 { |
2033 { |
2033 if(!iIsSupportedRenderInitialized) |
2034 if(!iIsSupportedRenderInitialized) |
2034 { |
2035 { |
2035 CheckAllAvailableRenders(); |
2036 CheckAllAvailableRenders(); |
2036 } |
2037 } |