egl/egltest/src/egltest_image_multiprocess.cpp
branchRCL_3
changeset 163 bbf46f59e123
parent 26 15986eb6c500
child 164 25ffed67c7ef
equal deleted inserted replaced
150:57c618273d5c 163:bbf46f59e123
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2009-2010 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".
    17  @file
    17  @file
    18  @test
    18  @test
    19 */
    19 */
    20 
    20 
    21 #include <test/tefunit.h> // for ASSERT macros
    21 #include <test/tefunit.h> // for ASSERT macros
    22 #ifndef __INIPARSER_H__
    22 #include <iniparser.h>
    23 #include <cinidata.h>
       
    24 #endif // __INIPARSER_H__
       
    25 #include <e32msgqueue.h>
    23 #include <e32msgqueue.h>
    26 
    24 
    27 #include "egltest_image_multiprocess.h"
    25 #include "egltest_image_multiprocess.h"
    28 
    26 
    29 #include <test/egltestcommonconversion.h>
    27 #include <test/egltestcommonconversion.h>
   516         TSgDrawableId sgImageId;
   514         TSgDrawableId sgImageId;
   517         messageQueue.ReceiveBlocking(sgImageId);
   515         messageQueue.ReceiveBlocking(sgImageId);
   518         ASSERT_EQUALS(rSgImageLocal.Open(sgImageId), KErrNone);
   516         ASSERT_EQUALS(rSgImageLocal.Open(sgImageId), KErrNone);
   519         }
   517         }
   520 
   518 
   521 	INFO_PRINTF2(_L("Process %d, Creating an EGLImage from the shared RSgImage"),aIdx);
   519 	// Wait for both processes to reach this point
       
   520     Rendezvous(aIdx);
       
   521     
       
   522     INFO_PRINTF2(_L("Process %d, Creating an EGLImage from the shared RSgImage"),aIdx);
   522 	CleanupClosePushL(rSgImageLocal);
   523 	CleanupClosePushL(rSgImageLocal);
   523 	EGLImageKHR eglImageLocal = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &rSgImageLocal, KEglImageAttribsPreservedTrue);
   524 	EGLImageKHR eglImageLocal = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &rSgImageLocal, KEglImageAttribsPreservedTrue);
   524 	ASSERT_EGL_TRUE(eglImageLocal != EGL_NO_IMAGE_KHR);
   525 	ASSERT_EGL_TRUE(eglImageLocal != EGL_NO_IMAGE_KHR);
   525 	CleanupStack::PopAndDestroy(&rSgImageLocal); 	//transferring ownership of the buffer to the EGLImage
   526 	CleanupStack::PopAndDestroy(&rSgImageLocal); 	//transferring ownership of the buffer to the EGLImage
   526 
   527 
   692         INFO_PRINTF2(_L("Process %d: Receiving SgImage ID from other process..."), aIdx);
   693         INFO_PRINTF2(_L("Process %d: Receiving SgImage ID from other process..."), aIdx);
   693         TSgDrawableId sgImageId;
   694         TSgDrawableId sgImageId;
   694         messageQueue.ReceiveBlocking(sgImageId);
   695         messageQueue.ReceiveBlocking(sgImageId);
   695         ASSERT_EQUALS(rSgImageLocal.Open(sgImageId),KErrNone);
   696         ASSERT_EQUALS(rSgImageLocal.Open(sgImageId),KErrNone);
   696         }
   697         }
       
   698 
       
   699 	// Wait for both processes to reach this point
       
   700     Rendezvous(aIdx);
   697 
   701 
   698 	INFO_PRINTF2(_L("Process %d, Creating an EGLImage from the shared RSgImage"),aIdx);
   702 	INFO_PRINTF2(_L("Process %d, Creating an EGLImage from the shared RSgImage"),aIdx);
   699 	CleanupClosePushL(rSgImageLocal);
   703 	CleanupClosePushL(rSgImageLocal);
   700 	EGLImageKHR eglImageLocal = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &rSgImageLocal, KEglImageAttribsPreservedTrue);
   704 	EGLImageKHR eglImageLocal = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &rSgImageLocal, KEglImageAttribsPreservedTrue);
   701 	ASSERT_EGL_TRUE(eglImageLocal != EGL_NO_IMAGE_KHR);
   705 	ASSERT_EGL_TRUE(eglImageLocal != EGL_NO_IMAGE_KHR);
  1460 		TSize bitmapSize = bitmap->SizeInPixels();
  1464 		TSize bitmapSize = bitmap->SizeInPixels();
  1461     	TUint8* address = reinterpret_cast<TUint8*>(bitmap->DataAddress());
  1465     	TUint8* address = reinterpret_cast<TUint8*>(bitmap->DataAddress());
  1462     	TInt stride = bitmap->DataStride();
  1466     	TInt stride = bitmap->DataStride();
  1463     	address += (bitmapSize.iHeight - 1) * stride;
  1467     	address += (bitmapSize.iHeight - 1) * stride;
  1464     	vgWritePixels(address, -stride, iSurfaceFormat, 0,0, bitmapSize.iWidth, bitmapSize.iHeight);
  1468     	vgWritePixels(address, -stride, iSurfaceFormat, 0,0, bitmapSize.iWidth, bitmapSize.iHeight);
       
  1469    	    eglWaitClient();   // wait for writing to finish
  1465 		delete bitmap;
  1470 		delete bitmap;
  1466 		bitmap = NULL;
  1471 		bitmap = NULL;
  1467 		ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
  1472 		ASSERT_TRUE(vgGetError()==VG_NO_ERROR);
  1468 
  1473 
  1469     	// Make no surface current and destroy surface
  1474     	// Make no surface current and destroy surface
  2104         TSgDrawableId sgImageId;
  2109         TSgDrawableId sgImageId;
  2105         messageQueueSgId.ReceiveBlocking(sgImageId);
  2110         messageQueueSgId.ReceiveBlocking(sgImageId);
  2106     	ASSERT_EQUALS(rSgImageLocal.Open(sgImageId),KErrNone);
  2111     	ASSERT_EQUALS(rSgImageLocal.Open(sgImageId),KErrNone);
  2107         }
  2112         }
  2108 
  2113 
       
  2114 	// Wait for both processes to reach this point
       
  2115     Rendezvous(aIdx);
       
  2116     
  2109     INFO_PRINTF2(_L("Process %d, Creating an EGLImage from the shared RSgImage"),aIdx);
  2117     INFO_PRINTF2(_L("Process %d, Creating an EGLImage from the shared RSgImage"),aIdx);
  2110 	CleanupClosePushL(rSgImageLocal);
  2118 	CleanupClosePushL(rSgImageLocal);
  2111 	EGLImageKHR eglImageLocal = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &rSgImageLocal, KEglImageAttribsPreservedTrue);
  2119 	EGLImageKHR eglImageLocal = iEglSess->eglCreateImageKhrL(iDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, &rSgImageLocal, KEglImageAttribsPreservedTrue);
  2112 	ASSERT_EGL_TRUE(eglImageLocal != EGL_NO_IMAGE_KHR);
  2120 	ASSERT_EGL_TRUE(eglImageLocal != EGL_NO_IMAGE_KHR);
  2113 	CleanupStack::PopAndDestroy(&rSgImageLocal); 	//transferring ownership of the buffer to the EGLImage
  2121 	CleanupStack::PopAndDestroy(&rSgImageLocal); 	//transferring ownership of the buffer to the EGLImage