egl/egltest/src/egltestcommonsession.cpp
branchRCL_3
changeset 164 25ffed67c7ef
parent 163 bbf46f59e123
equal deleted inserted replaced
163:bbf46f59e123 164:25ffed67c7ef
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   449 		INFO_PRINTF2(_L("\n*********************************\n\n"), index);
   449 		INFO_PRINTF2(_L("\n*********************************\n\n"), index);
   450 #endif
   450 #endif
   451 		}
   451 		}
   452 	}
   452 	}
   453 
   453 
   454 LOCAL_C TEglConfigMatchType GetMatchType(EGLint aAttrib, TEglConfigMatchRule aMatchRule)
   454 EXPORT_C static TEglConfigMatchType GetMatchType(EGLint aAttrib, TEglConfigMatchRule aMatchRule)
   455 	{
   455 	{
   456 	const TConfigMatchRuleItem* curMatchRuleItem = KConfigMatchRules[aMatchRule];
   456 	const TConfigMatchRuleItem* curMatchRuleItem = KConfigMatchRules[aMatchRule];
   457 
   457 
   458 	while(curMatchRuleItem->iAttrib != EGL_NONE)
   458 	while(curMatchRuleItem->iAttrib != EGL_NONE)
   459 		{
   459 		{
   777 	CleanupSurfaceSgImageL();
   777 	CleanupSurfaceSgImageL();
   778 	CloseSgDriver();
   778 	CloseSgDriver();
   779 	return ETrue;
   779 	return ETrue;
   780 	}
   780 	}
   781 
   781 
   782 EXPORT_C void CTestEglSession::CreateWindowSurfaceAndMakeCurrentL(EGLConfig aConfig, RWindow& aWindow, TBool aVgAlphaFormatPre, EGLenum aBindAPI, TInt aRenderVersionNumber, EGLint* aAttribList)
   782 EXPORT_C void CTestEglSession::CreateWindowSurfaceAndMakeCurrentL(EGLConfig aConfig, RWindow& aWindow, TBool aVgAlphaFormatPre, EGLenum aBindAPI, TInt aRenderVersionNumber)
   783 	{
   783 	{
   784 	ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
   784 	ASSERT_EQUALS(iSurface, EGL_NO_SURFACE);
   785 	ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
   785 	ASSERT_EQUALS(iContext, EGL_NO_CONTEXT);
   786 
   786 
   787 	ASSERT_EGL_TRUE(eglBindAPI(aBindAPI));
   787 	ASSERT_EGL_TRUE(eglBindAPI(aBindAPI));
   788 
   788 
   789 	// Create a Window surface from the native image
   789 	// Create a Window surface from the native image
   790 	const EGLint* windowAttribs = aAttribList;
   790 	const EGLint* windowAttribs = (aVgAlphaFormatPre && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
   791     if(!windowAttribs)
       
   792         {
       
   793         windowAttribs = (aVgAlphaFormatPre && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
       
   794         }
       
   795 	iSurface = eglCreateWindowSurface(iDisplay, aConfig, &aWindow, windowAttribs);
   791 	iSurface = eglCreateWindowSurface(iDisplay, aConfig, &aWindow, windowAttribs);
   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));
   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));
  1051 	const EGLint* pixmapAttribs = (aDisplayMode == EColor16MAP && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
  1047 	const EGLint* pixmapAttribs = (aDisplayMode == EColor16MAP && aBindAPI == EGL_OPENVG_API) ? KPixmapAttribsVgAlphaFormatPre : KPixmapAttribsNone;
  1052 	iSurface = eglCreatePixmapSurface(iDisplay, config, iFbsBitmap, pixmapAttribs);
  1048 	iSurface = eglCreatePixmapSurface(iDisplay, config, iFbsBitmap, pixmapAttribs);
  1053 	ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
  1049 	ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
  1054 
  1050 
  1055 	// 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
  1056 	const EGLint KAttribsListCtxNone[] = { EGL_NONE };
  1052 	const EGLint KAttribsListCtxNone[] = { EGL_NONE };;
  1057 	const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
  1053 	const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
  1058 	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;
  1059 	iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx);
  1055 	iContext = eglCreateContext(iDisplay, config, EGL_NO_CONTEXT, attrib_list_ctx);
  1060 	ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
  1056 	ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
  1061 	ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
  1057 	ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
  1082 			EGL_NONE };
  1078 			EGL_NONE };
  1083 	iSurface = eglCreatePbufferSurface(iDisplay, aConfig, KPbufferAttribs);
  1079 	iSurface = eglCreatePbufferSurface(iDisplay, aConfig, KPbufferAttribs);
  1084 	ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
  1080 	ASSERT_EGL_TRUE(iSurface != EGL_NO_SURFACE);
  1085 
  1081 
  1086 	// 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
  1087 	const EGLint KAttribsListCtxNone[] = { EGL_NONE };
  1083 	const EGLint KAttribsListCtxNone[] = { EGL_NONE };;
  1088 	const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
  1084 	const EGLint KAttribsListCtxGles2[] = { EGL_CONTEXT_CLIENT_VERSION, aRenderVersionNumber, EGL_NONE };
  1089 	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;
  1090 	iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx);
  1086 	iContext = eglCreateContext(iDisplay, aConfig, EGL_NO_CONTEXT, attrib_list_ctx);
  1091 	ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
  1087 	ASSERT_EGL_TRUE(iContext != EGL_NO_CONTEXT);
  1092 	ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
  1088 	ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
  1718 			{
  1714 			{
  1719 			// The extension is not supported
  1715 			// The extension is not supported
  1720 			return EFalse;
  1716 			return EFalse;
  1721 			}
  1717 			}
  1722 		}
  1718 		}
  1723     if(aExtension & KEGL_NOK__private__signal_sync || extensionName.Compare(KEglNokPrivateSignalSync)==0)
  1719     if(aExtension & KEGL_NOK__private__signal_sync)
  1724         {
  1720         {
  1725         TBool bFoundExtensionEGL_NOK__private__signal_sync = FindExtensionStringL(EIsEGL,KEglNokPrivateSignalSync);
  1721         TBool bFoundExtensionEGL_NOK__private__signal_sync = FindExtensionStringL(EIsEGL,KEglNokPrivateSignalSync);
  1726         if (!bFoundExtensionEGL_NOK__private__signal_sync)
  1722         if (!bFoundExtensionEGL_NOK__private__signal_sync)
  1727             {
  1723             {
  1728             // The extension is not supported
  1724             // The extension is not supported
  1729             return EFalse;
  1725             return EFalse;
  1730             }
  1726             }
  1731         }
  1727         }
  1732     if(aExtension & KEGL_NOKIA_swap_buffers || extensionName.Compare(KEglNokiaSwapBuffers)==0)
  1728     if(aExtension & KEGL_NOKIA_swap_buffers)
  1733         {
  1729         {
  1734         TBool bFoundExtensionEGL_NOKIA_swap_buffer = FindExtensionStringL(EIsEGL,KEglNokiaSwapBuffers);
  1730         TBool bFoundExtensionEGL_NOKIA_swap_buffer = FindExtensionStringL(EIsEGL,KEglNokiaSwapBuffers);
  1735         if (!bFoundExtensionEGL_NOKIA_swap_buffer)
  1731         if (!bFoundExtensionEGL_NOKIA_swap_buffer)
  1736             {
  1732             {
  1737             // The extension is not supported
  1733             // The extension is not supported
  1738             return EFalse;
  1734             return EFalse;
  1739             }
  1735             }
  1740         }
  1736         }
  1741 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
  1737 #ifndef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
  1742     if(aExtension & KEGL_SYMBIAN_image_preserved || extensionName.Compare(KEglSymbianImagePreserved)
  1738     if(aExtension & KEGL_SYMBIAN_image_preserved)
  1743         {
  1739         {
  1744         TBool bFoundExtensionEGL_SYMBIAN_image_preserved = FindExtensionStringL(EIsEGL,KEglSymbianImagePreserved);
  1740         TBool bFoundExtensionEGL_SYMBIAN_image_preserved = FindExtensionStringL(EIsEGL,KEglSymbianImagePreserved);
  1745         if (!bFoundExtensionEGL_SYMBIAN_image_preserved)
  1741         if (!bFoundExtensionEGL_SYMBIAN_image_preserved)
  1746             {
  1742             {
  1747             // The extension is not supported
  1743             // The extension is not supported
  1748             return EFalse;
  1744             return EFalse;
  1749             }
  1745             }
  1750         }
  1746         }
  1751 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
  1747 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
  1752     if(aExtension & KEGL_NOK_image_endpoint || extensionName.Compare(KEglNokiaImageEndpoint)==0)
  1748 
  1753         {
       
  1754         TBool bFoundExtensionEGL_NOK_image_endpoint = FindExtensionStringL(EIsEGL,KEglNokiaImageEndpoint);
       
  1755         if (!bFoundExtensionEGL_NOK_image_endpoint)
       
  1756             {
       
  1757             // The extension is not supported
       
  1758             return EFalse;
       
  1759             }
       
  1760         }
       
  1761     if(aExtension & KEGL_NOK_surface_scaling || extensionName.Compare(KEglNokiaSurfaceScaling)==0)
       
  1762         {
       
  1763         TBool bFoundExtensionEGL_NOK_surface_scaling = FindExtensionStringL(EIsEGL,KEglNokiaSurfaceScaling);
       
  1764         if (!bFoundExtensionEGL_NOK_surface_scaling)
       
  1765             {
       
  1766             // The extension is not supported
       
  1767             return EFalse;
       
  1768             }
       
  1769         }
       
  1770 	return ETrue;
  1749 	return ETrue;
  1771 	}
  1750 	}
  1772 
  1751 
  1773 EXPORT_C CFbsBitmap* CTestEglSession::CreateReferenceBitmapL(TDisplayMode aMode)
  1752 EXPORT_C CFbsBitmap* CTestEglSession::CreateReferenceBitmapL(TDisplayMode aMode)
  1774 	{
  1753 	{
  1859 	TInt alpha=255;
  1838 	TInt alpha=255;
  1860 
  1839 
  1861 	TBitmapUtil bmpUtil(bitmap);
  1840 	TBitmapUtil bmpUtil(bitmap);
  1862 	bmpUtil.Begin(TPoint(0,0));
  1841 	bmpUtil.Begin(TPoint(0,0));
  1863 	for (TInt colIndex = 0; colIndex < width; ++colIndex)
  1842 	for (TInt colIndex = 0; colIndex < width; ++colIndex)
       
  1843 
  1864 		{
  1844 		{
  1865 		bmpUtil.SetPos(TPoint(colIndex, 0));
  1845 		bmpUtil.SetPos(TPoint(colIndex, 0));
  1866 		for (TInt rowIndex =0; rowIndex < height; ++rowIndex)
  1846 		for (TInt rowIndex =0; rowIndex < height; ++rowIndex)
  1867 			{
  1847 			{
  1868 			TRgb rgb(red, green, blue, alpha);
  1848 			TRgb rgb(red, green, blue, alpha);