guestrendering/guestegl/src/guestegl.cpp
author Faisal Memon <faisal.memon@nokia.com>
Thu, 09 Sep 2010 18:49:52 +0100
branchbug235_bringup_0
changeset 19 da7c1a80df0d
parent 18 3064c37a6509
child 28 9464ab1666a0
child 30 f204b762818d
permissions -rwxr-xr-x
Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     7
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    10
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    11
// Contributors:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    12
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    13
// Description:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    14
// Guest EGL implementation
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    15
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    16
#include <graphics/surfacemanager.h>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    17
#include <graphics/surfaceconfiguration.h>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    18
#include <graphics/suerror.h>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    19
#include <graphics/surface_hints.h>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    20
#include <e32debug.h>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    21
#include <stdlib.h> // for malloc
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    22
#include "eglapi.h"
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    23
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    24
#include <graphics/guestvideodriverinterfaceconstants.h>
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    25
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    26
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    27
// FAISALMEMON HOLE 0
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    28
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    29
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    30
// constructor
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    31
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    32
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    33
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    34
// FAISALMEMON STUB CODE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    35
#define EGL_CHECK_ERROR(a, b, c)      /* This does no checking; just a stub */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    36
void CGuestEGL::EglInternalFunction_DestroyWindowSurface(TSurfaceInfo&)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    37
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    38
	return; // stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    39
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    40
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    41
EGLBoolean CGuestEGL::EglInternalFunction_SurfaceResized(TEglThreadState&, TSurfaceInfo&, int, int) 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    42
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    43
	return EFalse; // stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    44
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    45
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    46
TBool CGuestEGL::EglInternalFunction_SwapWindowSurface(TEglThreadState&, int, int)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    47
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    48
	return EFalse; // stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    49
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    50
TSymbianPixmapTypeId CGuestEGL::EglInternalFunction_GetNativePixmapType(void*)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    51
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    52
	return EPixmapTypeNone; // stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    53
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    54
TBool CGuestEGL::EglInternalFunction_IsValidNativePixmap(void*, TSymbianPixmapTypeId)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    55
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    56
	return EFalse; // stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    57
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    58
const char * CGuestEGL::EglInternalFunction_QueryExtensionList()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    59
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    60
	return NULL; // stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    61
	}
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    62
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    63
/**
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    64
Obtain extension function pointer.
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    65
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    66
Provide support for the Symbian Graphics SHAI for EGL Extensions
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    67
@param aName	Name of extension
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    68
@return			Function pointer, or NULL if not available.
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    69
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    70
@note  Known extensions and their directly associated functions:
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    71
   1. EGL_KHR_image 
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    72
		None
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    73
   2. EGL_KHR_image_base 
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    74
		eglCreateImageKHR,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    75
		eglDestroyImageKHR
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    76
   3. EGL_KHR_image_pixmap
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    77
		None
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    78
   4. EGL_KHR_vg_parent_image
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    79
		None
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    80
   5. EGL_KHR_gl_texture_2D_image
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    81
		None
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    82
   6. EGL_KHR_gl_texture_cubemap_image
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    83
		EGLImageTargetTexture2DOES,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    84
		EGLImageTargetRenderbufferStorageOES
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    85
   7. EGL_KHR_lock_surface2
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    86
		eglLockSurfaceKHR,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    87
		eglUnlockSurfaceKHR
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    88
   8. EGL_NOK_resource_profiling2
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    89
		eglQueryProfilingDataNOK
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    90
   9. EGL_SYMBIAN_composition
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    91
		None
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
    92
  10. EGL_NOK_image_endpoint
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    93
		eglCreateEndpointNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    94
		eglDestroyEndpointNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    95
		eglGetEndpointAttribNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    96
		eglSetEndpointAttribNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    97
		eglEndpointBeginStreamingNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    98
		eglEndpointEndStreamingNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
    99
		eglAcquireImageNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   100
		eglReleaseImageNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   101
		eglGetEndpointDirtyAreaNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   102
		eglEndpointRequestNotificationNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   103
		eglEndpointCancelNotificationNOK,
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   104
		eglCreateEndpointNOK
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   105
  11. NOK_pixmap_type_rsgimage
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   106
		None
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   107
  12. EGL_NOK_swap_region
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   108
		eglSwapBuffersRegionNOK
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   109
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   110
@see Khronos EGL 1.4 Specification, eglGetProcAddress()
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   111
@author Faisal Memon Community EGL project
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   112
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   113
*/
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   114
ProcPointer CGuestEGL::eglGetProcAddress(const char* aName)
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   115
	{
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   116
    if (strncmp("eglCreateImageKHR", aName, strlen("eglCreateImageKHR")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   117
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   118
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   119
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   120
    else if (strncmp("eglDestroyImageKHR", aName, strlen("eglDestroyImageKHR")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   121
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   122
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   123
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   124
    else if (strncmp("EGLImageTargetTexture2DOES", aName, strlen("EGLImageTargetTexture2DOES")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   125
None
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   126
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   127
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   128
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   129
    else if (strncmp("EGLImageTargetRenderbufferStorageOES", aName, strlen("EGLImageTargetRenderbufferStorageOES")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   130
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   131
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   132
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   133
    else if (strncmp("eglLockSurfaceKHR", aName, strlen("eglLockSurfaceKHR")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   134
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   135
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   136
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   137
    else if (strncmp("eglUnlockSurfaceKHR", aName, strlen("eglUnlockSurfaceKHR")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   138
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   139
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   140
        }
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   141
    else if (strncmp("EGL_KHR_lock_surface", aName, strlen("EGL_KHR_lock_surface")) == 0)
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   142
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   143
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   144
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   145
    else if (strncmp("eglQueryProfilingDataNOK", aName, strlen("eglQueryProfilingDataNOK")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   146
        {
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   147
        return NULL;
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   148
        }
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   149
    else if (strncmp("eglCreateEndpointNOK", aName, strlen("eglCreateEndpointNOK")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   150
        {
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   151
        return NULL;
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   152
        }
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   153
    else if (strncmp("eglDestroyEndpointNOK", aName, strlen("eglDestroyEndpointNOK")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   154
        {
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   155
        return NULL;
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   156
        }
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   157
    else if (strncmp("eglGetEndpointAttribNOK", aName, strlen("eglGetEndpointAttribNOK")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   158
        {
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   159
        return NULL;
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   160
        }
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   161
    else if (strncmp("eglEndpointBeginStreamingNOK", aName, strlen("eglEndpointBeginStreamingNOK")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   162
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   163
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   164
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   165
    else if (strncmp("eglEndpointEndStreamingNOK", aName, strlen("eglEndpointEndStreamingNOK")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   166
        {
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   167
        return NULL;
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   168
        }
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   169
    else if (strncmp("eglAcquireImageNOK", aName, strlen("eglAcquireImageNOK")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   170
        {
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   171
        return NULL;
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   172
        }
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   173
    else if (strncmp("eglReleaseImageNOK", aName, strlen("eglReleaseImageNOK")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   174
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   175
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   176
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   177
    else if (strncmp("eglGetEndpointDirtyAreaNOK", aName, strlen("eglGetEndpointDirtyAreaNOK")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   178
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   179
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   180
        }
19
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   181
    else if (strncmp("eglEndpointRequestNotificationNOK", aName, strlen("eglEndpointRequestNotificationNOK")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   182
        {
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   183
        return NULL;
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   184
        }
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   185
    else if (strncmp("eglEndpointCancelNotificationNOK", aName, strlen("eglEndpointCancelNotificationNOK")) == 0)
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   186
        {
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   187
        return NULL;
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   188
        }
da7c1a80df0d Identify the actual EGL extension functions, just returning NULL for the moment. Prototype code, needs bring-up before testing
Faisal Memon <faisal.memon@nokia.com>
parents: 18
diff changeset
   189
    else if (strncmp("eglCreateEndpointNOK", aName, strlen("eglCreateEndpointNOK")) == 0)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   190
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   191
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   192
        }
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   193
    else if (strncmp("eglSwapBuffersRegionNOK", aName, strlen("eglSwapBuffersRegionNOK")) == 0)
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   194
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   195
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   196
        }
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   197
    else
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   198
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   199
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   200
        }
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   201
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   202
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   203
EGLSurface CGuestEGL::eglCreateWindowSurface(TEglThreadState&, int, int, void*, const int*)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   204
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   205
	return 0; // stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   206
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   207
const char* CGuestEGL::eglQueryString(EGLDisplay aDisplay, EGLint aName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   208
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   209
	return NULL; // stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   210
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   211
// FAISALMEMON END OF STUB CODE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   212
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   213
CGuestEGL::CGuestEGL() :
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   214
		iEglSyncExtension(NULL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   215
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   216
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   217
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   218
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   219
void CGuestEGL::OpenSgResources()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   220
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   221
	// ToDo delay opening SgDriver until needed, as it force loads Open GL ES 1.1, GL ES 2 and Open VG DLLs if it finds them
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   222
	TInt err = iSgDriver.Open();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   223
	EGL_TRACE("  CGuestEGL::Create SgDriver.Open err=%d", err);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   224
	EGLPANIC_ASSERT(err == KErrNone, EEglPanicSgDriverCreateLocalFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   225
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   226
	TVersion sgImageVer = RSgDriver::Version();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   227
	EGL_TRACE("  CGuestEGL::Create  sgImageVer=%d.%d", sgImageVer.iMajor, sgImageVer.iMinor);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   228
	EGLPANIC_ASSERT(sgImageVer.iMajor == 1, EEglPanicBadSgDriverVersion);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   229
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   230
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   231
void CGuestEGL::CloseSgResources()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   232
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   233
	iSgDriver.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   234
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   235
#else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   236
void CGuestEGL::CloseSgResources()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   237
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   238
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   239
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   240
void CGuestEGL::OpenSgResources()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   241
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   242
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   243
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   244
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   245
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   246
// destructor
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   247
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   248
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   249
CGuestEGL::~CGuestEGL()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   250
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   251
	EGL_TRACE("CGuestEGL::~CGuestEGL");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   252
	// only expected to be called during process termination
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   253
	if (iEglSyncExtension)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   254
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   255
		delete iEglSyncExtension;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   256
		iEglSyncExtension = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   257
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   258
	iDisplayMapLock.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   259
	CloseSgResources();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   260
	iEglImageLock.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   261
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   262
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   263
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   264
// 2nd phase constructor
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   265
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   266
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   267
void CGuestEGL::Create()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   268
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   269
	EGL_TRACE("  CGuestEGL::Create -->");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   270
    OpenSgResources();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   271
    TInt err;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   272
	err = iDisplayMapLock.CreateLocal();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   273
	EGLPANIC_ASSERT(err == KErrNone, EEglPanicDisplayMapLockCreateLocalFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   274
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   275
	err = iEglImageLock.CreateLocal();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   276
	EGLPANIC_ASSERT(err == KErrNone, EEglPanicEglImageLockCreateLocalFailed);	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   277
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   278
	InitialiseExtensions();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   279
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   280
	const char* initExtensionList = EglInternalFunction_QueryExtensionList();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   281
	EGL_TRACE("  CGuestEGL::Create  initExtensionList=0x%x (\"%s\") <--",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   282
			initExtensionList, initExtensionList ? initExtensionList : "");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   283
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   284
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   285
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   286
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   287
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   288
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   289
CGuestEGL* CGuestEGL::New()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   290
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   291
	EGL_TRACE("CGuestEGL::New  start -->");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   292
	RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   293
	CGuestEGL* result = new CGuestEGL();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   294
	CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   295
	EGLPANIC_ASSERT(result, EEglPanicGuestGraphicsAllocFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   296
	if (result)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   297
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   298
		result->Create();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   299
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   300
	EGL_TRACE("CGuestEGL::New end - result=0x%x  <--", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   301
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   302
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   303
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   304
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   305
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   306
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   307
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   308
void CGuestEGL::SetError(EGLint aError)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   309
	{ // ToDo remove - everything except EGL Sync already uses threadState->SetEglError
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   310
	EGL_TRACE( "CGuestEGL::SetError EGL error=0x%x", aError);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   311
	TEglThreadState* threadState = CVghwUtils::EglThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   312
	if (threadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   313
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   314
		threadState->SetEglError(aError);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   315
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   316
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   317
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   318
EGLint CGuestEGL::CheckColorAttributes(const EGLint* aAttribList, EGLint aColorBufferType, EGLint aLuminanceBits, EGLint aRedBits,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   319
		EGLint aGreenBits, EGLint aBlueBits, EGLint aAlphaBits)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   320
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   321
	const EGLint* pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_COLOR_BUFFER_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   322
	if (pValue && (*pValue != aColorBufferType))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   323
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   324
		return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   325
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   326
	EGLint colorBits = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   327
	if (aColorBufferType == EGL_RGB_BUFFER)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   328
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   329
		colorBits = aRedBits + aGreenBits + aBlueBits + aAlphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   330
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   331
		if (pValue && (*pValue < aRedBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   332
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   333
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   334
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   335
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   336
		if (pValue && (*pValue < aGreenBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   337
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   338
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   339
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   340
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   341
		if (pValue && (*pValue < aBlueBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   342
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   343
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   344
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   345
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   346
		if (pValue && (*pValue != 0))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   347
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   348
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   349
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   350
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   351
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   352
		{ // EGL_LUMINANCE_BUFFER
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   353
		colorBits = aLuminanceBits + aAlphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   354
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   355
		if (pValue && (*pValue != 0))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   356
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   357
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   358
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   359
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   360
		if (pValue && (*pValue != 0))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   361
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   362
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   363
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   364
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   365
		if (pValue && (*pValue != 0))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   366
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   367
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   368
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   369
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   370
		if (pValue && (*pValue < aLuminanceBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   371
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   372
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   373
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   374
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   375
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   376
	if (aAlphaBits)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   377
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   378
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_ALPHA_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   379
		if (pValue && (*pValue < aAlphaBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   380
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   381
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   382
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   383
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   384
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   385
	pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BUFFER_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   386
	if (pValue && (*pValue < colorBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   387
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   388
		return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   389
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   390
	return EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   391
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   392
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   393
void CGuestEGL::AppendColorAttributes(EGLint* aAttribList, EGLint aColorBufferType, EGLint aLuminanceBits, EGLint aRedBits,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   394
		EGLint aGreenBits, EGLint aBlueBits, EGLint aAlphaBits, TBool aSetVgPreMultAlpha)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   395
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   396
	const EGLint* pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_COLOR_BUFFER_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   397
	if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   398
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   399
		TAttribUtils::AppendAttribValue(aAttribList, EGL_COLOR_BUFFER_TYPE, aColorBufferType);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   400
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   401
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   402
	EGLint colorBits = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   403
	if (aColorBufferType == EGL_RGB_BUFFER)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   404
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   405
		colorBits = aRedBits + aGreenBits + aBlueBits + aAlphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   406
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   407
		if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   408
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   409
			TAttribUtils::AppendAttribValue(aAttribList, EGL_RED_SIZE, aRedBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   410
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   411
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   412
		if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   413
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   414
			TAttribUtils::AppendAttribValue(aAttribList, EGL_GREEN_SIZE, aGreenBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   415
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   416
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   417
		if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   418
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   419
			TAttribUtils::AppendAttribValue(aAttribList, EGL_BLUE_SIZE, aBlueBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   420
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   421
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   422
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   423
		{ // EGL_LUMINANCE_BUFFER
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   424
		colorBits = aLuminanceBits + aAlphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   425
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   426
		if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   427
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   428
			TAttribUtils::AppendAttribValue(aAttribList, EGL_LUMINANCE_SIZE, aLuminanceBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   429
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   430
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   431
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   432
	pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BUFFER_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   433
	if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   434
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   435
		TAttribUtils::AppendAttribValue(aAttribList, EGL_BUFFER_SIZE, colorBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   436
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   437
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   438
	if (aAlphaBits)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   439
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   440
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_ALPHA_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   441
		if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   442
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   443
			TAttribUtils::AppendAttribValue(aAttribList, EGL_ALPHA_SIZE, aAlphaBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   444
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   445
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   446
	if (aSetVgPreMultAlpha)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   447
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   448
		EGLint* pSurfaceType = TAttribUtils::FindAttribValue(aAttribList, EGL_SURFACE_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   449
		if (pSurfaceType)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   450
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   451
			*pSurfaceType |= EGL_VG_ALPHA_FORMAT_PRE_BIT;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   452
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   453
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   454
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   455
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   456
EGLBoolean CGuestEGL::ChooseConfigForPixmapSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, const EGLint* aAttribList, EGLConfig* aConfigs, EGLint aConfigSize,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   457
		EGLint* aNumConfig, const void* aPixmap)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   458
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   459
	EGLint error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   460
	EGLint* newList = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   461
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   462
	switch ( EglInternalFunction_GetNativePixmapType((EGLNativePixmapType) (aPixmap)) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   463
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   464
		case EPixmapTypeFbsBitmap:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   465
			EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 1.a pixmap type is FbsBitmap (aPixmap=0x%x)", aPixmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   466
			error = ChooseConfigAttribsForFbsBitmap(aThreadState, aAttribList, reinterpret_cast<const CFbsBitmap*>(aPixmap), &newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   467
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   468
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   469
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   470
		case EPixmapTypeSgImage:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   471
			EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 1.b pixmap type is SgImage (aPixmap=0x%x)", aPixmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   472
			error = ChooseConfigAttribsForSgImage(aThreadState, aAttribList, reinterpret_cast<const RSgImage*>(aPixmap), &newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   473
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   474
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   475
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   476
		case EPixmapTypeNone:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   477
		default:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   478
			EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 1.c pixmap type is unknown (aPixmap=0x%x)", aPixmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   479
			error = EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   480
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   481
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   482
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   483
	if (error != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   484
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   485
		aThreadState.SetEglError(error);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   486
		EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 2.a encountered error=0x%x", error);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   487
		if (newList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   488
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   489
			CVghwUtils::Free(newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   490
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   491
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   492
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   493
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   494
	EGLPANIC_ASSERT(newList, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   495
	EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 2.b temp AttribList ... (*newList=0x%x)", *newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   496
	EGL_TRACE_ATTRIB_LIST(newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   497
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   498
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   499
	eglApiData.Init( EglRFC::EeglChooseConfig );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   500
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   501
	eglApiData.AppendEGLintVector(newList, TAttribUtils::AttribListLength(newList) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   502
	eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   503
	eglApiData.AppendEGLint(aConfigSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   504
	eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   505
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   506
	EGL_TRACE("CGuestEGL::ChooseConfigForPixmapSurface 3. Host EGL success=%d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   507
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   508
	CVghwUtils::Free(newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   509
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   510
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   511
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   512
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   513
EGLBoolean CGuestEGL::ChooseConfigForNativeSgImagePixmapSurface( TEglThreadState& aThreadState, EGLDisplay aDisplay, const EGLint* aAttribList, EGLConfig* aConfigs, EGLint aConfigSize,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   514
        EGLint* aNumConfig, const EGLint* aPixmap )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   515
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   516
    EGLConfig* sgConfigs;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   517
    EGLint sgConfigCnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   518
    TBool* sgConfigsMatchingAttributes;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   519
    TInt sgConfigsMatchingAttributesCnt=0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   520
    EGLint* sgConfigAttribs;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   521
    EGLint sgConfigsAttribtCnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   522
    EGL_TRACE( "CGuestEGL::eglChooseConfig: ChooseConfigForNativePixmapSurface" );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   523
    EglInternalFunction_MetaGetConfigs( aThreadState, sgConfigs, sgConfigCnt, sgConfigAttribs, sgConfigsAttribtCnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   524
    EGL_TRACE( "EglInternalFunction_MetaGetConfigAttirb cnt = %d ", sgConfigsAttribtCnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   525
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   526
    sgConfigsMatchingAttributes = new TBool[sgConfigCnt];
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   527
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   528
    TInt attribs_per_config = EglRFC::MetaGetConfigAttributeCnt();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   529
    TInt configcnt = (TInt) sgConfigsAttribtCnt / attribs_per_config;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   530
    EGL_TRACE( "EglInternalFunction_MetaGetConfigs cnt = %d ", configcnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   531
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   532
    //The attribute values of aAttribList, in the order of MetaGetConfigAttribute(i)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   533
    EGLint* specAttribVals = new EGLint[ attribs_per_config ];
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   534
    for( TInt i=0;i<attribs_per_config;++i )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   535
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   536
        *( specAttribVals + i ) = -1; 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   537
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   538
    int spec_attrib_kind;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   539
    int i_spec_attrib = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   540
    //Go through all the given attributes
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   541
    while( (spec_attrib_kind =  *(aAttribList + i_spec_attrib )) != EGL_NONE )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   542
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   543
        //Check which type of attribute is specified, then set the value if types match
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   544
        for( TInt i=0;i<attribs_per_config;++i )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   545
            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   546
            if( spec_attrib_kind == EglRFC::MetaGetConfigAttribute( i ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   547
            *(specAttribVals + i) = *( aAttribList + i_spec_attrib );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   548
            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   549
        i_spec_attrib += 2;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   550
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   551
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   552
    //Go through the configurations
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   553
    for( TInt i_config = 0;i_config < configcnt; ++i_config )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   554
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   555
        TBool pass = ETrue;//true, unless we bump into an attribute that doesn't match
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   556
        //Go throught the attributes of this configuration
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   557
        for( TInt i_attr = 0; i_attr < attribs_per_config; ++i_attr )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   558
            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   559
            EGL_TRACE( "cnf %d, attr %d = %d ", i_config, i_attr, *( sgConfigAttribs + i_config*attribs_per_config + i_attr ) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   560
            //Match attribute values here, if the client-specified attribute value isn't empty
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   561
            if( *( specAttribVals + i_attr ) != -1 )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   562
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   563
                switch( EglRFC::MetaGetConfigAttributeSelCriteria( i_attr ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   564
                    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   565
                    case EExact:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   566
                        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   567
                        if( *( specAttribVals + i_attr ) != *( sgConfigAttribs + i_config*attribs_per_config + i_attr ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   568
                            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   569
                            pass = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   570
                            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   571
                        break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   572
                        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   573
                    case EAtLeast:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   574
                        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   575
                        if( *( specAttribVals + i_attr ) > *( sgConfigAttribs + i_config*attribs_per_config + i_attr ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   576
                            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   577
                            pass = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   578
                            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   579
                        break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   580
                        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   581
                    case EMask:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   582
                        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   583
                        if( !(*( specAttribVals + i_attr ) & *( sgConfigAttribs + i_config*attribs_per_config + i_attr )) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   584
                            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   585
                            pass = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   586
                            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   587
                        break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   588
                        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   589
                    }//switch comparison method
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   590
                
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   591
                }//if attribute value specified by client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   592
            }//for through the attributes of a configuration
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   593
            if( pass )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   594
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   595
                *(sgConfigsMatchingAttributes + i_config) = ETrue; 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   596
                }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   597
            else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   598
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   599
                *(sgConfigsMatchingAttributes + i_config) = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   600
                }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   601
        }//end for through the configurations
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   602
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   603
    //Now get the configs that match, and return those
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   604
    TInt aConfigsIndex = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   605
    for( TInt i_config = 0;i_config < configcnt; ++i_config )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   606
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   607
        if( *(sgConfigsMatchingAttributes + i_config) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   608
            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   609
            if( aConfigsIndex < aConfigSize )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   610
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   611
                *(aConfigs + (aConfigsIndex++)) = *(sgConfigs + i_config);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   612
                ++sgConfigsMatchingAttributesCnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   613
                }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   614
            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   615
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   616
    //Ok, all done. Delete allocated memory
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   617
	// ToDo use correct Heap!
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   618
    delete[] sgConfigs;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   619
    delete[] sgConfigsMatchingAttributes;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   620
    delete[] sgConfigAttribs;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   621
    delete[] specAttribVals;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   622
	return EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   623
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   624
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   625
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   626
EGLint CGuestEGL::ChooseConfigAttribsForFbsBitmap(TEglThreadState& aThreadState, const EGLint* aAttribList, const CFbsBitmap* aBitmap, EGLint** aNewList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   627
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   628
	EGLPANIC_ASSERT_DEBUG(aNewList, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   629
	EGLint error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   630
	const TInt listLength = TAttribUtils::AttribListLength(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   631
	ASSERT(listLength);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   632
	TDisplayMode mode = ENone;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   633
	const EGLint* pRenderType = TAttribUtils::FindAttribValue(aAttribList, EGL_RENDERABLE_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   634
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   635
	mode = aBitmap->DisplayMode();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   636
	EGL_TRACE("CGuestEGL::ChooseConfigAttribsForFbsBitmap bitmap addr=0x%x, Display Mode=%d", aBitmap, mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   637
	switch (mode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   638
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   639
		case EColor64K:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   640
			error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 5, 6, 5);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   641
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   642
		case EColor16M:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   643
		case EColor16MU:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   644
			error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   645
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   646
		case EColor16MA:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   647
			error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   648
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   649
		case EColor16MAP:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   650
			error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   651
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   652
		default: // pixmap not supported
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   653
			error = EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   654
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   655
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   656
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   657
	if (error != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   658
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   659
		return error;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   660
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   661
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   662
	const TInt KExpansionSpace = 10 * 2; // want enough space for 10 extra attribute/value pairs
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   663
	*aNewList = (EGLint*) CVghwUtils::Alloc( (listLength + KExpansionSpace) * sizeof(EGLint) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   664
	if (!*aNewList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   665
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   666
		return EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   667
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   668
	memcpy(*aNewList, aAttribList, listLength * sizeof(EGLint));
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   669
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   670
	switch (mode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   671
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   672
		case EColor64K:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   673
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 5, 6, 5);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   674
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   675
		case EColor16M:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   676
		case EColor16MU:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   677
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   678
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   679
		case EColor16MA:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   680
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   681
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   682
		case EColor16MAP:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   683
			if (pRenderType && ( (*pRenderType) & EGL_OPENVG_BIT) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   684
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   685
				AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8, ETrue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   686
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   687
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   688
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   689
				AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   690
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   691
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   692
		default:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   693
			EGLPANIC_ALWAYS(EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   694
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   695
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   696
	return EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   697
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   698
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   699
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   700
EGLint CGuestEGL::ChooseConfigAttribsForSgImage(TEglThreadState& aThreadState, const EGLint* aAttribList, const RSgImage* aSgImage, EGLint** aNewList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   701
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   702
	ASSERT(aNewList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   703
	EGLint error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   704
	const TInt listLength = TAttribUtils::AttribListLength(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   705
	ASSERT(listLength);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   706
	const EGLint* pRenderType = TAttribUtils::FindAttribValue(aAttribList, EGL_RENDERABLE_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   707
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   708
	/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   709
	if (!iSgConfigAttribs)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   710
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   711
		EGL_TRACE( "CGuestEGL::ChooseConfigAttribsForSgImage 1. EglInternalFunction_MetaGetConfigs" );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   712
		EGLConfig* config;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   713
		EGLint config_cnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   714
		EglInternalFunction_MetaGetConfigs(aThreadState, config, config_cnt, iSgConfigAttribs, iSgConfigsAttribtCnt);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   715
		EGL_TRACE( "EglInternalFunction_MetaGetConfigs cnt = %d ", iSgConfigsAttribtCnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   716
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   717
	if (!iSgConfigAttribs)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   718
		{ // exit if EglInternalFunction_MetaGetConfigs still failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   719
		return EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   720
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   721
	*/
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   722
	// ToDo use iSgConfigAttribs
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   723
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   724
	// temporarily open a handle to the SgImage
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   725
	TSgDrawableId sgId = aSgImage->Id();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   726
	RSgDrawable sgHandle;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   727
	TSgImageInfo imgInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   728
	EGL_TRACE("CGuestEGL::ChooseConfigAttribsForSgImage 1. SgImage Id=0x%lx", sgId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   729
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   730
	// ToDo check SgImage usage bits 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   731
	if ( (sgId != KSgNullDrawableId) && (KErrNone == sgHandle.Open(sgId)) && (KErrNone == aSgImage->GetInfo(imgInfo)) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   732
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   733
		EGL_TRACE("CGuestEGL::ChooseConfigAttribsForSgImage 2. SgImage PixelFormat=0x%x; size=%d,%d; Usage=0x%x",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   734
				imgInfo.iPixelFormat, imgInfo.iSizeInPixels.iWidth, imgInfo.iSizeInPixels.iHeight, imgInfo.iUsage);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   735
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   736
		switch (imgInfo.iPixelFormat)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   737
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   738
			case ESgPixelFormatARGB_8888_PRE: // == EUidPixelFormatARGB_8888_PRE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   739
			case ESgPixelFormatARGB_8888: // == EUidPixelFormatARGB_8888,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   740
				error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   741
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   742
			case ESgPixelFormatXRGB_8888: // == EUidPixelFormatXRGB_8888,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   743
				error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   744
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   745
			case ESgPixelFormatRGB_565: // == EUidPixelFormatRGB_565,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   746
				error = CheckColorAttributes(aAttribList, EGL_RGB_BUFFER, 0, 5, 6, 5);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   747
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   748
			case ESgPixelFormatA_8: // == EUidPixelFormatA_8
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   749
				error = CheckColorAttributes(aAttribList, EGL_LUMINANCE_BUFFER, 8, 0, 0, 0);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   750
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   751
			default: // pixmap not supported
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   752
				error = EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   753
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   754
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   755
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   756
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   757
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   758
		error = EGL_BAD_PARAMETER;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   759
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   760
	sgHandle.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   761
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   762
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   763
	if (error != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   764
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   765
		return error;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   766
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   767
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   768
	const TInt KExpansionSpace = 10 * 2; // want enough space for 10 extra attribute/value pairs
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   769
	*aNewList = (EGLint*) CVghwUtils::Alloc( (listLength + KExpansionSpace) * sizeof(EGLint) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   770
	if (!*aNewList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   771
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   772
		return EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   773
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   774
	memcpy(*aNewList, aAttribList, listLength * sizeof(EGLint));
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   775
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   776
	switch (imgInfo.iPixelFormat)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   777
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   778
		case ESgPixelFormatARGB_8888_PRE: // == EUidPixelFormatARGB_8888_PRE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   779
			if (pRenderType && ( (*pRenderType) & EGL_OPENVG_BIT) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   780
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   781
				AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8, ETrue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   782
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   783
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   784
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   785
				AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   786
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   787
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   788
		case ESgPixelFormatARGB_8888: // == EUidPixelFormatARGB_8888,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   789
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   790
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   791
		case ESgPixelFormatXRGB_8888: // == EUidPixelFormatXRGB_8888,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   792
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   793
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   794
		case ESgPixelFormatRGB_565: // == EUidPixelFormatRGB_565,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   795
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 5, 6, 5);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   796
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   797
		case ESgPixelFormatA_8: // == EUidPixelFormatA_8
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   798
			AppendColorAttributes(*aNewList, EGL_LUMINANCE_BUFFER, 8, 0, 0, 0);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   799
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   800
		default: // pixmap not supported - panic because this code should be in-sync with supported SgImage formats
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   801
			EGLPANIC_ALWAYS(EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   802
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   803
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   804
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   805
	// change requested surface type from pixmap to Pbuffer
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   806
	EGLint* pSurfaceType = TAttribUtils::FindAttribValue(*aNewList, EGL_SURFACE_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   807
	EGLint surfaceType = *pSurfaceType;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   808
	*pSurfaceType = EGL_PBUFFER_BIT | (surfaceType & ~EGL_PIXMAP_BIT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   809
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   810
	TAttribUtils::RemoveAttrib(*aNewList, EGL_MATCH_NATIVE_PIXMAP);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   811
	return EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   812
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   813
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   814
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   815
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   816
  Create an information object for an opened Display.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   817
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   818
TBool CGuestEGL::CreateDisplayInfo(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   819
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   820
	TBool result = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   821
	EGL_TRACE("CGuestEGL::CreateDisplayInfo begin aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   822
	iDisplayMapLock.WriteLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   823
	RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   824
	if (NULL != iDisplayMap.Find( aDisplay))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   825
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   826
		result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   827
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   828
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   829
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   830
		TInt err = KErrNoMemory; 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   831
		CEglDisplayInfo* dispInfo = new CEglDisplayInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   832
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   833
		if (dispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   834
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   835
			err = iDisplayMap.Insert(aDisplay, dispInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   836
	//		EGL_TRACE("CreateDisplayInfo - DisplayMap insert error %d", err);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   837
			EGLPANIC_ASSERT_DEBUG(err == KErrNone, EEglPanicDisplayMapInsertFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   838
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   839
			//added for egl sync extension benefit
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   840
			if (iEglSyncExtension)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   841
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   842
				err = iEglSyncExtension->EglSyncDisplayCreate(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   843
	//			EGL_TRACE("CreateDisplayInfo - EglSyncDisplayCreate error %d", err);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   844
				EGLPANIC_ASSERT_DEBUG(err == KErrNone, EEglPanicEglSyncDisplayCreateFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   845
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   846
				if (err)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   847
					{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   848
					iDisplayMap.Remove(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   849
					}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   850
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   851
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   852
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   853
		if (err == KErrNone)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   854
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   855
			result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   856
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   857
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   858
	CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   859
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   860
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   861
	EGL_TRACE("CreateDisplayInfo end, result=%d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   862
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   863
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   864
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   865
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   866
  Mark information object for Display as Initialised
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   867
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   868
TBool CGuestEGL::InitializeDisplayInfo(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   869
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   870
	TBool result = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   871
	EGL_TRACE("CGuestEGL::InitialiseDisplayInfo begin aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   872
	iDisplayMapLock.WriteLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   873
	CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   874
	if (pDispInfo && *pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   875
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   876
		(*pDispInfo)->iInitialized = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   877
		result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   878
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   879
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   880
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   881
	EGL_TRACE("InitialiseDisplayInfo end, result=%d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   882
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   883
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   884
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   885
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   886
  Check whether Display exists and is Initialised
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   887
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   888
TBool CGuestEGL::IsDisplayInitialized(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   889
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   890
	TBool result = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   891
	EGL_TRACE("CGuestEGL::IsDisplayInitialized begin aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   892
	iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   893
	CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   894
	if ( pDispInfo && *pDispInfo && (*pDispInfo)->iInitialized)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   895
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   896
		result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   897
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   898
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   899
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   900
	EGL_TRACE("IsDisplayInitialized end, result=%d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   901
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   902
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   903
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   904
EGLBoolean CGuestEGL::eglSwapBuffers(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   905
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   906
    EglInternalFunction_SwapWindowSurface(aThreadState, aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   907
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   908
    // ToDo when all surfaces are recorded in client validate BEFORE sending cmd to host
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   909
    TSurfaceInfo* surfaceInfo = EglInternalFunction_GetPlatformSurface( aDisplay, aSurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   910
    EGL_CHECK_ERROR( surfaceInfo, EGL_BAD_SURFACE, EGL_FALSE );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   911
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   912
    //Check if surface size has changed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   913
    TSize size = surfaceInfo->iNativeWindow->Size();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   914
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   915
    if (size != surfaceInfo->iSize)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   916
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   917
		EGL_TRACE("CGuestEGL::eglSwapBuffers Surface Resized size=%d,%d, surfaceInfo->iSize=%d,%d",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   918
				size.iHeight, size.iWidth, surfaceInfo->iSize.iHeight, surfaceInfo->iSize.iWidth);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   919
        return EglInternalFunction_SurfaceResized(aThreadState, *surfaceInfo, aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   920
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   921
    return EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   922
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   923
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   924
EGLBoolean CGuestEGL::eglMakeCurrent(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aDraw, EGLSurface aRead, EGLContext aContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   925
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   926
	if (aContext == EGL_NO_CONTEXT)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   927
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   928
		if ( (aDraw != EGL_NO_SURFACE) || (aRead != EGL_NO_SURFACE) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   929
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   930
			aThreadState.SetEglError(EGL_BAD_SURFACE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   931
			return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   932
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   933
		EGL_TRACE("CGuestEGL::eglMakeCurrent call host");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   934
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   935
		eglApiData.Init( EglRFC::EeglMakeCurrent );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   936
		eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   937
		eglApiData.AppendEGLSurface(EGL_NO_SURFACE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   938
		eglApiData.AppendEGLSurface(EGL_NO_SURFACE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   939
		eglApiData.AppendEGLContext(EGL_NO_CONTEXT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   940
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   941
		EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   942
		EGL_TRACE("CGuestEGL::eglMakeCurrent end success=%d", ret);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   943
		return (EGLBoolean)ret;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   944
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   945
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   946
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   947
		if ( (aDraw == EGL_NO_SURFACE) || (aRead == EGL_NO_SURFACE) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   948
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   949
			aThreadState.SetEglError(EGL_BAD_SURFACE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   950
			return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   951
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   952
		// ToDo use new CEglContext code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   953
		const TInt KMaxSurfaces( 2 );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   954
		EGLSurface surfaces[KMaxSurfaces];
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   955
		TSurfaceInfo* surfaceInfo[KMaxSurfaces] = {NULL, NULL};
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   956
		surfaces[0] = aDraw;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   957
		if (aDraw != aRead)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   958
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   959
			surfaces[1] = aRead;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   960
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   961
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   962
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   963
			surfaces[1] = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   964
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   965
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   966
		for ( TInt i = 0; i < KMaxSurfaces; i++ )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   967
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   968
			if ( EGL_NO_SURFACE != surfaces[i] )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   969
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   970
				EGL_TRACE("CGuestEGL::eglMakeCurrent check surface %d", surfaces[i] );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   971
				surfaceInfo[i] = EglInternalFunction_GetPlatformSurface( aDisplay, surfaces[i] );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   972
				//EGL_CHECK_ERROR( surfaceInfo, EGL_BAD_SURFACE , EGL_FALSE );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   973
				if ( surfaceInfo[i] )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   974
					{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   975
					TSize newSize;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   976
					switch (surfaceInfo[i]->iSurfaceType)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   977
						{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   978
						case ESurfaceTypePixmapFbsBitmap:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   979
							EGLPANIC_ASSERT_DEBUG(surfaceInfo[i]->iFbsBitmap, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   980
							newSize = surfaceInfo[i]->iFbsBitmap->SizeInPixels();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   981
							break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   982
						case ESurfaceTypeWindow:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   983
							EGLPANIC_ASSERT_DEBUG(surfaceInfo[i]->iNativeWindow, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   984
							newSize = surfaceInfo[i]->iNativeWindow->Size();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   985
							break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   986
						default:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   987
							// size cannot change for other surface types
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   988
							newSize = surfaceInfo[i]->iSize;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   989
							break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   990
						}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   991
					if (newSize != surfaceInfo[i]->iSize)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   992
						{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   993
						EGL_TRACE("CGuestEGL::eglMakeCurrent resize surface");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   994
						if ( !EglInternalFunction_SurfaceResized(aThreadState, *surfaceInfo[i], aDisplay, surfaces[i] ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   995
							{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   996
							return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   997
							}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   998
						surfaceInfo[i]->iSize = newSize;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   999
						}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1000
					}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1001
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1002
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1003
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1004
		// adapt to only some surfaces having CEglSurfaceInfo objects so far 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1005
		EGLSurface drawId = surfaceInfo[0] ? surfaceInfo[0]->iHostSurfaceId : aDraw;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1006
		EGLSurface readId = aRead;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1007
		if ((aRead == aDraw) && surfaceInfo[0])
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1008
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1009
			readId = surfaceInfo[0]->iHostSurfaceId;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1010
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1011
		else if (surfaceInfo[1])
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1012
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1013
			readId = surfaceInfo[1]->iHostSurfaceId;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1014
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1015
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1016
		EGL_TRACE("  eglMakeCurrent surfaces[0]=0x%x, surfaces[1]=0x%x", surfaces[0], surfaces[1]);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1017
		EGL_TRACE("  eglMakeCurrent surfacesInfo[0]=0x%x, surfacesInfo[0].iHostSurfaceId=0x%x",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1018
				surfaceInfo[0], surfaceInfo[0] ? surfaceInfo[0]->iHostSurfaceId : NULL);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1019
		EGL_TRACE("  eglMakeCurrent surfacesInfo[1]=0x%x, surfacesInfo[1].iHostSurfaceId=0x%x",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1020
				surfaceInfo[1], surfaceInfo[1] ? surfaceInfo[1]->iHostSurfaceId : NULL);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1021
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1022
		EGL_TRACE("CGuestEGL::eglMakeCurrent call host");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1023
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1024
		eglApiData.Init( EglRFC::EeglMakeCurrent );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1025
		eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1026
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1027
		EGL_TRACE("  eglApiData.AppendEGLSurface(drawId = 0x%x)", drawId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1028
		eglApiData.AppendEGLSurface(drawId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1029
		EGL_TRACE("  eglApiData.AppendEGLSurface(readId = 0x%x);", readId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1030
		eglApiData.AppendEGLSurface(readId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1031
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1032
		eglApiData.AppendEGLContext(aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1033
		EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1034
		EGL_TRACE("CGuestEGL::eglMakeCurrent end success=%d", ret);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1035
		return (EGLBoolean)ret;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1036
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1037
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1038
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1039
// FAISALMEMON HOLE 0.1
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1040
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1041
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1042
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1043
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1044
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1045
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1046
TBool CGuestEGL::EglInternalFunction_CreateSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLConfig aConfig, RWindow* aNativeWindow,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1047
		TSurfaceInfo& aSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1048
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1049
    RSurfaceManager::TSurfaceCreationAttributesBuf attributes;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1050
    RSurfaceManager::TInfoBuf info;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1051
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1052
    aSurfaceInfo.iNativeWindow = aNativeWindow;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1053
    aSurfaceInfo.iSurfaceType = ESurfaceTypeWindow;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1054
    aSurfaceInfo.iSize = aNativeWindow->Size();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1055
    aSurfaceInfo.iConfigId = aConfig;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1056
	aSurfaceInfo.iHostSurfaceId = aSurface;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1057
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1058
    // ToDo have function variants that do not validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1059
    eglQuerySurface(aThreadState, aDisplay, aSurface, EGL_VG_ALPHA_FORMAT, &aSurfaceInfo.iAlphaFormat);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1060
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BUFFER_SIZE, &aSurfaceInfo.iColorBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1061
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_RED_SIZE, &aSurfaceInfo.iRedBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1062
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_GREEN_SIZE, &aSurfaceInfo.iGreenBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1063
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BLUE_SIZE, &aSurfaceInfo.iBlueBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1064
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_ALPHA_SIZE, &aSurfaceInfo.iAlphaBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1065
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1066
    /*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1067
    TInt err = LastError();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1068
    EGL_CHECK_ERROR( EGL_SUCCESS == err, err, EGL_FALSE );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1069
    */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1070
    EGL_TRACE("  Win surface details: width=%d height=%d colorbits=%d red=%d green=%d blue=%d alpha=%d alphaformat=0x%x",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1071
    		aSurfaceInfo.iSize.iWidth, aSurfaceInfo.iSize.iHeight, aSurfaceInfo.iColorBits, aSurfaceInfo.iRedBits,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1072
    		aSurfaceInfo.iGreenBits, aSurfaceInfo.iBlueBits, aSurfaceInfo.iAlphaBits, aSurfaceInfo.iAlphaFormat);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1073
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1074
    TSize size;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1075
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1076
    // FAISALMEMON HOLE 1
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1077
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1078
    // FAISALMEMON STUB CODE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1079
    TUint8 offsetToFirstBuffer = 0; // This is wrong; just stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1080
    TUint8 offsetToSecondBuffer = 0; // This is wrong; just stub code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1081
    // FAISALMEMON END OF STUB CODE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1082
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1083
    TUint32 chunkHWBase = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1084
    (void)CVghwUtils::MapToHWAddress(aSurfaceInfo.iChunk->Handle(), chunkHWBase);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1085
    // FAISALMEMON write code to handle errors in the above function
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1086
    EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface AFTER VGHWUtils::MapToHWAddress");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1087
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1088
    /* Store the pointer to the pixel data */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1089
    aSurfaceInfo.iBuffer0 = aSurfaceInfo.iChunk->Base() + offsetToFirstBuffer;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1090
    aSurfaceInfo.iBuffer1 = aSurfaceInfo.iChunk->Base() + offsetToSecondBuffer;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1091
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1092
    aSurfaceInfo.iBuffer0Index = (chunkHWBase + offsetToFirstBuffer) - VVI_FRAMEBUFFER_BASE_ADDRESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1093
    aSurfaceInfo.iBuffer1Index = (chunkHWBase + offsetToSecondBuffer) - VVI_FRAMEBUFFER_BASE_ADDRESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1094
    EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface %u %x %x %x %x",chunkHWBase, offsetToFirstBuffer, offsetToSecondBuffer,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1095
    		aSurfaceInfo.iBuffer0Index,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1096
    		aSurfaceInfo.iBuffer1Index);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1097
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1098
    if ( !EglInternalFunction_CallSetSurfaceParams(aThreadState, aDisplay, aSurface, aSurfaceInfo) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1099
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1100
        EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface end failure");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1101
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1102
        return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1103
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1104
    EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface end success");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1105
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1106
    return EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1107
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1108
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1109
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1110
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1111
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1112
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1113
EGLBoolean CGuestEGL::eglDestroySurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1114
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1115
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1116
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1117
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1118
	// do not destroy SgImage surfaces on the Host!
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1119
	TSurfaceInfo* surfaceInfo = EglInternalFunction_GetPlatformSurface(aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1120
	if (!surfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1121
		{ // Note: Pbuffer surfaces are not currently recorded in client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1122
		eglApiData.Init( EglRFC::EeglDestroySurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1123
		eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1124
		eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1125
		result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1126
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1127
	else 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1128
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1129
		if (surfaceInfo->iSurfaceType != ESurfaceTypePixmapSgImage)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1130
			{ // destroy surface allocated by Host EGL 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1131
			eglApiData.Init( EglRFC::EeglDestroySurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1132
			eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1133
			eglApiData.AppendEGLSurface(surfaceInfo->iHostSurfaceId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1134
			result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1135
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1136
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1137
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1138
			{ // release SgImage handle
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1139
			surfaceInfo->iSgHandle.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1140
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1141
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1142
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1143
		DestroySurfaceInfo(aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1144
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1145
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1146
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1147
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1148
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1149
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1150
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1151
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1152
void CGuestEGL::DestroySurfaceInfo(EGLDisplay aDisplay, EGLSurface aSurface)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1153
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1154
    EGL_TRACE("DestroySurfaceInfo begin");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1155
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1156
    iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1157
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1158
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1159
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1160
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1161
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1162
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1163
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1164
		TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1165
		if (!pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1166
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1167
			EGL_TRACE("cannot find surface %d for display %d", aSurface, aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1168
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1169
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1170
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1171
			TSurfaceInfo* surfaceInfo = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1172
			RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1173
			if (surfaceInfo->iNativeWindow)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1174
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1175
				EglInternalFunction_DestroyWindowSurface(*surfaceInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1176
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1177
			delete surfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1178
			(*pDispInfo)->iSurfaceMap.Remove( aSurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1179
			CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1180
			EGL_TRACE("DestroySurfaceInfo end");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1181
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1182
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1183
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1184
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1185
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1186
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1187
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1188
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1189
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1190
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1191
TBool CGuestEGL::DestroyDisplayInfo (EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1192
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1193
    EGL_TRACE("DestroyDisplayInfo begin aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1194
    TBool success = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1195
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1196
	iDisplayMapLock.WriteLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1197
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1198
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1199
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1200
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1201
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1202
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1203
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1204
		success = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1205
		RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1206
		RHashMap<TInt, TSurfaceInfo*>::TIter iter((*pDispInfo)->iSurfaceMap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1207
		for (;;)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1208
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1209
			TSurfaceInfo** pSurfaceInfo = const_cast<TSurfaceInfo**>(iter.NextValue());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1210
			if (!pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1211
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1212
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1213
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1214
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1215
			EGL_TRACE("destroying surface %d", *iter.CurrentKey());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1216
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1217
			TSurfaceInfo* surfaceInfo = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1218
			if (surfaceInfo->iNativeWindow)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1219
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1220
				EglInternalFunction_DestroyWindowSurface(*surfaceInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1221
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1222
			delete surfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1223
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1224
		iDisplayMap.Remove(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1225
		CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1226
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1227
		//added for egl sync extension benefit
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1228
		if (iEglSyncExtension)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1229
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1230
			iEglSyncExtension->EglSyncDisplayDestroy(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1231
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1232
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1233
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1234
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1235
	EGL_TRACE("DestroyDisplayInfo end - ret=%d", success);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1236
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1237
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1238
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1239
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1240
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1241
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1242
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1243
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1244
EGLBoolean CGuestEGL::EglInternalFunction_CallSetSurfaceParams(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, TSurfaceInfo& aSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1245
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1246
    EGL_TRACE("EglInternalFunction_CallSetSurfaceParams begin");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1247
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1248
    RemoteFunctionCallData rfcdata;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1249
    EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1250
    eglApiData.Init(EglRFC::EeglSimulatorSetSurfaceParams);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1251
    eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1252
    eglApiData.AppendEGLSurface( aSurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1253
    EGLNativeWindowType win = (EGLNativeWindowType)aSurfaceInfo.iNativeWindow->ClientHandle();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1254
    eglApiData.AppendEGLNativeWindowType( win );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1255
    eglApiData.AppendEGLSize(aSurfaceInfo.iSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1256
    eglApiData.AppendEGLint(aSurfaceInfo.iStride);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1257
    eglApiData.AppendEGLint(aSurfaceInfo.iBuffer0Index);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1258
    eglApiData.AppendEGLint(aSurfaceInfo.iBuffer1Index);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1259
    aThreadState.ExecuteEglNeverErrorCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1260
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1261
    EGL_TRACE("EglInternalFunction_CallSetSurfaceParams end");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1262
    return EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1263
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1264
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1265
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1266
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1267
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1268
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1269
EGLint CGuestEGL::ConfigMatchesFbsBitmapPixmap(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, const EGLint* aAttribList, TDisplayMode aMode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1270
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1271
	// ToDo check EGL_VG_ALPHA_FORMAT ?
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1272
	EGLint colorBits, redBits, greenBits, blueBits, alphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1273
	EGLint wantColorBits, wantRedBits, wantGreenBits, wantBlueBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1274
	EGLint wantAlphaBits = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1275
	switch (aMode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1276
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1277
		case EColor64K:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1278
			wantColorBits = 12;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1279
			wantRedBits = 5;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1280
			wantGreenBits = 6;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1281
			wantBlueBits = 5;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1282
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1283
		case EColor16M:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1284
		case EColor16MU:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1285
			wantColorBits = 24;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1286
			wantRedBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1287
			wantGreenBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1288
			wantBlueBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1289
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1290
		case EColor16MA:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1291
			wantColorBits = 32;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1292
			wantRedBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1293
			wantGreenBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1294
			wantBlueBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1295
			wantAlphaBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1296
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1297
		case EColor16MAP:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1298
			wantColorBits = 32;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1299
			wantRedBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1300
			wantGreenBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1301
			wantBlueBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1302
			wantAlphaBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1303
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1304
		default: // pixmap format not supported
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1305
			return EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1306
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1307
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1308
	// ToDo version of these functions lighter on parameter checking - maybe use cached values
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1309
	if (!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BUFFER_SIZE, &colorBits) || 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1310
			!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_RED_SIZE, &redBits) ||
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1311
			!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_GREEN_SIZE, &greenBits) ||
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1312
			!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BLUE_SIZE, &blueBits) ||
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1313
			!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_ALPHA_SIZE, &alphaBits) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1314
		{ // fetch failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1315
		return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1316
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1317
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1318
	EGL_TRACE("CGuestEGL::ConfigMatchesFbsBitmapPixmap: want %d bpp, %d red, %d green, %d blue, %d alpha\n\tconfig has %d bpp, %d red, %d green, %d blue, %d alpha",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1319
			wantColorBits, wantRedBits, wantGreenBits, wantBlueBits, wantAlphaBits,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1320
			colorBits, redBits, greenBits, blueBits, alphaBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1321
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1322
	if ( (colorBits < wantColorBits) || (redBits < wantRedBits) || (greenBits < wantGreenBits) ||
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1323
			(blueBits < wantBlueBits) || (alphaBits < wantAlphaBits) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1324
		{ // config does not match bitmap
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1325
		return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1326
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1327
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1328
	return EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1329
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1330
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1331
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1332
 Returns EGL_NO_SURFACE on failure. If the attributes of pixmap do not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1333
 correspond to config, then an EGL_BAD_MATCH error is generated. If config does
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1334
 not support rendering to pixmaps (the EGL_SURFACE_TYPE attribute does not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1335
 contain EGL_PIXMAP_BIT), an EGL_BAD_MATCH error is generated. If config does
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1336
 not support the colorspace or alpha format attributes specified in attrib list
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1337
 (as defined for eglCreateWindowSurface), an EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1338
 If config is not a valid EGLConfig, an EGL_BAD_CONFIG error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1339
 pixmap is not a valid native pixmap handle, then an EGL_BAD_NATIVE_PIXMAP
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1340
 error should be generated. If there is already an EGLSurface associated with
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1341
 pixmap (as a result of a previous eglCreatePixmapSurface call), then a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1342
 EGL_BAD_ALLOC error is generated. Finally, if the implementation cannotallocate
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1343
 resources for the new EGL pixmap, an EGL_BAD_ALLOC error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1344
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1345
EGLSurface CGuestEGL::eglCreatePixmapSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, EGLNativePixmapType aNativePixmap, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1346
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1347
	EGL_TRACE( "CGuestEGL::eglCreatePixmapSurface");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1348
	EGL_TRACE_ATTRIB_LIST(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1349
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1350
	EGLSurface newSurfaceId = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1351
	TSurfaceInfo* surfaceInfo = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1352
	EGLint error = EGL_BAD_DISPLAY;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1353
	TSymbianPixmapTypeId pixmapType = EPixmapTypeNone;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1354
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1355
	const EGLint* pixmapMatch = TAttribUtils::FindAttribValue(aAttribList, EGL_MATCH_NATIVE_PIXMAP);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1356
	if ( pixmapMatch && ( (*pixmapMatch) != (EGLint)(aNativePixmap) ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1357
		{ // if EGL_MATCH_NATIVE_PIXMAP is in the attribute list it must be the same pixmap as aNativePixmap
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1358
		error = EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1359
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1360
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1361
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1362
		iDisplayMapLock.WriteLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1363
		CEglDisplayInfo** pDispInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1364
		pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1365
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1366
		if (pDispInfo && *pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1367
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1368
			RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1369
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1370
			surfaceInfo = new TSurfaceInfo();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1371
			if (surfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1372
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1373
				surfaceInfo->iConfigId = aConfig;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1374
				pixmapType = EglInternalFunction_GetNativePixmapType(aNativePixmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1375
				switch (pixmapType)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1376
					{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1377
					case EPixmapTypeFbsBitmap:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1378
						newSurfaceId = CreateFbsBitmapSurface(aThreadState, aDisplay, aConfig, reinterpret_cast<CFbsBitmap*>(aNativePixmap), aAttribList,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1379
								*surfaceInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1380
						break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1381
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1382
					case EPixmapTypeSgImage:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1383
						newSurfaceId = CreateSgImageSurface(aThreadState, aDisplay, aConfig, reinterpret_cast<const RSgImage*>(aNativePixmap), aAttribList,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1384
								*surfaceInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1385
						break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1386
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1387
					default:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1388
						break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1389
					}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1390
				if (newSurfaceId == EGL_NO_SURFACE)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1391
					{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1392
					error = EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1393
					}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1394
				else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1395
					{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1396
					error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1397
					EGL_TRACE( "CGuestEGL::eglCreatePixmapSurface inserting surface 0x%x to display %d", newSurfaceId, aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1398
					if (KErrNone != (*pDispInfo)->iSurfaceMap.Insert(newSurfaceId, surfaceInfo))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1399
						{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1400
						error = EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1401
						if (pixmapType == EPixmapTypeFbsBitmap)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1402
							{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1403
							(void) eglDestroySurface(aThreadState, aDisplay, newSurfaceId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1404
							}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1405
						newSurfaceId = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1406
						}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1407
					}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1408
				if (error != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1409
					{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1410
					delete surfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1411
					surfaceInfo = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1412
					}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1413
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1414
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1415
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1416
				error = EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1417
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1418
			CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1419
			}  // dispInfo
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1420
		iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1421
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1422
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1423
	aThreadState.SetEglError(error);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1424
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1425
	// parameter check failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1426
	if (error != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1427
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1428
		EGLPANIC_ASSERT_DEBUG(newSurfaceId == EGL_NO_SURFACE, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1429
		EGLPANIC_ASSERT_DEBUG(surfaceInfo == NULL, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1430
		return EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1431
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1432
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1433
	EGLPANIC_ASSERT_DEBUG(newSurfaceId != EGL_NO_SURFACE, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1434
	EGLPANIC_ASSERT_DEBUG(surfaceInfo != NULL, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1435
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1436
	return newSurfaceId;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1437
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1438
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1439
EGLSurface CGuestEGL::CreateFbsBitmapSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, CFbsBitmap* aBitmap,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1440
		const EGLint *aAttribList, TSurfaceInfo& aSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1441
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1442
	EGLSurface newSurfaceId = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1443
	aSurfaceInfo.iSurfaceType = ESurfaceTypePixmapFbsBitmap;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1444
	aSurfaceInfo.iFbsBitmap = aBitmap;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1445
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1446
	TDisplayMode mode = ENone;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1447
	TInt stride;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1448
	aSurfaceInfo.iSize = aBitmap->SizeInPixels(); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1449
	EGL_TRACE("CGuestEGL::CreateFbsBitmapSurface image width=%d, height=%d", aSurfaceInfo.iSize.iWidth, aSurfaceInfo.iSize.iHeight);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1450
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1451
	// check that a pixmap surface has not previously been created from this CFbsBitmap
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1452
	if (!EglInternalFunction_PixmapSurfacePreviouslyCreated(aBitmap, EPixmapTypeFbsBitmap))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1453
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1454
		// error = EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1455
		return EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1456
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1457
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1458
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1459
		mode = aBitmap->DisplayMode();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1460
		if (EGL_SUCCESS != ConfigMatchesFbsBitmapPixmap(aThreadState, aDisplay, aConfig, aAttribList, mode))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1461
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1462
			return EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1463
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1464
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1465
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1466
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1467
	stride = CFbsBitmap::ScanLineLength(aSurfaceInfo.iSize.iWidth, mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1468
	eglApiData.Init( EglRFC::EeglCreatePixmapSurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1469
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1470
	eglApiData.AppendEGLConfig(aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1471
	eglApiData.AppendEGLNativePixmapType((EGLNativePixmapType) aBitmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1472
	eglApiData.AppendEGLint(mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1473
	eglApiData.AppendEGLSize(aSurfaceInfo.iSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1474
	eglApiData.AppendEGLint(stride);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1475
	eglApiData.AppendEGLint(EPixmapTypeFbsBitmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1476
	eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList));
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1477
	newSurfaceId = aThreadState.ExecEglSurfaceCmd(eglApiData); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1478
	EGL_TRACE( "EeglCreatePixmapSurface aDisplay=%d, config=%d, format=%d, width=%d, height=%d, stride=%d, pixmapType=%d, newSurface=%d",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1479
			aDisplay, aConfig, mode, aSurfaceInfo.iSize.iWidth, aSurfaceInfo.iSize.iHeight, stride, EPixmapTypeFbsBitmap, newSurfaceId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1480
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1481
	aSurfaceInfo.iHostSurfaceId = newSurfaceId;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1482
	return newSurfaceId;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1483
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1484
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1485
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1486
EGLSurface CGuestEGL::CreateSgImageSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, const RSgImage* aSgImage,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1487
		const EGLint *aAttribList, TSurfaceInfo& aSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1488
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1489
	// ToDo check that the SgImage is not already being used for a surface or EglImage
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1490
	aSurfaceInfo.iSurfaceType = ESurfaceTypePixmapSgImage;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1491
	aSurfaceInfo.iSgId = aSgImage->Id();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1492
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1493
    EGL_TRACE("CGuestEGL::CreateSgImageSurface sgImage id 0x%lx", aSurfaceInfo.iSgId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1494
	TSgImageInfo imgInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1495
	// ToDo ensure SgImage has correct suitable usage bits 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1496
	if ( (aSurfaceInfo.iSgId != KSgNullDrawableId) && (KErrNone == aSurfaceInfo.iSgHandle.Open(aSurfaceInfo.iSgId)) &&
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1497
			(KErrNone == aSgImage->GetInfo(imgInfo)) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1498
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1499
		EGL_TRACE("CGuestEGL::CreateSgImageSurface 1. SgImage PixelFormat=%d; size=%d,%d; Usage=0x%x",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1500
				imgInfo.iPixelFormat, imgInfo.iSizeInPixels.iWidth, imgInfo.iSizeInPixels.iHeight, imgInfo.iUsage);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1501
		aSurfaceInfo.iSize = imgInfo.iSizeInPixels;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1502
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1503
        /* Package the handles to 64-bit value, since there's only one parameter available.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1504
           pbufferHandle is the lower 32 bits, VGImageHandle is the upper bits. */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1505
        TUint64 sgHandles;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1506
		EGLint hostResult = CVghwUtils::EglGetSgHandles(aSurfaceInfo.iSgId.iId, &sgHandles);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1507
		EGL_TRACE("CGuestEGL::CreateSgImageSurface 2. EglGetSgHandles result=%d, sgHandles=0x%lx", hostResult, sgHandles);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1508
		aSurfaceInfo.iHostSurfaceId = (EGLSurface)(sgHandles&0xFFFFFFFF);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1509
		return aSurfaceInfo.iHostSurfaceId;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1510
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1511
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1512
	aSurfaceInfo.iSgHandle.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1513
	return EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1514
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1515
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1516
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1517
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1518
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1519
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1520
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1521
TSurfaceInfo* CGuestEGL::EglInternalFunction_GetPlatformSurface( EGLDisplay display, EGLSurface surface )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1522
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1523
	EGL_TRACE( "CGuestEGL::EglInternalFunction_GetPlatformSurface");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1524
	TSurfaceInfo* result = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1525
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1526
	iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1527
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1528
	CEglDisplayInfo** pDispInfo = iDisplayMap.Find( display );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1529
	if (pDispInfo && *pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1530
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1531
		TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find( surface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1532
		if (pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1533
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1534
			result = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1535
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1536
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1537
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1538
	// TODO on success should probably Unlock() the surface in the caller
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1539
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1540
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1541
	/* TODO review calling code, to see if this suggestion makes sense
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1542
	if (result == NULL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1543
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1544
		EGL_RAISE_ERROR( EGL_BAD_SURFACE, NULL); //Enable this when all surfaces are in surface map
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1545
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1546
		*/
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1547
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1548
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1549
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1550
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1551
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1552
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1553
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1554
EGLBoolean CGuestEGL::eglWaitClient(TEglThreadState& aThreadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1555
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1556
	EGL_TRACE( "CGuestEGL::eglWaitClient");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1557
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1558
	eglApiData.Init(EglRFC::EeglWaitClient);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1559
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1560
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1561
	if (result)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1562
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1563
		// ToDo cache in client, check results are not EGL_NO_DISPLAY / EGL_NO_SURFACE 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1564
		EGLDisplay display = eglGetCurrentDisplay(aThreadState);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1565
		EGLSurface surface = eglGetCurrentSurface(aThreadState, EGL_DRAW);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1566
		iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1567
		CEglDisplayInfo** pDispInfo = iDisplayMap.Find( display );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1568
		TSurfaceInfo* surfaceInfo = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1569
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1570
		if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1571
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1572
			EGL_TRACE( "cannot find display %d", display );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1573
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1574
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1575
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1576
			TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find( surface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1577
			if (!pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1578
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1579
				EGL_TRACE( "cannot find surface %d for display %d", surface, display );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1580
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1581
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1582
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1583
				surfaceInfo = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1584
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1585
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1586
		iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1587
		if (surfaceInfo == NULL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1588
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1589
			return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1590
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1591
		if (surfaceInfo->iSurfaceType == ESurfaceTypePixmapFbsBitmap)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1592
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1593
			EGLPANIC_ASSERT_DEBUG(surfaceInfo->iFbsBitmap, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1594
			surfaceInfo->iFbsBitmap->BeginDataAccess();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1595
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1596
			RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1597
			eglApiData.Init( EglRFC::EeglSimulatorCopyImageData );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1598
			const TSize sizePixels( surfaceInfo->iFbsBitmap->Header().iSizeInPixels );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1599
			eglApiData.AppendVector( (void*)surfaceInfo->iFbsBitmap->DataAddress(),
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1600
			CFbsBitmap::ScanLineLength( sizePixels.iWidth, surfaceInfo->iFbsBitmap->DisplayMode() )*sizePixels.iHeight,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1601
				RemoteFunctionCallData::EOut );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1602
			aThreadState.ExecuteEglNeverErrorCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1603
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1604
			surfaceInfo->iFbsBitmap->EndDataAccess();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1605
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1606
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1607
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1608
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1609
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1610
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1611
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1612
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1613
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1614
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1615
EGLSurface CGuestEGL::eglGetCurrentSurface(TEglThreadState& aThreadState, EGLint aReadDraw)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1616
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1617
	// ToDo cache in client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1618
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1619
	eglApiData.Init(EglRFC::EeglGetCurrentSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1620
	eglApiData.AppendEGLint(aReadDraw);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1621
	return ExecEglSurfaceNoErrorCmd(aThreadState, eglApiData); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1622
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1623
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1624
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1625
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1626
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1627
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1628
EGLDisplay CGuestEGL::eglGetCurrentDisplay(TEglThreadState& aThreadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1629
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1630
	// ToDo cache in client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1631
	EGL_TRACE("CGuestEGL::eglGetCurrentDisplay");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1632
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1633
	eglApiData.Init(EglRFC::EeglGetCurrentDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1634
	return ExecEglDisplayNoErrorCmd(aThreadState, eglApiData); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1635
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1636
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1637
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1638
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1639
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1640
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1641
EGLBoolean CGuestEGL::eglCopyBuffers(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLNativePixmapType aTarget)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1642
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1643
	TSize pixmapSize;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1644
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1645
	EGL_TRACE("CGuestEGL::eglCopyBuffers");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1646
	EGLBoolean hostResult = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1647
	TSymbianPixmapTypeId targetPixmapType = EglInternalFunction_GetNativePixmapType(aTarget);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1648
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1649
	// Only CFbsBitmap native pixmaps are supported by this API.  (SgImages are not supported, as per the SgImsge Lite spec.)  
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1650
	if ( (targetPixmapType == EPixmapTypeFbsBitmap) && EglInternalFunction_IsValidNativePixmap(aTarget, targetPixmapType) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1651
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1652
		RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1653
		CFbsBitmap* bitmap = (CFbsBitmap*)aTarget;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1654
		TSize pixmapSize = bitmap->SizeInPixels(); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1655
		bitmap->BeginDataAccess();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1656
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1657
		TDisplayMode mode = bitmap->DisplayMode();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1658
		EGLint stride = CFbsBitmap::ScanLineLength(bitmap->Header().iSizeInPixels.iWidth, mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1659
		void* data = bitmap->DataAddress();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1660
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1661
#ifdef _DEBUG
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1662
		char* modeName = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1663
		switch (mode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1664
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1665
			case ENone: modeName = "ENone"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1666
			case EGray2: modeName = "EGray2"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1667
			case EGray4: modeName = "EGray4"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1668
			case EGray16: modeName = "EGray16"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1669
			case EGray256: modeName = "EGray256"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1670
			case EColor16: modeName = "EColor16"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1671
			case EColor256: modeName = "EColor256"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1672
			case EColor64K: modeName = "EColor64K"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1673
			case EColor16M: modeName = "EColor16M"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1674
			case ERgb: modeName = "ERgb"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1675
			case EColor4K: modeName = "EColor4K"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1676
			case EColor16MU: modeName = "EColor16MU"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1677
			case EColor16MA: modeName = "EColor16MA"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1678
			case EColor16MAP: modeName = "EColor16MAP"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1679
			case EColorLast: modeName = "EColorLast"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1680
			default: modeName = "unknown"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1681
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1682
		EGL_TRACE("EglInternalFunction_GetNativePixmapInfo (0x%x) -> CFbsBitmap: DisplayMode=%d (\"%s\"), ScanLineLength=%d, data addr=0x%x",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1683
				bitmap, mode, modeName, stride, data);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1684
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1685
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1686
		eglApiData.Init(EglRFC::EeglCopyBuffers);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1687
		eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1688
		eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1689
		const TSize sizePixels( bitmap->Header().iSizeInPixels );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1690
		eglApiData.AppendVector((void*)bitmap->DataAddress(), 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1691
				stride*pixmapSize.iHeight,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1692
				RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1693
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1694
		eglApiData.AppendEGLint((EGLint) mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1695
		eglApiData.AppendEGLSize(pixmapSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1696
		eglApiData.AppendEGLint(stride);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1697
		eglApiData.AppendEGLint(targetPixmapType);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1698
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1699
		hostResult = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1700
		bitmap->EndDataAccess();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1701
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1702
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1703
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1704
		aThreadState.SetEglError(EGL_BAD_NATIVE_PIXMAP);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1705
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1706
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1707
	return hostResult;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1708
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1709
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1710
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1711
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1712
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1713
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1714
// Beware odd logic: EFalse if surface is found, otherwise ETrue
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1715
TBool CGuestEGL::EglInternalFunction_PixmapSurfacePreviouslyCreated(EGLNativePixmapType pixmap, TSymbianPixmapTypeId pixmapType)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1716
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1717
	// ToDo keep a hashmap of pixmap addresses currently used for surfaces
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1718
	TBool result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1719
    if(pixmapType == EPixmapTypeFbsBitmap)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1720
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1721
		iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1722
        RHashMap<TInt, CEglDisplayInfo*>::TIter iter( iDisplayMap );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1723
        for (;;)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1724
            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1725
            CEglDisplayInfo** pDispInfo = const_cast<CEglDisplayInfo**>(iter.NextValue());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1726
            if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1727
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1728
                break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1729
                }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1730
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1731
            RHashMap<TInt, TSurfaceInfo*>::TIter iter2((*pDispInfo)->iSurfaceMap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1732
            for (;;)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1733
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1734
                TSurfaceInfo** pSurfaceInfo = const_cast<TSurfaceInfo**>(iter2.NextValue());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1735
                if (!pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1736
                    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1737
                    break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1738
                    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1739
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1740
                TSurfaceInfo* surfaceInfo = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1741
                if ( (surfaceInfo->iSurfaceType == ESurfaceTypePixmapFbsBitmap) && (surfaceInfo->iFbsBitmap == pixmap) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1742
                    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1743
                    result = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1744
                    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1745
                }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1746
            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1747
		iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1748
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1749
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1750
	EGL_TRACE("CGuestEGL::EglInternalFunction_PixmapSurfacePreviouslyCreated %d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1751
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1752
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1753
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1754
// FAISALMEMON HOLE 2
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1755
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1756
EGLDisplay CGuestEGL::eglGetDisplay(TEglThreadState& aThreadState, EGLNativeDisplayType aDisplayId)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1757
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1758
	RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1759
	eglApiData.Init(EglRFC::EeglGetDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1760
	eglApiData.AppendEGLNativeDisplayType(aDisplayId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1761
	EGLDisplay display = ExecEglDisplayNoErrorCmd(aThreadState, eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1762
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1763
	if (display != EGL_NO_DISPLAY)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1764
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1765
		if (!CreateDisplayInfo(display))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1766
			{ // alloc failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1767
			display = EGL_NO_DISPLAY;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1768
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1769
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1770
	return display;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1771
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1772
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1773
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1774
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1775
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1776
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1777
EGLint CGuestEGL::InitialiseExtensions()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1778
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1779
	iEglSyncExtension = CEglSyncExtension::Create(*this);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1780
	return EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1781
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1782
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1783
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1784
// API supporting EGL sync extension
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1785
// lock the display once found
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1786
EGLint CGuestEGL::FindAndLockDisplay(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1787
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1788
	EGLint result = EGL_BAD_DISPLAY;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1789
	EGL_TRACE("CGuestEGL::FindAndLockDisplay aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1790
	iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1791
	CEglDisplayInfo** pDisp = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1792
	if (pDisp && *pDisp)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1793
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1794
		CEglDisplayInfo* disp = *pDisp;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1795
		if (disp->iInitialized)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1796
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1797
			EGL_TRACE("CGuestEGL::FindAndLockDisplay display found");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1798
			result = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1799
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1800
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1801
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1802
			EGL_TRACE("CGuestEGL::FindAndLockDisplay display not initialized");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1803
			result = EGL_NOT_INITIALIZED;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1804
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1805
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1806
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1807
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1808
		EGL_TRACE("CGuestEGL::FindAndLockDisplay cannot find display");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1809
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1810
	if (result != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1811
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1812
		iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1813
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1814
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1815
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1816
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1817
// release the lock
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1818
void CGuestEGL::ReleaseDisplayLock(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1819
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1820
	EGL_TRACE("CGuestEGL::ReleaseDisplayLock aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1821
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1822
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1823
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1824
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1825
CEglSyncExtension* CGuestEGL::EGLSyncExtension()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1826
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1827
    return iEglSyncExtension;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1828
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1829
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1830
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1831
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1832
 EGL_FALSE is returned on failure and major and minor are not updated. An
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1833
 EGL_BAD_DISPLAY error is generated if the dpy argument does not refer to a valid
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1834
 EGLDisplay. An EGL_NOT_INITIALIZED error is generated if EGL cannot be
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1835
 initialized for an otherwise valid dpy.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1836
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1837
EGLBoolean CGuestEGL::eglInitialize(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLint *aMajor, EGLint *aMinor)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1838
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1839
	if ((aDisplay == EGL_NO_DISPLAY) || !InitializeDisplayInfo(aDisplay))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1840
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1841
		aThreadState.SetEglError(EGL_BAD_DISPLAY);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1842
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1843
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1844
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1845
	RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1846
	eglApiData.Init(EglRFC::EeglInitialize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1847
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1848
	EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1849
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1850
	if(ret)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1851
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1852
		if(aMajor)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1853
			*aMajor = EGL_VERSION_MAJOR;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1854
		if(aMinor)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1855
			*aMinor = EGL_VERSION_MINOR;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1856
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1857
	EGL_TRACE("eglInitialize <-" );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1858
	return ret;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1859
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1860
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1861
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1862
 Returns EGL_FALSE on failure and value is not updated. If attribute is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1863
 valid EGL surface attribute, then an EGL_BAD_ATTRIBUTE error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1864
 surface is not a valid EGLSurface then an EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1865
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1866
EGLBoolean CGuestEGL::eglQuerySurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLint aAttribute, EGLint *aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1867
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1868
	// ToDo more parameter validation, and possibly use cached values
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1869
	if ( (aValue == NULL) || (3 & (TUint32)aValue) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1870
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1871
		aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1872
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1873
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1874
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1875
	eglApiData.Init(EglRFC::EeglQuerySurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1876
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1877
	eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1878
	eglApiData.AppendEGLint(aAttribute);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1879
	eglApiData.AppendEGLintVector(aValue, 1, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1880
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1881
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1882
	EGL_TRACE_GET_ATTRIB("eglQuerySurface", "surface", aDisplay, aSurface, aAttribute, aValue, result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1883
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1884
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1885
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1886
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1887
 On failure eglCreatePbufferFromClientBuffer returns EGL_NO_SURFACE. In
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1888
 addition to the errors described eglCreatePbufferSurface,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1889
 eglCreatePbufferFromClientBuffer may fail and generate errors for the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1890
 following reasons:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1891
 * If buftype is not a recognized client API resource type (e.g. is not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1892
   EGL_OPENVG_IMAGE), an EGL_BAD_PARAMETER error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1893
 * If buffer is not a valid handle or name of a client API resource of the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1894
   specified buftype in the currently bound context corresponding to that
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1895
   type, an EGL_BAD_PARAMETER error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1896
 * If the buffers contained in buffer do not correspond to a proper subset
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1897
   of the buffers described by config, and match the bit depths for those
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1898
   buffers specified in config, then an EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1899
   For example, a VGImage with pixel format VG_lRGBA_8888 corresponds to an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1900
   EGLConfig with EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, and
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1901
   EGL_ALPHA_SIZE values of 8.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1902
 * If no context corresponding to the specified buftype is current, an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1903
   EGL_BAD_ACCESS error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1904
 * There may be additional constraints on which types of buffers may be
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1905
   bound to EGL surfaces, as described in client API specifications. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1906
   those constraints are violated, then an EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1907
 * If buffer is already bound to another pbuffer, or is in use by a client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1908
   API an EGL_BAD_ACCESS error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1909
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1910
EGLSurface CGuestEGL::eglCreatePbufferFromClientBuffer(TEglThreadState& aThreadState,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1911
	      EGLDisplay aDisplay, EGLenum aBufType, EGLClientBuffer aBuffer, EGLConfig aConfig, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1912
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1913
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1914
	// ToDo SgImage Design Spec 5.12 - eglCreatePbufferFromClientBuffer should fail with EGL_BAD_ACCESS for VgImages derived from SgImages
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1915
    EGL_TRACE("eglCreatePbufferFromClientBuffer %d %d %d", aDisplay, aBufType, aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1916
    RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1917
    eglApiData.Init(EglRFC::EeglCreatePbufferFromClientBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1918
    eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1919
    eglApiData.AppendEGLenum(aBufType);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1920
    eglApiData.AppendEGLClientBuffer(aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1921
    eglApiData.AppendEGLConfig(aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1922
    eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1923
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1924
    return aThreadState.ExecEglSurfaceCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1925
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1926
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1927
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1928
 If the dpy argument does not refer to a valid EGLDisplay, EGL_FALSE is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1929
 returned, and an EGL_BAD_DISPLAY error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1930
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1931
EGLBoolean CGuestEGL::eglTerminate(TEglThreadState& aThreadState, EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1932
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1933
	EGLBoolean success = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1934
	if (DestroyDisplayInfo(aDisplay))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1935
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1936
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1937
		eglApiData.Init(EglRFC::EeglTerminate);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1938
		eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1939
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1940
		success = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1941
		EGL_TRACE("eglTerminate display=%d ret=%d", aDisplay, success);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1942
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1943
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1944
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1945
		aThreadState.SetEglError(EGL_BAD_DISPLAY);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1946
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1947
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1948
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1949
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1950
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1951
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1952
 On failure, EGL_FALSE is returned. An EGL_NOT_INITIALIZED error is generated
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1953
 if EGL is not initialized on dpy. An EGL_BAD_PARAMETER error is generated
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1954
 if num config is NULL.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1955
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1956
EGLBoolean CGuestEGL::eglGetConfigs(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig *aConfigs,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1957
			 EGLint aConfigSize, EGLint *aNumConfig)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1958
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1959
	EGLint error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1960
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1961
	if (aNumConfig == NULL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1962
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1963
		error = EGL_BAD_PARAMETER;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1964
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1965
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1966
	// ToDo check display is valid 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1967
	if (error != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1968
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1969
		aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1970
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1971
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1972
	if (aConfigs && !aConfigSize)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1973
		aConfigSize = 1;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1974
	else if (!aConfigs)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1975
		aConfigSize = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1976
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1977
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1978
	eglApiData.Init(EglRFC::EeglGetConfigs);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1979
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1980
	eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1981
	eglApiData.AppendEGLint(aConfigSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1982
	eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1983
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1984
	// ToDo cache successful result for next time 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1985
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1986
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1987
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1988
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1989
EGLBoolean CGuestEGL::eglChooseConfig(TEglThreadState& aThreadState, EGLDisplay aDisplay, const EGLint *aAttribList,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1990
				EGLConfig *aConfigs, EGLint aConfigSize, EGLint *aNumConfig)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1991
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1992
	if (aConfigs && !aConfigSize)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1993
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1994
		aConfigSize = 1;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1995
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1996
	else if (!aConfigs)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1997
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1998
		aConfigSize = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1999
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2000
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2001
	const EGLint* surfaceType = TAttribUtils::FindAttribValue(aAttribList, EGL_SURFACE_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2002
	if (surfaceType && (*surfaceType & EGL_PIXMAP_BIT))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2003
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2004
		EGL_TRACE("CGuestEGL::eglChooseConfig for Pixmap Surface");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2005
		const EGLint* pixmapMatch = TAttribUtils::FindAttribValue(aAttribList, EGL_MATCH_NATIVE_PIXMAP);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2006
		if (pixmapMatch && *pixmapMatch)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2007
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2008
			EGL_TRACE("CGuestEGL::eglChooseConfig attributes include EGL_MATCH_NATIVE_PIXMAP, value is 0x%x", *pixmapMatch);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2009
			// check/copy color & alpha sizes from pixmap
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2010
			return ChooseConfigForPixmapSurface(aThreadState, aDisplay, aAttribList, aConfigs, aConfigSize, aNumConfig, (const void*)*pixmapMatch);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2011
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2012
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2013
			{ // Pixmap to match is missing
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2014
			EGL_TRACE("CGuestEGL::eglChooseConfig EGL_MATCH_NATIVE_PIXMAP attribute is missing or NULL");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2015
			aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2016
			return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2017
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2018
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2019
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2020
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2021
	eglApiData.Init( EglRFC::EeglChooseConfig );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2022
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2023
	eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList));
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2024
	eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2025
	eglApiData.AppendEGLint(aConfigSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2026
	eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2027
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2028
	return aThreadState.ExecEglBooleanCmd(eglApiData); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2029
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2030
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2031
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2032
 On failure returns EGL_FALSE. If attribute
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2033
 is not a valid attribute then EGL_BAD_ATTRIBUTE is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2034
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2035
EGLBoolean CGuestEGL::eglGetConfigAttrib(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2036
					EGLint aAttribute, EGLint *aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2037
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2038
	// ToDo validate display & aAttribute, and maybe get result from local cache
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2039
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2040
	eglApiData.Init(EglRFC::EeglGetConfigAttrib);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2041
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2042
	eglApiData.AppendEGLConfig(aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2043
	eglApiData.AppendEGLint(aAttribute);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2044
	eglApiData.AppendEGLintVector(aValue, 1, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2045
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2046
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2047
	EGL_TRACE_GET_ATTRIB("eglGetConfigAttrib", "config", aDisplay, aConfig, aAttribute, aValue, result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2048
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2049
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2050
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2051
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2052
 Returns EGL_FALSE on failure and value is not updated. If attribute is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2053
 valid EGL surface attribute, then an EGL_BAD_ATTRIBUTE error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2054
 surface is not a valid EGLSurface then an EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2055
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2056
EGLBoolean CGuestEGL::eglSurfaceAttrib(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2057
			    EGLint aAttribute, EGLint aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2058
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2059
	EGL_TRACE_SET_ATTRIB("eglSurfaceAttrib", "surface", aDisplay, aSurface, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2060
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2061
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2062
	eglApiData.Init(EglRFC::EeglSurfaceAttrib);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2063
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2064
	eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2065
	eglApiData.AppendEGLint(aAttribute);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2066
	eglApiData.AppendEGLint(aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2067
	return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2068
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2069
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2070
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2071
 If eglBindTexImage is called and the surface attribute EGL_TEXTURE_FORMAT is set
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2072
 to EGL_NO_TEXTURE, then an EGL_BAD_MATCH error is returned. If buffer is already
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2073
 bound to a texture then an EGL_BAD_ACCESS error is returned. If buffer is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2074
 valid buffer, then an EGL_BAD_PARAMETER error is generated. If surface is not a
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2075
 valid EGLSurface, or is not a pbuffer surface supporting texture
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2076
 binding, then an EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2077
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2078
EGLBoolean CGuestEGL::eglBindTexImage(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLint aBuffer)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2079
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2080
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2081
	if ( (aBuffer == NULL) || (3 & (TUint)aBuffer))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2082
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2083
		aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2084
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2085
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2086
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2087
	eglApiData.Init(EglRFC::EeglBindTexImage);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2088
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2089
	eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2090
	eglApiData.AppendEGLint(aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2091
	return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2092
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2093
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2094
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2095
 If the value of surface attribute EGL_TEXTURE_FORMAT is EGL_NO_TEXTURE,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2096
 then an EGL_BAD_MATCH error is returned. If buffer is not a valid buffer
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2097
 (currently only EGL_BACK_BUFFER may  be specified), then an
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2098
 EGL_BAD_PARAMETER error is generated. If surface is not a valid EGLSurface,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2099
 or is not a bound pbuffer surface, then an EGL_BAD_SURFACE error is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2100
 returned.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2101
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2102
EGLBoolean CGuestEGL::eglReleaseTexImage(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface, EGLint aBuffer)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2103
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2104
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2105
	if ( (aBuffer == NULL) || (3 & (TUint)aBuffer))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2106
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2107
		aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2108
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2109
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2110
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2111
	eglApiData.Init(EglRFC::EeglReleaseTexImage);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2112
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2113
	eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2114
	eglApiData.AppendEGLint(aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2115
	return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2116
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2117
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2118
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2119
 Returns EGL_FALSE on failure. If there is no current context on the calling
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2120
 thread, a EGL_BAD_CONTEXT error is generated. If there is no surface bound
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2121
 to the current context, a EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2122
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2123
EGLBoolean CGuestEGL::eglSwapInterval(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLint aInterval)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2124
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2125
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2126
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2127
	eglApiData.Init(EglRFC::EeglSwapInterval);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2128
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2129
	eglApiData.AppendEGLint(aInterval);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2130
	return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2131
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2132
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2133
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2134
 On failure returns EGL_NO_CONTEXT. If the current rendering api is EGL_NONE,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2135
 then an EGL_BAD_MATCH error is generated (this situation can only arise in
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2136
 an implementation which does not support OpenGL ES, and prior to the first
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2137
 call to eglBindAPI). If share context is neither zero nor a valid context
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2138
 of the same client API type as the newly created context, then an EGL_-
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2139
 BAD_CONTEXT error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2140
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2141
 ...
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2142
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2143
EGLContext CGuestEGL::eglCreateContext(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2144
				EGLContext aShareContext, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2145
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2146
	EGLContext result = EGL_NO_CONTEXT;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2147
    iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2148
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2149
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2150
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2151
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2152
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2153
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2154
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2155
		CEglContext* shareContext = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2156
		if (aShareContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2157
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2158
			CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aShareContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2159
			if (!pContext || (*pContext)->IsDestroyed())
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2160
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2161
				EGL_TRACE("cannot find share context %d for display %d, or it is destroyed", aShareContext, aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2162
				aThreadState.SetEglError(EGL_BAD_CONTEXT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2163
				iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2164
				return EGL_NO_CONTEXT;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2165
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2166
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2167
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2168
		CEglContext* newContext = CEglContext::Create(aThreadState, aDisplay, aConfig, shareContext, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2169
		if (newContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2170
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2171
			RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2172
			TInt err = (*pDispInfo)->iContextMap.Insert(newContext->ClientContext(), newContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2173
			CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2174
			if (err != KErrNone)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2175
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2176
				newContext->Destroy(aThreadState);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2177
				aThreadState.SetEglError(EGL_BAD_ALLOC);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2178
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2179
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2180
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2181
				result = newContext->ClientContext();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2182
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2183
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2184
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2185
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2186
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2187
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2188
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2189
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2190
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2191
 Returns EGL_FALSE on failure. An EGL_BAD_CONTEXT error is generated if ctx is
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2192
 not a valid context.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2193
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2194
EGLBoolean CGuestEGL::eglDestroyContext(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLContext aContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2195
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2196
	EGLBoolean success = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2197
    iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2198
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2199
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2200
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2201
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2202
		aThreadState.SetEglError(EGL_BAD_DISPLAY);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2203
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2204
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2205
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2206
		CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2207
		if (!pContext || (*pContext)->IsDestroyed())
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2208
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2209
			EGL_TRACE("cannot find context %d for display %d, or it is destroyed", aContext, aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2210
			aThreadState.SetEglError(EGL_BAD_CONTEXT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2211
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2212
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2213
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2214
			success = EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2215
			if ((*pContext)->Destroy(aThreadState))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2216
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2217
				RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2218
				(*pDispInfo)->iContextMap.Remove(aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2219
				CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2220
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2221
			EGL_TRACE("eglDestroyContext end");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2222
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2223
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2224
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2225
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2226
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2227
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2228
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2229
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2230
 Returns EGL_FALSE on failure and value is not updated. If attribute is not
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2231
 a valid EGL context attribute, then an EGL_BAD_ATTRIBUTE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2232
 If ctx is invalid, an EGL_BAD_CONTEXT error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2233
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2234
EGLBoolean CGuestEGL::eglQueryContext(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLContext aContext, EGLint aAttribute, EGLint *aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2235
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2236
	EGLBoolean success = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2237
    iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2238
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2239
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2240
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2241
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2242
		aThreadState.SetEglError(EGL_BAD_DISPLAY);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2243
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2244
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2245
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2246
		CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2247
		if (!pContext || (*pContext)->IsDestroyed())
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2248
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2249
			EGL_TRACE("cannot find context %d for display %d, or it is destroyed", aContext, aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2250
			aThreadState.SetEglError(EGL_BAD_CONTEXT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2251
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2252
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2253
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2254
			success = (*pContext)->QueryAttribute(aThreadState, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2255
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2256
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2257
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2258
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2259
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2260
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2261
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2262
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2263
 On failure returns EGL_NO_SURFACE. If the pbuffer could not be created due
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2264
 to insufficient resources, then an EGL_BAD_ALLOC error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2265
 config is not a valid EGLConfig, an EGL_BAD_CONFIG error is generated. If
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2266
 the value specified for either EGL_WIDTH or EGL_HEIGHT is less than zero,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2267
 an EGL_BAD_PARAMETER error is generated. If config does not support
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2268
 pbuffers, an EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2269
 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2270
 ... see also comment on exported API
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2271
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2272
EGLSurface CGuestEGL::eglCreatePbufferSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, const EGLint *aAttribList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2273
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2274
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2275
	// ToDo store info about surface
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2276
    RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2277
    eglApiData.Init(EglRFC::EeglCreatePbufferSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2278
    eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2279
    eglApiData.AppendEGLConfig(aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2280
    eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2281
    return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2282
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2283
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2284
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2285
 If there is no current context for the current rendering API, or if the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2286
 current rendering API is EGL_NONE, then EGL_NO_CONTEXT is returned (this
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2287
 is not an error).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2288
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2289
EGLContext CGuestEGL::eglGetCurrentContext(TEglThreadState& aThreadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2290
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2291
	// ToDo should have this information cached
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2292
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2293
	eglApiData.Init(EglRFC::EeglGetCurrentContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2294
	return ExecEglContextNoErrorCmd(aThreadState, eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2295
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2296
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2297
/**
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2298
 * 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2299
 * 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2300
 * @param aConfigs handle to an EGLConfig pointer, where the new configuration data will be. Ownership is transferred to the client.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2301
 * @param aConfigsCnt number of configs that will be in aConfigs upon returning
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2302
 * 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2303
 * @param aConfigAttribs handle to a pointer, where the memory will be allocated, and data copied. This will contain a list of
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2304
 *          config attribute _values_, in the order set out in eglrfc::MetaGetConfigAttribute().
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2305
 *          Format: c1attrval1, c1attrval2, ..., c2attrval1, c2attrval2, ... cNattrvalM
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2306
 *          (the number of attribute values per config is eglrfc::MetaGetConfigAttributeCnt()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2307
 *          Ownership is transferred to the client.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2308
 * @param aConfigAttribsLen handle to an integer value, where the size of the above vector will be stored.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2309
 * @param aFetchMode: which configs to fetch, default = EMetaGetConfigsSg (get configs that support sgImage), possible values are
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2310
 *              EMetaGetConfigsAll,   //get all the configs available
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2311
 *              EMetaGetConfigsSg,    //get configs supporting sg images
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2312
 *              EMetaGetConfigsNonSg, //get configs not supporting sg images
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2313
 *              (only sgImage implemented!)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2314
 * 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2315
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2316
TBool CGuestEGL::EglInternalFunction_MetaGetConfigs(TEglThreadState& aThreadState, EGLConfig*& aConfigs, EGLint& aConfigCnt, EGLint*& aConfigAttribs, EGLint& aConfigAttribsLen, TMetaGetConfigsMode aFetchMode )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2317
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2318
    aConfigCnt = KConfigsMaxCnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2319
	//TODO: optimize this so that the length is the number of returned items
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2320
    aConfigs = (EGLConfig*) CVghwUtils::Alloc( sizeof(EGLConfig) * aConfigCnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2321
    aConfigAttribsLen = KConfigsMaxCnt * 29;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2322
	//TODO: optimize this so that the length is the number of returned items
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2323
    aConfigAttribs = (EGLint*) CVghwUtils::Alloc( sizeof(EGLint) * aConfigAttribsLen );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2324
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2325
    RemoteFunctionCallData rfcdata; EglRFC call( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2326
    call.Init( EglRFC::EeglMetaGetConfigs );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2327
    call.AppendEGLintVector( aConfigs, aConfigCnt, RemoteFunctionCallData::EInOut );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2328
    call.AppendEGLintVector( aConfigAttribs, aConfigAttribsLen, RemoteFunctionCallData::EInOut );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2329
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2330
    call.AppendEGLint( (EGLint)aFetchMode );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2331
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2332
    return aThreadState.ExecEglBooleanCmd( call );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2333
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2334
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2335
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2336
// Private interfaces for EGL to call into Open VG & Open GL ES 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2337
// class MVgApiForEgl - redirects via CVghwUtils to exported functions from Open VG
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2338
ExtensionProcPointer CGuestEGL::guestGetVgProcAddress (const char *aProcName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2339
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2340
	if (!iVgApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2341
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2342
		iVgApiForEgl = CVghwUtils::VgApiForEgl();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2343
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2344
	if (iVgApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2345
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2346
		return iVgApiForEgl->guestGetVgProcAddress(aProcName);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2347
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2348
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2349
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2350
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2351
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2352
// class MGles11ApiForEgl - redirects via CVghwUtils to exported functions from Open GL ES 1.1
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2353
ExtensionProcPointer CGuestEGL::guestGetGles11ProcAddress (const char *aProcName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2354
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2355
	if (!iGles11ApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2356
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2357
		iGles11ApiForEgl = CVghwUtils::Gles11ApiForEgl();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2358
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2359
	if (iGles11ApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2360
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2361
		return iGles11ApiForEgl->guestGetGles11ProcAddress(aProcName);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2362
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2363
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2364
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2365
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2366
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2367
// class MGles2ApiForEgl - redirects via CVghwUtils to exported functions from Open GL ES 2
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2368
ExtensionProcPointer CGuestEGL::guestGetGles2ProcAddress (const char *aProcName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2369
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2370
	if (!iGles2ApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2371
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2372
		iGles2ApiForEgl = CVghwUtils::Gles2ApiForEgl();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2373
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2374
	if (iGles2ApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2375
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2376
		return iGles2ApiForEgl->guestGetGles2ProcAddress(aProcName);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2377
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2378
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2379
	}