sl@0: // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: */ sl@0: sl@0: #include "egltest_image.h" sl@0: sl@0: #include sl@0: #include // for ASSERT macros sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-EGL-0107 sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMPREQ 39 sl@0: sl@0: @SYMREQ See SGL.GT0386.401 document sl@0: sl@0: @SYMTestCaseDesc sl@0: Tests the use of an EglImageKHR object with OpenVG, using the “EGL_IMAGE_PRESERVED” attribute. sl@0: This means we can draw to the source RSgImage as soon as it is created. sl@0: sl@0: @SYMTestActions sl@0: This test will check for the “VG_KHR_EGL_image” extension, if it is not supported on this platform then the test will return immediately without failure. sl@0: Create a reference Bitmap sl@0: Create and fully construct an RSgImage object having the same content as the reference bitmap sl@0: • Set the iUsage bit to ESgUsageBitOpenVgImage sl@0: Pass the RSgImage object into eglCreateImageKHR() with sl@0: • The target parameter set to EGL_NATIVE_PIXMAP_KHR sl@0: • Use the current display and EGL_NO_CONTEXT sl@0: • Use the “EGL_IMAGE_PRESERVED” attribute sl@0: Check that eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR sl@0: Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface. sl@0: • Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface sl@0: Use vgCreateEGLImageTargetKHR() to construct a VGImage object from the EGLImage. sl@0: • Check for errors sl@0: Use OpenVG to copy the VGImage created from the EGLImage to the new pixmap surface currently linked to the context. sl@0: Call eglWaitClient() to finish the above drawing instructions synchronously. sl@0: Destroy the original image data sl@0: • Pass the VGImage into vgDestroyImage() sl@0: • Pass the EGLImage into eglDestroyImageKHR() sl@0: • Close the RSgImage sl@0: Check that the pixmap contains expected pixel values. sl@0: Destroy the pixmap sl@0: Check for memory and handle leaks sl@0: sl@0: @SYMTestExpectedResults sl@0: eglCreateImageKHR() does NOT return EGL_NO_IMAGE_KHR sl@0: After each call to an OpenVG method, check that vgGetError() returns VG_NO_ERROR sl@0: The pixmap contains expected pixel values after the original image data has been destroyed sl@0: No memory or handle leaks sl@0: */ sl@0: TVerdict CEglTest_EGL_Image_RSgImage_UseOpenVG_PersistImageData::doTestStepL() sl@0: { sl@0: SetTestStepID(_L("GRAPHICS-EGL-0107")); sl@0: INFO_PRINTF1(_L("CEglTest_EGL_Image_RSgImage_UseOpenVG::doTestStepL")); sl@0: sl@0: TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image); sl@0: if(!ret) sl@0: { sl@0: // The extension is not supported sl@0: RecordTestResultL(); sl@0: CloseTMSGraphicsStep(); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // This test is performed for default pixel format sl@0: PrintUsedPixelConfiguration(); sl@0: sl@0: // Create display object sl@0: GetDisplayL(); sl@0: CreateEglSessionL(); sl@0: iEglSess->InitializeL(); sl@0: iEglSess->OpenSgDriverL(); sl@0: sl@0: // Create RSgImage's attributes. sl@0: //This image will become a VGImage. It will be Cleared via vgClear sl@0: TSgImageInfoTest imageInfo = TSgImageInfoTest(iSourceFormat, KPixmapSize); sl@0: #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE sl@0: imageInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; sl@0: #else sl@0: imageInfo.iUsage = ESgUsageOpenVgImage | ESgUsageOpenVgTarget; sl@0: #endif sl@0: INFO_PRINTF1(_L("Creating an RSgImage")); sl@0: RSgImage sgImage; sl@0: CleanupClosePushL(sgImage); sl@0: ret = sgImage.Create(imageInfo, NULL, NULL); sl@0: ASSERT_EQUALS(ret, KErrNone); sl@0: sl@0: INFO_PRINTF1(_L("Calling eglBindAPI(EGL_OPENVG_API)")); sl@0: ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API)); sl@0: sl@0: EGLint numConfigsWithPre = 0; sl@0: EGLConfig configWithPre; sl@0: const EGLint KAttribImagePre[] = { EGL_MATCH_NATIVE_PIXMAP, reinterpret_cast(&sgImage), sl@0: EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT, sl@0: EGL_SURFACE_TYPE, EGL_PIXMAP_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT, sl@0: EGL_NONE }; sl@0: ASSERT_EGL_TRUE(eglChooseConfig(iDisplay, KAttribImagePre, &configWithPre, 1, &numConfigsWithPre)); sl@0: sl@0: // Create a pixmap surface from the native image sl@0: INFO_PRINTF1(_L("Calling eglCreatePixmapSurface")); sl@0: EGLSurface surface = eglCreatePixmapSurface(iDisplay, configWithPre, &sgImage, KPixmapAttribsVgAlphaFormatPre ); sl@0: ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE); sl@0: sl@0: // Create a context for drawing to/reading from the pixmap surface and make it current sl@0: INFO_PRINTF1(_L("Calling eglCreateContext")); sl@0: EGLContext context = eglCreateContext(iDisplay, configWithPre, EGL_NO_CONTEXT, NULL); sl@0: ASSERT_EGL_TRUE(context != EGL_NO_CONTEXT); sl@0: sl@0: INFO_PRINTF1(_L("Calling eglMakeCurrent")); sl@0: ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context)); sl@0: sl@0: //Drawing to the current surface (and hence to the RSgImage) to test that the contents are preserved sl@0: //create a reference bitmap to use the values (we use index=1) sl@0: TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat); sl@0: CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 1); sl@0: CleanupStack::PushL(bitmap); sl@0: // Mind the fact that CFbsBitmap and VGImages use different coordinates origin! sl@0: TSize bitmapSize = bitmap->SizeInPixels(); sl@0: TUint8* address = reinterpret_cast(bitmap->DataAddress()); sl@0: TInt stride = bitmap->DataStride(); sl@0: address += (bitmapSize.iHeight - 1) * stride; sl@0: vgWritePixels(address, -stride, KDefaultSurfaceFormat,0,0, bitmapSize.iWidth, bitmapSize.iHeight); sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: eglWaitClient(); // wait for writing to finish sl@0: ASSERT_EGL_TRUE(eglDestroySurface(iDisplay, surface)); //Destroying Surface handle sl@0: sl@0: INFO_PRINTF1(_L("Create a EGLImage out of the SgImage")); sl@0: EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay,EGL_NO_CONTEXT,EGL_NATIVE_PIXMAP_KHR,&sgImage,KEglImageAttribsPreservedTrue); sl@0: ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR); sl@0: sl@0: INFO_PRINTF1(_L("Create a VGImage out of the EGLImage")); sl@0: VGImage vgImageTarget = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR); sl@0: ASSERT_VG_TRUE(vgImageTarget != VG_INVALID_HANDLE); sl@0: sl@0: //Create an OffScreen Pixmap to be used as an OpenVg target using the same config of the previous RSgImage sl@0: //except for Usage sl@0: imageInfo.iSizeInPixels = KPixmapSize; sl@0: #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE sl@0: imageInfo.iUsage = ESgUsageBitOpenVgSurface; sl@0: #else sl@0: imageInfo.iUsage = ESgUsageOpenVgTarget; sl@0: #endif sl@0: RSgImage sgImageTarget; sl@0: CleanupClosePushL(sgImageTarget); sl@0: ret = sgImageTarget.Create(imageInfo, NULL, NULL); sl@0: ASSERT_EQUALS(ret, KErrNone); sl@0: sl@0: surface = eglCreatePixmapSurface(iDisplay, configWithPre, &sgImageTarget, KPixmapAttribsVgAlphaFormatPre); sl@0: ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE); sl@0: sl@0: INFO_PRINTF1(_L("Calling eglMakeCurrent")); sl@0: ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context)); sl@0: sl@0: //Copy the source VGImage to the surface sl@0: vgSetPixels(0, 0, vgImageTarget, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: eglWaitClient(); sl@0: sl@0: vgDestroyImage(vgImageTarget); //Destroying VGImage handle sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR)); //Destroying EGLImage handle sl@0: sgImage.Close(); //Destroying SgImage and so the actual data sl@0: sl@0: // we can now compare the VgImage to the one we would expect for this particular process sl@0: iEglSess->CheckVgDrawingL(iSurfaceFormat, bitmap); sl@0: sl@0: ASSERT_EGL_TRUE(eglDestroyContext(iDisplay, context)); //Closing eglContext sl@0: ASSERT_EGL_TRUE(eglDestroySurface(iDisplay,surface)); //Destroying Target Surface handle sl@0: sgImageTarget.Close(); //Destroying 2nd RSgImage handle sl@0: sl@0: //cleanup sl@0: CleanupStack::PopAndDestroy(3,&sgImage); // sgImage, bitmap, sgImageTarget sl@0: CleanAll(); sl@0: RecordTestResultL(); sl@0: CloseTMSGraphicsStep(); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-EGL-0108 sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMPREQ 39 sl@0: sl@0: @SYMREQ See SGL.GT0386.401 document sl@0: sl@0: @SYMTestCaseDesc sl@0: Ensure that if there are more than one EGLImage and some of them are destroyed, sl@0: the other images remain workable sl@0: sl@0: @SYMTestActions sl@0: Create a reference Bitmap sl@0: Create and fully construct 4 RSgImage objects having the same content as the reference bitmap sl@0: • Set the iUsage bit to ESgUsageBitOpenVgImage sl@0: Pass the 4 RSgImage objects into eglCreateImageKHR() with sl@0: • The target parameter set to EGL_NATIVE_PIXMAP_KHR sl@0: • Use the current display and EGL_NO_CONTEXT sl@0: • Use a NULL attr_list sl@0: Check that those calls to eglCreateImageKHR() do NOT return EGL_NO_IMAGE_KHR sl@0: Create and make current and EGL context bound to OVG APIs and linked to a pixmap surface. sl@0: • Set the iUsage bit of the underlying RSgImage to ESgUsageBitOpenVgSurface sl@0: Use vgCreateEGLImageTargetKHR() to construct VGImage objects from the just created EGLImages. sl@0: • Check for errors sl@0: Destroy all the RSgImages. sl@0: Pass the 2nd and the 3rd EGLImeges to eglDestroyImageKHR(). sl@0: Call vgDestroyImage on the 2nd VGImage too. sl@0: Use OpenVG to draw the VGImage created from the 4th EGLImage to the new pixmap surface currently linked to the context. sl@0: Call eglWaitClient() to finish the above drawing instructions synchronously. sl@0: Check that the pixmap contains expected pixel values. sl@0: Clear the destination surface to the default background color sl@0: Use OpenVG to draw the VGImage created from the 3rd EGLImage to the new pixmap surface currently linked to the context. sl@0: Call eglWaitClient() to finish the above drawing instructions synchronously. sl@0: Check that the pixmap contains expected pixel values. sl@0: Clear the destination surface to the default background color sl@0: Destroy and restore the 4th VGImage and copy it to the pixmap surface. sl@0: Call eglWaitClient() to finish the above drawing instructions synchronously. sl@0: Check that the pixmap contains expected pixel values. sl@0: Pass all the VGImages left into vgDestroyImage() sl@0: Pass the EGLImage left into eglDestroyImageKHR() sl@0: Destroy the pixmap sl@0: Check for memory and handle leaks sl@0: sl@0: @SYMTestExpectedResults sl@0: Pixmap surface has the expected contents sl@0: No memory or handle leaks sl@0: sl@0: */ sl@0: TVerdict CEglTest_EGL_Image_Consistent_Linked_List::doTestStepL() sl@0: { sl@0: SetTestStepID(_L("GRAPHICS-EGL-0108")); sl@0: INFO_PRINTF1(_L("CEglTest_EGL_Image_Consistent_Linked_List::doTestStepL")); sl@0: sl@0: TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image); sl@0: if(!ret) sl@0: { sl@0: // The extension is not supported sl@0: RecordTestResultL(); sl@0: CloseTMSGraphicsStep(); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // This test is performed for default pixel format sl@0: PrintUsedPixelConfiguration(); sl@0: sl@0: // Create display object sl@0: GetDisplayL(); sl@0: CreateEglSessionL(); sl@0: iEglSess->InitializeL(); sl@0: iEglSess->OpenSgDriverL(); sl@0: sl@0: // Create a reference bitmap which we use to init the SgImage (we use index=6) sl@0: TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat); sl@0: CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 6); sl@0: CleanupStack::PushL(bitmap); sl@0: sl@0: INFO_PRINTF1(_L("Creating 4 RSgImages")); sl@0: TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize); sl@0: RSgImage sgImage1; sl@0: CleanupClosePushL(sgImage1); sl@0: ASSERT_EQUALS(sgImage1.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone); sl@0: RSgImage sgImage2; sl@0: CleanupClosePushL(sgImage2); sl@0: ASSERT_EQUALS(sgImage2.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone); sl@0: RSgImage sgImage3; sl@0: CleanupClosePushL(sgImage3); sl@0: ASSERT_EQUALS(sgImage3.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone); sl@0: RSgImage sgImage4; sl@0: CleanupClosePushL(sgImage4); sl@0: ASSERT_EQUALS(sgImage4.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone); sl@0: sl@0: INFO_PRINTF1(_L("Creating 4 EGLImages")); sl@0: EGLImageKHR imageKHR1 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage1, KEglImageAttribsPreservedTrue); sl@0: ASSERT_EGL_TRUE(imageKHR1 != EGL_NO_IMAGE_KHR); sl@0: EGLImageKHR imageKHR2 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage2, KEglImageAttribsPreservedTrue); sl@0: ASSERT_EGL_TRUE(imageKHR2 != EGL_NO_IMAGE_KHR); sl@0: EGLImageKHR imageKHR3 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage3, KEglImageAttribsPreservedTrue); sl@0: ASSERT_EGL_TRUE(imageKHR3 != EGL_NO_IMAGE_KHR); sl@0: EGLImageKHR imageKHR4 = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage4, KEglImageAttribsPreservedTrue); sl@0: ASSERT_EGL_TRUE(imageKHR4 != EGL_NO_IMAGE_KHR); sl@0: sl@0: //Create a Surface and Link it to a Context bound to OpenVG sl@0: TUidPixelFormat pixelFormat = EglTestConversion::VgFormatToSgPixelFormat(iSurfaceFormat); sl@0: TSgImageInfoOpenVgTarget imageInfo2 = TSgImageInfoOpenVgTarget(pixelFormat, KPixmapSize); sl@0: iEglSess->CreatePixmapSurfaceAndMakeCurrentAndMatchL(imageInfo2, CTestEglSession::EResourceCloseSgImageEarly); sl@0: sl@0: INFO_PRINTF1(_L("Creating 4 VGImages from the four EGLImages")); sl@0: VGImage vgImage1 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR1); sl@0: ASSERT_VG_TRUE(vgImage1 != VG_INVALID_HANDLE); sl@0: VGImage vgImage2 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR2); sl@0: ASSERT_VG_TRUE(vgImage2 != VG_INVALID_HANDLE); sl@0: VGImage vgImage3 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR3); sl@0: ASSERT_VG_TRUE(vgImage3 != VG_INVALID_HANDLE); sl@0: VGImage vgImage4 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR4); sl@0: ASSERT_VG_TRUE(vgImage4 != VG_INVALID_HANDLE); sl@0: sl@0: INFO_PRINTF1(_L("Destroying all RSgImage, the 2nd and the 3rd EGLImage, the 2nd VGImage")); sl@0: CleanupStack::PopAndDestroy(4, &sgImage1); // closes the 4 RSgImages sl@0: ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR2)); //Destroying 2nd EGLImage handle sl@0: ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR3)); //Destroying 3rd EGLImage handle sl@0: vgDestroyImage(vgImage2); //Destroying 2nd VGImage handle sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: sl@0: //Copy the source VGImage to the surface sl@0: INFO_PRINTF1(_L("Drawing the 4th VGImage content to the surface")); sl@0: vgSetPixels(0, 0, vgImage4, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: eglWaitClient(); sl@0: iEglSess->CheckVgDrawingL(iSurfaceFormat, bitmap); sl@0: INFO_PRINTF1(_L("Content is as expected")); sl@0: sl@0: INFO_PRINTF1(_L("Clear the surface and draw the 3rd VGImage content to the surface")); sl@0: VGfloat bgColor[] = {0.25, 0.50, 0.75, 1.0}; // random opaque colour sl@0: vgSetfv(VG_CLEAR_COLOR, 4, bgColor); sl@0: vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); sl@0: ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR); sl@0: vgSetPixels(0, 0, vgImage3, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: eglWaitClient(); sl@0: iEglSess->CheckVgDrawingL(iSurfaceFormat, bitmap); sl@0: INFO_PRINTF1(_L("Content is as expected")); sl@0: sl@0: INFO_PRINTF1(_L("Clear the surface, destroy the 4th VGImage and, after having it set up again, copy its content to the surface")); sl@0: vgSetfv(VG_CLEAR_COLOR, 4, bgColor); sl@0: vgClear(0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); sl@0: ASSERT_EGL_TRUE(vgGetError() == VG_NO_ERROR); sl@0: vgDestroyImage(vgImage4); //Destroying 4th VGImage handle sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: vgImage4 = VG_INVALID_HANDLE; sl@0: vgImage4 = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR4); //Creating 4th image again sl@0: ASSERT_VG_TRUE(vgImage4 != VG_INVALID_HANDLE); sl@0: vgSetPixels(0, 0, vgImage4, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: eglWaitClient(); sl@0: iEglSess->CheckVgDrawingL(iSurfaceFormat, bitmap); sl@0: INFO_PRINTF1(_L("Content is as expected")); sl@0: sl@0: INFO_PRINTF1(_L("Destroying remaining images")); sl@0: vgDestroyImage(vgImage1); //Destroying 1st VGImage handle sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: vgDestroyImage(vgImage3); //Destroying 3rd VGImage handle sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: vgDestroyImage(vgImage4); //Destroying 4th VGImage handle sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR1)); //Destroying 1st EGLImage handle sl@0: ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR4)); //Destroying 4th EGLImage handle sl@0: sl@0: //cleanup sl@0: CleanupStack::PopAndDestroy(bitmap); sl@0: CleanAll(); sl@0: RecordTestResultL(); sl@0: CloseTMSGraphicsStep(); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-EGL-0112 sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMPREQ 39 sl@0: sl@0: @SYMREQ See SGL.GT0386.401 document sl@0: sl@0: @SYMTestCaseDesc sl@0: Ensure that the EGL implementation holds a handle to the SgDriver. sl@0: In this way all the resource may be used even though a call to SgDriver::Close() has been made. sl@0: sl@0: @SYMTestActions sl@0: Create a RSgImage with the same content as the reference bitmap. sl@0: Create a EGLImage from the RSgImage. sl@0: Close the SgDriver. sl@0: Create a pbuffer surface, a context and make them current. sl@0: Create a VGImage from the eglImage. sl@0: Copy the VGImage to the surface. sl@0: Check the contents sl@0: Release all resources. sl@0: sl@0: @SYMTestExpectedResults sl@0: If creation of pbuffer fails, silently terminate the test without failing, as it is not mandatory to support sl@0: a pbuffer format. sl@0: The surface contains the expected contents. sl@0: No memory or handle leaks. sl@0: */ sl@0: TVerdict CEglTest_EGL_Image_SgDriverHandle::doTestStepL() sl@0: { sl@0: SetTestStepID(_L("GRAPHICS-EGL-0112")); sl@0: INFO_PRINTF1(_L("CEglTest_EGL_Image_SgDriverHandle::doTestStepL")); sl@0: sl@0: TBool ret = CheckForExtensionL(KEGL_RSgimage | KEGL_KHR_image_base | KEGL_KHR_image_pixmap | KVG_KHR_EGL_image); sl@0: if(!ret) sl@0: { sl@0: // The extension is not supported sl@0: RecordTestResultL(); sl@0: CloseTMSGraphicsStep(); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: // This test is performed for default pixel format sl@0: PrintUsedPixelConfiguration(); sl@0: sl@0: // Create display object sl@0: GetDisplayL(); sl@0: CreateEglSessionL(); sl@0: iEglSess->InitializeL(); sl@0: iEglSess->OpenSgDriverL(); sl@0: sl@0: RSgImage sgImage; sl@0: CleanupClosePushL(sgImage); sl@0: sl@0: // Create a reference bitmap which we use to init the SgImage (we use index=6) sl@0: TDisplayMode bitmapMode = EglTestConversion::PixelFormatToDisplayMode(iSourceFormat); sl@0: CFbsBitmap* bitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 6); sl@0: CleanupStack::PushL(bitmap); sl@0: sl@0: INFO_PRINTF1(_L("Creating 1 RSgImage")); sl@0: TSgImageInfoOpenVgImage imageInfo = TSgImageInfoOpenVgImage(iSourceFormat, KPixmapSize); sl@0: ASSERT_EQUALS(sgImage.Create(imageInfo, bitmap->DataAddress(), bitmap->DataStride()), KErrNone); sl@0: CleanupStack::PopAndDestroy(bitmap); sl@0: sl@0: INFO_PRINTF1(_L("Creating 1 EGLImage from the RSgImage")); sl@0: EGLImageKHR imageKHR = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &sgImage, KEglImageAttribsPreservedTrue); sl@0: ASSERT_EGL_TRUE(imageKHR != EGL_NO_IMAGE_KHR); sl@0: sl@0: //close SgImage before closing the SgDriver sl@0: CleanupStack::PopAndDestroy(&sgImage); sl@0: sl@0: INFO_PRINTF1(_L("Closing the SgDriver now should cause no difference")); sl@0: iEglSess->CloseSgDriver(); sl@0: sl@0: // If create pbuffer surface fails, don't fail if there's no matching config (but fail in any other situation): sl@0: // Support for a pbuffer surface is not mandated for any pixel format sl@0: // We should not enforce it in the tests sl@0: // Silently terminate the test without failing. sl@0: TEglTestConfig pbufferFormat = EglTestConversion::VgFormatToPBufferSurfaceFormat(iSurfaceFormat); sl@0: EGLConfig currentConfig = 0; sl@0: TRAPD(res, currentConfig = iEglSess->GetConfigExactMatchL( pbufferFormat )); sl@0: if(res == KTestNoMatchingConfig) sl@0: { sl@0: WARN_PRINTF2(_L("Can't create pbuffer, format %d. Terminating the test without failing"), pbufferFormat); sl@0: ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR)); sl@0: CleanAll(); sl@0: RecordTestResultL(); sl@0: CloseTMSGraphicsStep(); sl@0: return TestStepResult(); sl@0: } sl@0: User::LeaveIfError(res); // leave here if any other error was raised other than the one above. sl@0: iEglSess->CreatePbufferSurfaceAndMakeCurrentL(currentConfig, KPixmapSizeBigger, EGL_OPENVG_API); sl@0: sl@0: INFO_PRINTF1(_L("Creating 1 VGImage from the EGLImage")); sl@0: VGImage vgImage = iEglSess->vgCreateImageTargetKHR((VGeglImageKHR)imageKHR); sl@0: ASSERT_VG_TRUE(vgImage != VG_INVALID_HANDLE); sl@0: sl@0: INFO_PRINTF1(_L("Copying the VGImage to the surface")); sl@0: vgSetPixels(0, 0, vgImage, 0, 0, KPixmapSize.iWidth, KPixmapSize.iHeight); sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: eglWaitClient(); sl@0: sl@0: // Re-create a reference bitmap which we use to init the SgImage (we use index=6) sl@0: CFbsBitmap* refBitmap = iEglSess->CreateReferenceBitmapL(bitmapMode, KPixmapSize, 6); sl@0: CleanupStack::PushL(refBitmap); sl@0: iEglSess->CheckVgDrawingL(iSurfaceFormat, refBitmap); sl@0: CleanupStack::PopAndDestroy(refBitmap); sl@0: INFO_PRINTF1(_L("Content is as expected")); sl@0: sl@0: // destroy eglimage and vgimage sl@0: vgDestroyImage(vgImage); sl@0: ASSERT_TRUE(vgGetError()==VG_NO_ERROR); sl@0: ASSERT_EGL_TRUE(iEglSess->DestroyEGLImage(iDisplay, imageKHR)); sl@0: sl@0: //cleanup sl@0: CleanAll(); sl@0: RecordTestResultL(); sl@0: CloseTMSGraphicsStep(); sl@0: return TestStepResult(); sl@0: } sl@0: