guestrendering/guestegl/src/guestegl.cpp
author Jon Medhurst
Fri, 22 Oct 2010 13:33:46 +0100
branchbug235_bringup_0
changeset 63 13f031032ff1
parent 61 032a79db4ef1
child 65 3e31350c2490
permissions -rwxr-xr-x
Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
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)
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   125
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   126
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   127
        }
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
   128
    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
   129
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   130
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   131
        }
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
   132
    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
   133
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   134
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   135
        }
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
   136
    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
   137
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   138
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   139
        }
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   140
    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
   141
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   142
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   143
        }
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
   144
    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
   145
        {
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
        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
   147
        }
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
    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
   149
        {
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
        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
   151
        }
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
    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
   153
        {
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
        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
   155
        }
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
    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
   157
        {
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
        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
   159
        }
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
    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
   161
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   162
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   163
        }
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
   164
    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
   165
        {
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
        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
   167
        }
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
    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
   169
        {
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
        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
   171
        }
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
    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
   173
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   174
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   175
        }
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
   176
    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
   177
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   178
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   179
        }
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
   180
    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
   181
        {
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
        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
   183
        }
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
    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
   185
        {
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
        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
   187
        }
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
    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
   189
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   190
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   191
        }
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   192
    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
   193
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   194
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   195
        }
46
f7fe6b575f3c Fixed incorrect case in eglGetProcAddress egl_Private_SignalSyncNOK
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 45
diff changeset
   196
	else if (strncmp("egl_Private_SignalSyncNOK", aName, strlen("egl_Private_SignalSyncNOK")) == 0)
44
02fdf3459799 add support for eglgetprocaddress for Egl_PrivateSignalSyncNOK
Faisal Memon <faisal.memon@nokia.com>
parents: 42
diff changeset
   197
		{
02fdf3459799 add support for eglgetprocaddress for Egl_PrivateSignalSyncNOK
Faisal Memon <faisal.memon@nokia.com>
parents: 42
diff changeset
   198
		return (ProcPointer)CEglSyncExtension::egl_Private_SignalSyncNOK;
02fdf3459799 add support for eglgetprocaddress for Egl_PrivateSignalSyncNOK
Faisal Memon <faisal.memon@nokia.com>
parents: 42
diff changeset
   199
		}
47
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   200
	else if (strncmp("eglCreateSyncKHR", aName, strlen("eglCreateSyncKHR")) == 0)
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   201
		{
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   202
		return (ProcPointer)CEglSyncExtension::eglCreateSyncKHR;
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   203
		}
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   204
	else if (strncmp("eglDestroySyncKHR", aName, strlen("eglDestroySyncKHR")) == 0)
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   205
		{
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   206
		return (ProcPointer)CEglSyncExtension::eglDestroySyncKHR;
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   207
		}
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   208
	else if (strncmp("eglClientWaitSyncKHR", aName, strlen("eglClientWaitSyncKHR")) == 0)
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   209
		{
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   210
		return (ProcPointer)CEglSyncExtension::eglClientWaitSyncKHR;
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   211
		}
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   212
	else if (strncmp("eglSignalSyncKHR", aName, strlen("eglSignalSyncKHR")) == 0)
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   213
		{
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   214
		return (ProcPointer)CEglSyncExtension::eglSignalSyncKHR;
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   215
		}
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   216
	else if (strncmp("eglGetSyncAttribKHR", aName, strlen("eglGetSyncAttribKHR")) == 0)
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   217
		{
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   218
		return (ProcPointer)CEglSyncExtension::eglGetSyncAttribKHR;
75fe64f1ad18 Added support for EGL sync extensions
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 46
diff changeset
   219
		}
18
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   220
    else
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   221
        {
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   222
        return NULL;
3064c37a6509 Add TPIP-free implementation of eglGetProcAddress
Faisal Memon <faisal.memon@nokia.com>
parents: 17
diff changeset
   223
        }
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   224
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   225
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   226
EGLSurface CGuestEGL::eglCreateWindowSurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig, 
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   227
		EGLNativeWindowType aNativeWindow, const EGLint *aAttribList)
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   228
	{
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   229
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   230
	// FAISALMEMON NEW
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   231
	/**
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   232
	 * pseudo code:
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   233
	 * 
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   234
	 * surfacemamanger.
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   235
	 * 	open()
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   236
	 *   createsurface(2 buffers, width, height, pixel format,...)
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   237
	 *   map surface -> get chunk
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   238
	 * serialization.eglCreateWindowSurface(..)
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   239
	 * eglinternalfunctioncreatesurface(chunk, width, height, ..)
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   240
	 * egl.... setwindowsurfacebuffers(...)
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   241
	 * surfaceupdatesession.connect()
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   242
	 * wnd.setbackgroundsurface()
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   243
	 */
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   244
	EGL_TRACE( "CGuestEGL::eglCreateWindowSurface");
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   245
	EGL_TRACE_ATTRIB_LIST(aAttribList);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   246
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   247
	RWindow* window;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   248
	window = (RWindow*) aNativeWindow;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   249
	TSize size = window->Size();
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   250
	
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   251
	TSurfaceInfo* surfaceInfo = NULL;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   252
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   253
    RSurfaceManager::TSurfaceCreationAttributesBuf buf;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   254
    RSurfaceManager::TSurfaceCreationAttributes& attributes = buf();
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   255
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   256
    attributes.iSize = size;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   257
    attributes.iBuffers = 2;           // REQUIREMENT because host side assumes exactly two buffers
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   258
    attributes.iPixelFormat = EUidPixelFormatARGB_8888;  // this is a guess; either query or hardcode to match syborg
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   259
    attributes.iStride = 4 * size.iWidth;          // Number of bytes between start of one line and start of next
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   260
    attributes.iOffsetToFirstBuffer = 0;
41
2110890eb027 Fixed compile. This change now provides alpha support for the integration of guestegl with the host
Faisal Memon <faisal.memon@nokia.com>
parents: 40
diff changeset
   261
    attributes.iAlignment = RSurfaceManager::EPageAligned;                      // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   262
    attributes.iHintCount=0;  
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   263
    attributes.iSurfaceHints = NULL;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   264
    attributes.iOffsetBetweenBuffers = 0;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   265
    attributes.iContiguous = ETrue;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   266
    attributes.iCacheAttrib = RSurfaceManager::ENotCached;      // Cache attributes
59
d9b81aebba7b Add mapping fix to guestegl and debugging (temporary)
Faisal Memon <faisal.memon@nokia.com>
parents: 50
diff changeset
   267
    attributes.iMappable = ETrue;
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   268
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   269
	iDisplayMapLock.WriteLock();
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   270
	CEglDisplayInfo** pDispInfo;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   271
	pDispInfo = iDisplayMap.Find(aDisplay);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   272
	
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   273
	if (pDispInfo && *pDispInfo)
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   274
			{
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   275
			RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   276
	
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   277
			surfaceInfo = new TSurfaceInfo();
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   278
			if (surfaceInfo)
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   279
				{
40
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
   280
				surfaceInfo->iNativeWindow = (RWindow*)aNativeWindow;
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   281
				surfaceInfo->iConfigId = aConfig;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   282
				surfaceInfo->iSurfaceManager.Open();
63
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
   283
				surfaceInfo->iSurfaceManager.CreateSurface(buf, surfaceInfo->iSurfaceId);
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
   284
				TInt err =  surfaceInfo->iSurfaceManager.MapSurface(surfaceInfo->iSurfaceId, surfaceInfo->iChunk);
59
d9b81aebba7b Add mapping fix to guestegl and debugging (temporary)
Faisal Memon <faisal.memon@nokia.com>
parents: 50
diff changeset
   285
				EGL_TRACE("CGuestEGL::eglCreateWindowSurface surface manager returned chunk %x and ret val %d", surfaceInfo->iChunk, err);
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   286
				RemoteFunctionCallData rfcdata;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   287
				EglRFC eglApiData( rfcdata );
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   288
				eglApiData.Init( EglRFC::EeglCreateWindowSurface);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   289
				eglApiData.AppendEGLDisplay(aDisplay);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   290
				eglApiData.AppendEGLConfig(aConfig);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   291
				eglApiData.AppendEGLNativeWindowType(aNativeWindow);				
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   292
				eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList) );
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   293
				eglApiData.AppendEGLint(size.iWidth);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   294
				eglApiData.AppendEGLint(size.iHeight);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   295
				eglApiData.AppendEGLint(1000); // horizontalPitch arbitrary
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   296
				eglApiData.AppendEGLint(1000); // verticalPitch arbitrary
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   297
				surfaceInfo->iHostSurfaceId = aThreadState.ExecEglSurfaceCmd(eglApiData); // todo check if is valid
41
2110890eb027 Fixed compile. This change now provides alpha support for the integration of guestegl with the host
Faisal Memon <faisal.memon@nokia.com>
parents: 40
diff changeset
   298
				(*pDispInfo)->iSurfaceMap.Insert(surfaceInfo->iHostSurfaceId, surfaceInfo);
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   299
				EglInternalFunction_CreateSurface(aThreadState, aDisplay, surfaceInfo->iHostSurfaceId, aConfig, window, *surfaceInfo);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   300
				surfaceInfo->iSurfaceUpdateSession.Connect();
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   301
				TSurfaceConfiguration surfaceConfig;
63
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
   302
				surfaceConfig.SetSurfaceId(surfaceInfo->iSurfaceId);
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   303
				window->SetBackgroundSurface(surfaceConfig, ETrue);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   304
				}
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   305
			CVghwUtils::SwitchFromVghwHeap(threadHeap);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   306
			}
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   307
	
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   308
		iDisplayMapLock.Unlock();
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   309
		
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   310
	aThreadState.SetEglError(EGL_SUCCESS);
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   311
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   312
	return surfaceInfo->iHostSurfaceId;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   313
	
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   314
	// FAISALMEMON END OF NEW
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   315
	
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   316
	}
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
   317
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   318
const char* CGuestEGL::eglQueryString(EGLDisplay aDisplay, EGLint aName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   319
	{
50
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   320
	RemoteFunctionCallData rfcdata;
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   321
	EglRFC eglApiData( rfcdata );
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   322
	eglApiData.Init( EglRFC::EeglQueryString );
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   323
	eglApiData.AppendEGLDisplay(aDisplay);
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   324
	eglApiData.AppendEGLint(aName);
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   325
	TEglThreadState* threadState = CVghwUtils::CreateThreadState();
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   326
	EGLBoolean result = EGL_FALSE;
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   327
	if (threadState)
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   328
		{
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   329
		/*
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   330
		 * This command is pointless at the moment.  We actually want the host
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   331
		 * to return a string, not a boolean.  The serialization interface does
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   332
		 * not currently support the returning of strings from the host side,
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   333
		 * so there is no way to get back the result of the query properly.
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   334
		 * 
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   335
		 * We should improve the guest/host interface to add this support.  Then
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   336
		 * this code can be made "useful".  At the moment, returning true means
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   337
		 * the host knows about the extension and wants to reply with a non-NULL
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   338
		 * string. 
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   339
		 */
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   340
		result = threadState->ExecEglBooleanCmd(eglApiData);
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   341
		if (result == EGL_FALSE)
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   342
			{
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   343
			return NULL;
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   344
			}
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   345
		}
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   346
		
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   347
	switch (aName)
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   348
		{
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   349
		case EGL_CLIENT_APIS:
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   350
			return "OpenVG OpenGL_ES OpenGL_ES2";
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   351
		case EGL_EXTENSIONS:
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   352
			return "KHR_reusable_sync EGL_SYMBIAN_COMPOSITION";
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   353
		case EGL_VENDOR:
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   354
			return "Symbian Foundation";
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   355
		case EGL_VERSION:
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   356
			return "1.4 guestegl";
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   357
		}
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   358
	
a7fcb1229472 Add support for eglQueryString. Its partially fake support because the serialization interface does not support the return of string data
Faisal Memon <faisal.memon@nokia.com>
parents: 47
diff changeset
   359
	return NULL;
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   360
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   361
// FAISALMEMON END OF STUB CODE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   362
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   363
CGuestEGL::CGuestEGL() :
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   364
		iEglSyncExtension(NULL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   365
	{
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   368
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   369
void CGuestEGL::OpenSgResources()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   370
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   371
	// 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
   372
	TInt err = iSgDriver.Open();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   373
	EGL_TRACE("  CGuestEGL::Create SgDriver.Open err=%d", err);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   374
	EGLPANIC_ASSERT(err == KErrNone, EEglPanicSgDriverCreateLocalFailed);
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
	TVersion sgImageVer = RSgDriver::Version();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   377
	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
   378
	EGLPANIC_ASSERT(sgImageVer.iMajor == 1, EEglPanicBadSgDriverVersion);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   379
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
void CGuestEGL::CloseSgResources()
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
	iSgDriver.Close();
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
#else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   386
void CGuestEGL::CloseSgResources()
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
	}
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
void CGuestEGL::OpenSgResources()
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
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   394
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
// destructor
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   397
// -----------------------------------------------------------------------------
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
CGuestEGL::~CGuestEGL()
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
	EGL_TRACE("CGuestEGL::~CGuestEGL");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   402
	// only expected to be called during process termination
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   403
	if (iEglSyncExtension)
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
		delete iEglSyncExtension;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   406
		iEglSyncExtension = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   407
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   408
	iDisplayMapLock.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   409
	CloseSgResources();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   410
	iEglImageLock.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   411
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   412
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
// 2nd phase constructor
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
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   417
void CGuestEGL::Create()
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
	EGL_TRACE("  CGuestEGL::Create -->");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   420
    OpenSgResources();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   421
    TInt err;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   422
	err = iDisplayMapLock.CreateLocal();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   423
	EGLPANIC_ASSERT(err == KErrNone, EEglPanicDisplayMapLockCreateLocalFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   424
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   425
	err = iEglImageLock.CreateLocal();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   426
	EGLPANIC_ASSERT(err == KErrNone, EEglPanicEglImageLockCreateLocalFailed);	
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
	InitialiseExtensions();
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
	const char* initExtensionList = EglInternalFunction_QueryExtensionList();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   431
	EGL_TRACE("  CGuestEGL::Create  initExtensionList=0x%x (\"%s\") <--",
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   432
			initExtensionList, initExtensionList ? initExtensionList : "");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   433
	}
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
// -----------------------------------------------------------------------------
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
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   439
CGuestEGL* CGuestEGL::New()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   440
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   441
	EGL_TRACE("CGuestEGL::New  start -->");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   442
	RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   443
	CGuestEGL* result = new CGuestEGL();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   444
	CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   445
	EGLPANIC_ASSERT(result, EEglPanicGuestGraphicsAllocFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   446
	if (result)
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
		result->Create();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   449
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   450
	EGL_TRACE("CGuestEGL::New end - result=0x%x  <--", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   451
	return result;
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
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   457
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   458
void CGuestEGL::SetError(EGLint aError)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   459
	{ // 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
   460
	EGL_TRACE( "CGuestEGL::SetError EGL error=0x%x", aError);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   461
	TEglThreadState* threadState = CVghwUtils::EglThreadState();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   462
	if (threadState)
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
		threadState->SetEglError(aError);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   465
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   466
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   467
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   468
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
   469
		EGLint aGreenBits, EGLint aBlueBits, EGLint aAlphaBits)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   470
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   471
	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
   472
	if (pValue && (*pValue != aColorBufferType))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   473
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   474
		return EGL_BAD_MATCH;
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
	EGLint colorBits = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   477
	if (aColorBufferType == EGL_RGB_BUFFER)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   478
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   479
		colorBits = aRedBits + aGreenBits + aBlueBits + aAlphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   480
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   481
		if (pValue && (*pValue < aRedBits))
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
			return EGL_BAD_MATCH;
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
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   486
		if (pValue && (*pValue < aGreenBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   487
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   488
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   489
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   490
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   491
		if (pValue && (*pValue < aBlueBits))
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
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   494
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   495
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   496
		if (pValue && (*pValue != 0))
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
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   499
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   500
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   501
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   502
		{ // EGL_LUMINANCE_BUFFER
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   503
		colorBits = aLuminanceBits + aAlphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   504
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   505
		if (pValue && (*pValue != 0))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   506
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   507
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   508
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   509
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   510
		if (pValue && (*pValue != 0))
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
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   513
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   514
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   515
		if (pValue && (*pValue != 0))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   516
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   517
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   518
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   519
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   520
		if (pValue && (*pValue < aLuminanceBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   521
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   522
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   523
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   524
		}
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
	if (aAlphaBits)
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
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_ALPHA_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   529
		if (pValue && (*pValue < aAlphaBits))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   530
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   531
			return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   532
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   533
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   534
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   535
	pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BUFFER_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   536
	if (pValue && (*pValue < colorBits))
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
		return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   539
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   540
	return EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   541
	}
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
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
   544
		EGLint aGreenBits, EGLint aBlueBits, EGLint aAlphaBits, TBool aSetVgPreMultAlpha)
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
	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
   547
	if (!pValue)
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
		TAttribUtils::AppendAttribValue(aAttribList, EGL_COLOR_BUFFER_TYPE, aColorBufferType);
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
	EGLint colorBits = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   553
	if (aColorBufferType == EGL_RGB_BUFFER)
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
		colorBits = aRedBits + aGreenBits + aBlueBits + aAlphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   556
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_RED_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   557
		if (!pValue)
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
			TAttribUtils::AppendAttribValue(aAttribList, EGL_RED_SIZE, aRedBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   560
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   561
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_GREEN_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   562
		if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   563
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   564
			TAttribUtils::AppendAttribValue(aAttribList, EGL_GREEN_SIZE, aGreenBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   565
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   566
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BLUE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   567
		if (!pValue)
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
			TAttribUtils::AppendAttribValue(aAttribList, EGL_BLUE_SIZE, aBlueBits);
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
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   572
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   573
		{ // EGL_LUMINANCE_BUFFER
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   574
		colorBits = aLuminanceBits + aAlphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   575
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_LUMINANCE_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   576
		if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   577
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   578
			TAttribUtils::AppendAttribValue(aAttribList, EGL_LUMINANCE_SIZE, aLuminanceBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   579
			}
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   582
	pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_BUFFER_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   583
	if (!pValue)
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
		TAttribUtils::AppendAttribValue(aAttribList, EGL_BUFFER_SIZE, colorBits);
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   588
	if (aAlphaBits)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   589
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   590
		pValue = TAttribUtils::FindAttribValue(aAttribList, EGL_ALPHA_SIZE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   591
		if (!pValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   592
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   593
			TAttribUtils::AppendAttribValue(aAttribList, EGL_ALPHA_SIZE, aAlphaBits);
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
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   596
	if (aSetVgPreMultAlpha)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   597
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   598
		EGLint* pSurfaceType = TAttribUtils::FindAttribValue(aAttribList, EGL_SURFACE_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   599
		if (pSurfaceType)
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
			*pSurfaceType |= EGL_VG_ALPHA_FORMAT_PRE_BIT;
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
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   604
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   605
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   606
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
   607
		EGLint* aNumConfig, const void* aPixmap)
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
	EGLint error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   610
	EGLint* newList = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   611
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   612
	switch ( EglInternalFunction_GetNativePixmapType((EGLNativePixmapType) (aPixmap)) )
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
		case EPixmapTypeFbsBitmap:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   615
			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
   616
			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
   617
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   618
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   619
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   620
		case EPixmapTypeSgImage:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   621
			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
   622
			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
   623
			break;
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
		case EPixmapTypeNone:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   627
		default:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   628
			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
   629
			error = EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   630
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   631
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   632
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   633
	if (error != EGL_SUCCESS)
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
		aThreadState.SetEglError(error);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   636
		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
   637
		if (newList)
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
			CVghwUtils::Free(newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   640
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   641
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   642
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   643
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   644
	EGLPANIC_ASSERT(newList, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   645
	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
   646
	EGL_TRACE_ATTRIB_LIST(newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   647
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   648
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   649
	eglApiData.Init( EglRFC::EeglChooseConfig );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   650
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   651
	eglApiData.AppendEGLintVector(newList, TAttribUtils::AttribListLength(newList) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   652
	eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   653
	eglApiData.AppendEGLint(aConfigSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   654
	eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   655
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   656
	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
   657
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   658
	CVghwUtils::Free(newList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   659
	return result;
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
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   663
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
   664
        EGLint* aNumConfig, const EGLint* aPixmap )
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
    EGLConfig* sgConfigs;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   667
    EGLint sgConfigCnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   668
    TBool* sgConfigsMatchingAttributes;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   669
    TInt sgConfigsMatchingAttributesCnt=0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   670
    EGLint* sgConfigAttribs;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   671
    EGLint sgConfigsAttribtCnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   672
    EGL_TRACE( "CGuestEGL::eglChooseConfig: ChooseConfigForNativePixmapSurface" );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   673
    EglInternalFunction_MetaGetConfigs( aThreadState, sgConfigs, sgConfigCnt, sgConfigAttribs, sgConfigsAttribtCnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   674
    EGL_TRACE( "EglInternalFunction_MetaGetConfigAttirb cnt = %d ", sgConfigsAttribtCnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   675
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   676
    sgConfigsMatchingAttributes = new TBool[sgConfigCnt];
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   677
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   678
    TInt attribs_per_config = EglRFC::MetaGetConfigAttributeCnt();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   679
    TInt configcnt = (TInt) sgConfigsAttribtCnt / attribs_per_config;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   680
    EGL_TRACE( "EglInternalFunction_MetaGetConfigs cnt = %d ", configcnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   681
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   682
    //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
   683
    EGLint* specAttribVals = new EGLint[ attribs_per_config ];
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   684
    for( TInt i=0;i<attribs_per_config;++i )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   685
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   686
        *( specAttribVals + i ) = -1; 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   687
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   688
    int spec_attrib_kind;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   689
    int i_spec_attrib = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   690
    //Go through all the given attributes
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   691
    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
   692
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   693
        //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
   694
        for( TInt i=0;i<attribs_per_config;++i )
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
            if( spec_attrib_kind == EglRFC::MetaGetConfigAttribute( i ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   697
            *(specAttribVals + i) = *( aAttribList + i_spec_attrib );
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
        i_spec_attrib += 2;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   700
        }
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
    //Go through the configurations
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   703
    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
   704
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   705
        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
   706
        //Go throught the attributes of this configuration
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   707
        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
   708
            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   709
            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
   710
            //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
   711
            if( *( specAttribVals + i_attr ) != -1 )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   712
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   713
                switch( EglRFC::MetaGetConfigAttributeSelCriteria( i_attr ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   714
                    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   715
                    case EExact:
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( *( 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
   718
                            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   719
                            pass = EFalse;
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
                        break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   722
                        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   723
                    case EAtLeast:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   724
                        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   725
                        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
   726
                            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   727
                            pass = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   728
                            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   729
                        break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   730
                        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   731
                    case EMask:
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
                        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
   734
                            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   735
                            pass = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   736
                            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   737
                        break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   738
                        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   739
                    }//switch comparison method
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   740
                
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   741
                }//if attribute value specified by client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   742
            }//for through the attributes of a configuration
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   743
            if( pass )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   744
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   745
                *(sgConfigsMatchingAttributes + i_config) = ETrue; 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   746
                }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   747
            else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   748
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   749
                *(sgConfigsMatchingAttributes + i_config) = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   750
                }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   751
        }//end for through the configurations
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   752
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   753
    //Now get the configs that match, and return those
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   754
    TInt aConfigsIndex = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   755
    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
   756
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   757
        if( *(sgConfigsMatchingAttributes + i_config) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   758
            {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   759
            if( aConfigsIndex < aConfigSize )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   760
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   761
                *(aConfigs + (aConfigsIndex++)) = *(sgConfigs + i_config);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   762
                ++sgConfigsMatchingAttributesCnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   763
                }
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
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   766
    //Ok, all done. Delete allocated memory
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   767
	// ToDo use correct Heap!
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   768
    delete[] sgConfigs;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   769
    delete[] sgConfigsMatchingAttributes;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   770
    delete[] sgConfigAttribs;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   771
    delete[] specAttribVals;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   772
	return EGL_TRUE;
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
#endif
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
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
   777
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   778
	EGLPANIC_ASSERT_DEBUG(aNewList, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   779
	EGLint error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   780
	const TInt listLength = TAttribUtils::AttribListLength(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   781
	ASSERT(listLength);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   782
	TDisplayMode mode = ENone;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   783
	const EGLint* pRenderType = TAttribUtils::FindAttribValue(aAttribList, EGL_RENDERABLE_TYPE);
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
	mode = aBitmap->DisplayMode();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   786
	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
   787
	switch (mode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   788
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   789
		case EColor64K:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   790
			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
   791
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   792
		case EColor16M:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   793
		case EColor16MU:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   794
			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
   795
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   796
		case EColor16MA:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   797
			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
   798
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   799
		case EColor16MAP:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   800
			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
   801
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   802
		default: // pixmap not supported
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   803
			error = EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   804
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   805
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   806
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   807
	if (error != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   808
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   809
		return error;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   810
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   811
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   812
	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
   813
	*aNewList = (EGLint*) CVghwUtils::Alloc( (listLength + KExpansionSpace) * sizeof(EGLint) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   814
	if (!*aNewList)
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
		return EGL_BAD_ALLOC;
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
	memcpy(*aNewList, aAttribList, listLength * sizeof(EGLint));
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
	switch (mode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   821
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   822
		case EColor64K:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   823
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 5, 6, 5);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   824
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   825
		case EColor16M:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   826
		case EColor16MU:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   827
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   828
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   829
		case EColor16MA:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   830
			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
   831
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   832
		case EColor16MAP:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   833
			if (pRenderType && ( (*pRenderType) & EGL_OPENVG_BIT) )
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
				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
   836
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   837
			else
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
				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
   840
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   841
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   842
		default:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   843
			EGLPANIC_ALWAYS(EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   844
		}
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
	return EGL_SUCCESS;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   849
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   850
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
   851
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   852
	ASSERT(aNewList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   853
	EGLint error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   854
	const TInt listLength = TAttribUtils::AttribListLength(aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   855
	ASSERT(listLength);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   856
	const EGLint* pRenderType = TAttribUtils::FindAttribValue(aAttribList, EGL_RENDERABLE_TYPE);
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
	/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   859
	if (!iSgConfigAttribs)
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( "CGuestEGL::ChooseConfigAttribsForSgImage 1. EglInternalFunction_MetaGetConfigs" );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   862
		EGLConfig* config;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   863
		EGLint config_cnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   864
		EglInternalFunction_MetaGetConfigs(aThreadState, config, config_cnt, iSgConfigAttribs, iSgConfigsAttribtCnt);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   865
		EGL_TRACE( "EglInternalFunction_MetaGetConfigs cnt = %d ", iSgConfigsAttribtCnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   866
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   867
	if (!iSgConfigAttribs)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   868
		{ // exit if EglInternalFunction_MetaGetConfigs still failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   869
		return EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   870
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   871
	*/
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   872
	// ToDo use iSgConfigAttribs
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   873
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   874
	// temporarily open a handle to the SgImage
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   875
	TSgDrawableId sgId = aSgImage->Id();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   876
	RSgDrawable sgHandle;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   877
	TSgImageInfo imgInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   878
	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
   879
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   880
	// ToDo check SgImage usage bits 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   881
	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
   882
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   883
		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
   884
				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
   885
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   886
		switch (imgInfo.iPixelFormat)
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
			case ESgPixelFormatARGB_8888_PRE: // == EUidPixelFormatARGB_8888_PRE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   889
			case ESgPixelFormatARGB_8888: // == EUidPixelFormatARGB_8888,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   890
				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
   891
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   892
			case ESgPixelFormatXRGB_8888: // == EUidPixelFormatXRGB_8888,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   893
				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
   894
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   895
			case ESgPixelFormatRGB_565: // == EUidPixelFormatRGB_565,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   896
				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
   897
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   898
			case ESgPixelFormatA_8: // == EUidPixelFormatA_8
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   899
				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
   900
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   901
			default: // pixmap not supported
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   902
				error = EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   903
				break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   904
			}
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
	else
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
		error = EGL_BAD_PARAMETER;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   909
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   910
	sgHandle.Close();
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   913
	if (error != EGL_SUCCESS)
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
		return error;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   918
	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
   919
	*aNewList = (EGLint*) CVghwUtils::Alloc( (listLength + KExpansionSpace) * sizeof(EGLint) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   920
	if (!*aNewList)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   921
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   922
		return EGL_BAD_ALLOC;
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
	memcpy(*aNewList, aAttribList, listLength * sizeof(EGLint));
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
	switch (imgInfo.iPixelFormat)
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
		case ESgPixelFormatARGB_8888_PRE: // == EUidPixelFormatARGB_8888_PRE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   929
			if (pRenderType && ( (*pRenderType) & EGL_OPENVG_BIT) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   930
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   931
				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
   932
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   933
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   934
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   935
				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
   936
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   937
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   938
		case ESgPixelFormatARGB_8888: // == EUidPixelFormatARGB_8888,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   939
			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
   940
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   941
		case ESgPixelFormatXRGB_8888: // == EUidPixelFormatXRGB_8888,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   942
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 8, 8, 8);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   943
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   944
		case ESgPixelFormatRGB_565: // == EUidPixelFormatRGB_565,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   945
			AppendColorAttributes(*aNewList, EGL_RGB_BUFFER, 0, 5, 6, 5);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   946
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   947
		case ESgPixelFormatA_8: // == EUidPixelFormatA_8
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   948
			AppendColorAttributes(*aNewList, EGL_LUMINANCE_BUFFER, 8, 0, 0, 0);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   949
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   950
		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
   951
			EGLPANIC_ALWAYS(EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   952
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   953
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   954
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   955
	// change requested surface type from pixmap to Pbuffer
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   956
	EGLint* pSurfaceType = TAttribUtils::FindAttribValue(*aNewList, EGL_SURFACE_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   957
	EGLint surfaceType = *pSurfaceType;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   958
	*pSurfaceType = EGL_PBUFFER_BIT | (surfaceType & ~EGL_PIXMAP_BIT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   959
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   960
	TAttribUtils::RemoveAttrib(*aNewList, EGL_MATCH_NATIVE_PIXMAP);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   961
	return EGL_SUCCESS;
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
#endif
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
  Create an information object for an opened Display.
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
TBool CGuestEGL::CreateDisplayInfo(EGLDisplay aDisplay)
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
	TBool result = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   971
	EGL_TRACE("CGuestEGL::CreateDisplayInfo begin aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   972
	iDisplayMapLock.WriteLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   973
	RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   974
	if (NULL != iDisplayMap.Find( aDisplay))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   975
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   976
		result = ETrue;
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
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   979
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   980
		TInt err = KErrNoMemory; 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   981
		CEglDisplayInfo* dispInfo = new CEglDisplayInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   982
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   983
		if (dispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   984
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   985
			err = iDisplayMap.Insert(aDisplay, dispInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   986
	//		EGL_TRACE("CreateDisplayInfo - DisplayMap insert error %d", err);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   987
			EGLPANIC_ASSERT_DEBUG(err == KErrNone, EEglPanicDisplayMapInsertFailed);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   988
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   989
			//added for egl sync extension benefit
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   990
			if (iEglSyncExtension)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   991
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   992
				err = iEglSyncExtension->EglSyncDisplayCreate(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   993
	//			EGL_TRACE("CreateDisplayInfo - EglSyncDisplayCreate error %d", err);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   994
				EGLPANIC_ASSERT_DEBUG(err == KErrNone, EEglPanicEglSyncDisplayCreateFailed);
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
				if (err)
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
					iDisplayMap.Remove(aDisplay);
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
		if (err == KErrNone)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1004
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1005
			result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1006
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1007
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1008
	CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1009
	iDisplayMapLock.Unlock();
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
	EGL_TRACE("CreateDisplayInfo end, result=%d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1012
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1013
	}
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
  Mark information object for Display as Initialised
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1017
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1018
TBool CGuestEGL::InitializeDisplayInfo(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1019
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1020
	TBool result = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1021
	EGL_TRACE("CGuestEGL::InitialiseDisplayInfo begin aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1022
	iDisplayMapLock.WriteLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1023
	CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1024
	if (pDispInfo && *pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1025
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1026
		(*pDispInfo)->iInitialized = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1027
		result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1028
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1029
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1030
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1031
	EGL_TRACE("InitialiseDisplayInfo end, result=%d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1032
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1033
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1034
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1035
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1036
  Check whether Display exists and is Initialised
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
TBool CGuestEGL::IsDisplayInitialized(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1039
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1040
	TBool result = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1041
	EGL_TRACE("CGuestEGL::IsDisplayInitialized begin aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1042
	iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1043
	CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1044
	if ( pDispInfo && *pDispInfo && (*pDispInfo)->iInitialized)
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
		result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1047
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1048
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1049
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1050
	EGL_TRACE("IsDisplayInitialized end, result=%d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1051
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1052
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1053
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1054
EGLBoolean CGuestEGL::eglSwapBuffers(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1055
    {
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1056
	/**
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1057
	 * PSEUDO CODE
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1058
	 * serialization.eglSwapBuffers
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1059
	 * (maybe finish currently bound api)
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1060
	 * surfaceupdatesession.notifywhenavailable
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1061
	 *   .whendisplayed()  (alternative choice from above)
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1062
	 * surfaceupdatesession.submitupdated()
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1063
	 * user:waitforrequestl
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1064
	 */
40
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1065
	
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1066
	RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1067
    TSurfaceInfo* surfaceInfo = EglInternalFunction_GetPlatformSurface( aDisplay, aSurface );
40
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1068
	RemoteFunctionCallData rfcdata;
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1069
	EglRFC eglApiData( rfcdata );
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1070
	eglApiData.Init(EglRFC::EeglSwapBuffers);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1071
	TSize size = surfaceInfo->iNativeWindow->Size();
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1072
	
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1073
	eglApiData.AppendEGLDisplay(aDisplay);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1074
	eglApiData.AppendEGLSurface(surfaceInfo->iHostSurfaceId);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1075
	eglApiData.AppendEGLint(size.iWidth);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1076
	eglApiData.AppendEGLint(size.iHeight);
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1077
40
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1078
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1079
	TRequestStatus status;
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1080
	TTimeStamp timestampLocalToThread;
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1081
	surfaceInfo->iSurfaceUpdateSession.NotifyWhenDisplayed(status, timestampLocalToThread);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1082
	surfaceInfo->iSurfaceUpdateSession.SubmitUpdate(surfaceInfo->iNativeWindow->ScreenNumber(),surfaceInfo->iSurfaceId, surfaceInfo->iFrontBuffer);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1083
	User::WaitForRequest(status);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1084
	
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1085
	if (surfaceInfo->iFrontBuffer == 0)
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1086
		{
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1087
		surfaceInfo->iFrontBuffer = 1;
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1088
		}
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1089
	else
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1090
		{
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1091
		surfaceInfo->iFrontBuffer = 0;
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1092
		}
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1093
	
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1094
    if (size != surfaceInfo->iSize)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1095
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1096
		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
  1097
				size.iHeight, size.iWidth, surfaceInfo->iSize.iHeight, surfaceInfo->iSize.iWidth);
40
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1098
		
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1099
		CVghwUtils::SwitchFromVghwHeap(threadHeap);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1100
        return EglInternalFunction_SurfaceResized(aThreadState, *surfaceInfo, aDisplay, aSurface); // TODO handling of resize
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1101
        }
40
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1102
    
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1103
	CVghwUtils::SwitchFromVghwHeap(threadHeap);
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1104
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1105
	return result;
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1106
    }
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
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
  1109
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1110
	if (aContext == EGL_NO_CONTEXT)
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
		if ( (aDraw != EGL_NO_SURFACE) || (aRead != EGL_NO_SURFACE) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1113
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1114
			aThreadState.SetEglError(EGL_BAD_SURFACE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1115
			return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1116
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1117
		EGL_TRACE("CGuestEGL::eglMakeCurrent call host");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1118
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1119
		eglApiData.Init( EglRFC::EeglMakeCurrent );
61
032a79db4ef1 Revert fix for eglMakeCurrent since it was the deinit path was is ok for EGL_NO_*. Add extra debugging
Faisal Memon <faisal.memon@nokia.com>
parents: 60
diff changeset
  1120
		eglApiData.AppendEGLDisplay(EGL_NO_DISPLAY);
032a79db4ef1 Revert fix for eglMakeCurrent since it was the deinit path was is ok for EGL_NO_*. Add extra debugging
Faisal Memon <faisal.memon@nokia.com>
parents: 60
diff changeset
  1121
		eglApiData.AppendEGLSurface(EGL_NO_SURFACE);
032a79db4ef1 Revert fix for eglMakeCurrent since it was the deinit path was is ok for EGL_NO_*. Add extra debugging
Faisal Memon <faisal.memon@nokia.com>
parents: 60
diff changeset
  1122
		eglApiData.AppendEGLSurface(EGL_NO_SURFACE);
032a79db4ef1 Revert fix for eglMakeCurrent since it was the deinit path was is ok for EGL_NO_*. Add extra debugging
Faisal Memon <faisal.memon@nokia.com>
parents: 60
diff changeset
  1123
		eglApiData.AppendEGLContext(EGL_NO_CONTEXT);
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1124
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1125
		EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1126
		EGL_TRACE("CGuestEGL::eglMakeCurrent end success=%d", ret);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1127
		return (EGLBoolean)ret;
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
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1130
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1131
		if ( (aDraw == EGL_NO_SURFACE) || (aRead == EGL_NO_SURFACE) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1132
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1133
			aThreadState.SetEglError(EGL_BAD_SURFACE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1134
			return EGL_FALSE;
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
		// ToDo use new CEglContext code
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1137
		const TInt KMaxSurfaces( 2 );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1138
		EGLSurface surfaces[KMaxSurfaces];
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1139
		TSurfaceInfo* surfaceInfo[KMaxSurfaces] = {NULL, NULL};
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1140
		surfaces[0] = aDraw;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1141
		if (aDraw != aRead)
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
			surfaces[1] = aRead;
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
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1146
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1147
			surfaces[1] = EGL_NO_SURFACE;
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
		for ( TInt i = 0; i < KMaxSurfaces; i++ )
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
			if ( EGL_NO_SURFACE != surfaces[i] )
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("CGuestEGL::eglMakeCurrent check surface %d", surfaces[i] );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1155
				surfaceInfo[i] = EglInternalFunction_GetPlatformSurface( aDisplay, surfaces[i] );
61
032a79db4ef1 Revert fix for eglMakeCurrent since it was the deinit path was is ok for EGL_NO_*. Add extra debugging
Faisal Memon <faisal.memon@nokia.com>
parents: 60
diff changeset
  1156
				EGL_TRACE("CGuestEGL::eglMakeCurrent surfaces[%d] is %x", i, surfaces[i]);
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1157
				//EGL_CHECK_ERROR( surfaceInfo, EGL_BAD_SURFACE , EGL_FALSE );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1158
				if ( surfaceInfo[i] )
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
					TSize newSize;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1161
					switch (surfaceInfo[i]->iSurfaceType)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1162
						{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1163
						case ESurfaceTypePixmapFbsBitmap:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1164
							EGLPANIC_ASSERT_DEBUG(surfaceInfo[i]->iFbsBitmap, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1165
							newSize = surfaceInfo[i]->iFbsBitmap->SizeInPixels();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1166
							break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1167
						case ESurfaceTypeWindow:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1168
							EGLPANIC_ASSERT_DEBUG(surfaceInfo[i]->iNativeWindow, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1169
							newSize = surfaceInfo[i]->iNativeWindow->Size();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1170
							break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1171
						default:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1172
							// size cannot change for other surface types
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1173
							newSize = surfaceInfo[i]->iSize;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1174
							break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1175
						}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1176
					if (newSize != surfaceInfo[i]->iSize)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1177
						{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1178
						EGL_TRACE("CGuestEGL::eglMakeCurrent resize surface");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1179
						if ( !EglInternalFunction_SurfaceResized(aThreadState, *surfaceInfo[i], aDisplay, surfaces[i] ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1180
							{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1181
							return EGL_FALSE;
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
						surfaceInfo[i]->iSize = newSize;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1184
						}
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
		// 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
  1190
		EGLSurface drawId = surfaceInfo[0] ? surfaceInfo[0]->iHostSurfaceId : aDraw;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1191
		EGLSurface readId = aRead;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1192
		if ((aRead == aDraw) && surfaceInfo[0])
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1193
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1194
			readId = surfaceInfo[0]->iHostSurfaceId;
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
		else if (surfaceInfo[1])
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1197
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1198
			readId = surfaceInfo[1]->iHostSurfaceId;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1201
		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
  1202
		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
  1203
				surfaceInfo[0], surfaceInfo[0] ? surfaceInfo[0]->iHostSurfaceId : NULL);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1204
		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
  1205
				surfaceInfo[1], surfaceInfo[1] ? surfaceInfo[1]->iHostSurfaceId : NULL);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1206
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1207
		EGL_TRACE("CGuestEGL::eglMakeCurrent call host");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1208
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1209
		eglApiData.Init( EglRFC::EeglMakeCurrent );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1210
		eglApiData.AppendEGLDisplay(aDisplay);
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
		EGL_TRACE("  eglApiData.AppendEGLSurface(drawId = 0x%x)", drawId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1213
		eglApiData.AppendEGLSurface(drawId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1214
		EGL_TRACE("  eglApiData.AppendEGLSurface(readId = 0x%x);", readId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1215
		eglApiData.AppendEGLSurface(readId);
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
		eglApiData.AppendEGLContext(aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1218
		EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
61
032a79db4ef1 Revert fix for eglMakeCurrent since it was the deinit path was is ok for EGL_NO_*. Add extra debugging
Faisal Memon <faisal.memon@nokia.com>
parents: 60
diff changeset
  1219
		EGL_TRACE("CGuestEGL::eglMakeCurrent last end success=%d", ret);
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1220
		return (EGLBoolean)ret;
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
	}
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
// FAISALMEMON HOLE 0.1
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1225
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
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1228
//
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
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1231
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
  1232
		TSurfaceInfo& aSurfaceInfo)
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
    RSurfaceManager::TSurfaceCreationAttributesBuf attributes;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1235
    RSurfaceManager::TInfoBuf info;
63
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1236
	TInt r;
13
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
    aSurfaceInfo.iNativeWindow = aNativeWindow;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1239
    aSurfaceInfo.iSurfaceType = ESurfaceTypeWindow;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1240
    aSurfaceInfo.iSize = aNativeWindow->Size();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1241
    aSurfaceInfo.iConfigId = aConfig;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1242
	aSurfaceInfo.iHostSurfaceId = aSurface;
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
    // ToDo have function variants that do not validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1245
    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
  1246
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BUFFER_SIZE, &aSurfaceInfo.iColorBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1247
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_RED_SIZE, &aSurfaceInfo.iRedBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1248
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_GREEN_SIZE, &aSurfaceInfo.iGreenBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1249
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BLUE_SIZE, &aSurfaceInfo.iBlueBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1250
    eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_ALPHA_SIZE, &aSurfaceInfo.iAlphaBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1251
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1252
    /*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1253
    TInt err = LastError();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1254
    EGL_CHECK_ERROR( EGL_SUCCESS == err, err, EGL_FALSE );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1255
    */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1256
    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
  1257
    		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
  1258
    		aSurfaceInfo.iGreenBits, aSurfaceInfo.iBlueBits, aSurfaceInfo.iAlphaBits, aSurfaceInfo.iAlphaFormat);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1259
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1260
    TSize size;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1261
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1262
    // FAISALMEMON HOLE 1
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
    // FAISALMEMON STUB CODE
63
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1265
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1266
    TInt offsetToFirstBuffer = -1;
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1267
    TInt offsetToSecondBuffer = -1;
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1268
	r = aSurfaceInfo.iSurfaceManager.GetBufferOffset(aSurfaceInfo.iSurfaceId,0,offsetToFirstBuffer);
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1269
	if(r!=KErrNone)
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1270
		return EGL_FALSE;
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1271
	r = aSurfaceInfo.iSurfaceManager.GetBufferOffset(aSurfaceInfo.iSurfaceId,1,offsetToSecondBuffer);
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1272
	if(r!=KErrNone)
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1273
		return EGL_FALSE;
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1274
    EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface offsetToFirstBuffer=0x%x offsetToSecondBuffer=0x%x",offsetToFirstBuffer,offsetToSecondBuffer);
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1275
13f031032ff1 Update CGuestEGL::eglCreateWindowSurface to save iSurfaceId and get offesets to buffers that lower layers require
Jon Medhurst
parents: 61
diff changeset
  1276
	// FAISALMEMON END OF STUB CODE
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1277
    
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1278
    TUint32 chunkHWBase = 0;
59
d9b81aebba7b Add mapping fix to guestegl and debugging (temporary)
Faisal Memon <faisal.memon@nokia.com>
parents: 50
diff changeset
  1279
    TInt err = CVghwUtils::MapToHWAddress(aSurfaceInfo.iChunk.Handle(), chunkHWBase);
d9b81aebba7b Add mapping fix to guestegl and debugging (temporary)
Faisal Memon <faisal.memon@nokia.com>
parents: 50
diff changeset
  1280
    EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface MapToHWAddress returned %d", err);
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1281
    // 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
  1282
    EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface AFTER VGHWUtils::MapToHWAddress");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1283
31
e77cac87b397 Merge rename of frame buffer to surface buffer with Guest EGL changes.
Matt Plumtree <matt.plumtree@nokia.com>
parents: 30 28
diff changeset
  1284
	TUint32 surfaceBufferBaseAddress(0);
32
b23067389fdf Fixup missed changes from frame (buffer) to surface buffer.
Matt Plumtree <matt.plumtree@nokia.com>
parents: 31
diff changeset
  1285
	(void)CVghwUtils::GetSurfaceBufferBaseAddress(surfaceBufferBaseAddress);
59
d9b81aebba7b Add mapping fix to guestegl and debugging (temporary)
Faisal Memon <faisal.memon@nokia.com>
parents: 50
diff changeset
  1286
	EGL_TRACE("CGuestEGL::egliCreateSurface AFTER VGHWUtils::MapToHWAddress");
d9b81aebba7b Add mapping fix to guestegl and debugging (temporary)
Faisal Memon <faisal.memon@nokia.com>
parents: 50
diff changeset
  1287
	EGL_TRACE("CGuestEGL::egliCreateSurface aSurfaceInfo.iChunk.Base() is %x", aSurfaceInfo.iChunk.Base());
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1288
    /* Store the pointer to the pixel data */
39
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1289
    aSurfaceInfo.iBuffer0 = aSurfaceInfo.iChunk.Base() + offsetToFirstBuffer;
c8311e991ee3 interim checkin, no compilation check done so don't sync to this changeset
Faisal Memon <faisal.memon@nokia.com>
parents: 28
diff changeset
  1290
    aSurfaceInfo.iBuffer1 = aSurfaceInfo.iChunk.Base() + offsetToSecondBuffer;
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1291
31
e77cac87b397 Merge rename of frame buffer to surface buffer with Guest EGL changes.
Matt Plumtree <matt.plumtree@nokia.com>
parents: 30 28
diff changeset
  1292
    aSurfaceInfo.iBuffer0Index = (chunkHWBase + offsetToFirstBuffer) -  surfaceBufferBaseAddress;
e77cac87b397 Merge rename of frame buffer to surface buffer with Guest EGL changes.
Matt Plumtree <matt.plumtree@nokia.com>
parents: 30 28
diff changeset
  1293
    aSurfaceInfo.iBuffer1Index = (chunkHWBase + offsetToSecondBuffer) - surfaceBufferBaseAddress;
40
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1294
    
eaa1315a8556 added eglSwapBuffers integration; this change has not been compiled so don't sync to this changelist
Faisal Memon <faisal.memon@nokia.com>
parents: 39
diff changeset
  1295
    aSurfaceInfo.iFrontBuffer = 0; // Assume host peer also starts rendering buffer 0 as its front buffer
13
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1296
    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
  1297
    		aSurfaceInfo.iBuffer0Index,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1298
    		aSurfaceInfo.iBuffer1Index);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1299
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1300
    if ( !EglInternalFunction_CallSetSurfaceParams(aThreadState, aDisplay, aSurface, aSurfaceInfo) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1301
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1302
        EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface end failure");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1303
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1304
        return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1305
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1306
    EGL_TRACE("CGuestEGL::EglInternalFunction_CreateSurface end success");
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
    return EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1309
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1310
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1311
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1312
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1313
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1314
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1315
EGLBoolean CGuestEGL::eglDestroySurface(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface)
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
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1318
	EGLBoolean result = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1319
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1320
	// do not destroy SgImage surfaces on the Host!
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1321
	TSurfaceInfo* surfaceInfo = EglInternalFunction_GetPlatformSurface(aDisplay, aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1322
	if (!surfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1323
		{ // Note: Pbuffer surfaces are not currently recorded in client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1324
		eglApiData.Init( EglRFC::EeglDestroySurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1325
		eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1326
		eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1327
		result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1328
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1329
	else 
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
		if (surfaceInfo->iSurfaceType != ESurfaceTypePixmapSgImage)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1332
			{ // destroy surface allocated by Host EGL 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1333
			eglApiData.Init( EglRFC::EeglDestroySurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1334
			eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1335
			eglApiData.AppendEGLSurface(surfaceInfo->iHostSurfaceId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1336
			result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1337
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1338
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1339
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1340
			{ // release SgImage handle
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1341
			surfaceInfo->iSgHandle.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1342
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1343
#endif
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
		DestroySurfaceInfo(aDisplay, aSurface);
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1348
	return result;
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
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1351
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1352
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1353
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1354
void CGuestEGL::DestroySurfaceInfo(EGLDisplay aDisplay, EGLSurface aSurface)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1355
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1356
    EGL_TRACE("DestroySurfaceInfo begin");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1357
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1358
    iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1359
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1360
    if (!pDispInfo || !*pDispInfo)
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
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1363
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1364
	else
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
		TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1367
		if (!pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1368
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1369
			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
  1370
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1371
		else
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
			TSurfaceInfo* surfaceInfo = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1374
			RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1375
			if (surfaceInfo->iNativeWindow)
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
				EglInternalFunction_DestroyWindowSurface(*surfaceInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1378
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1379
			delete surfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1380
			(*pDispInfo)->iSurfaceMap.Remove( aSurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1381
			CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1382
			EGL_TRACE("DestroySurfaceInfo end");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1383
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1384
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1385
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1386
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1387
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1388
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
//
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
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1393
TBool CGuestEGL::DestroyDisplayInfo (EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1394
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1395
    EGL_TRACE("DestroyDisplayInfo begin aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1396
    TBool success = EFalse;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1397
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1398
	iDisplayMapLock.WriteLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1399
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1400
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1401
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1402
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1403
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1404
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1405
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1406
		success = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1407
		RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1408
		RHashMap<TInt, TSurfaceInfo*>::TIter iter((*pDispInfo)->iSurfaceMap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1409
		for (;;)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1410
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1411
			TSurfaceInfo** pSurfaceInfo = const_cast<TSurfaceInfo**>(iter.NextValue());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1412
			if (!pSurfaceInfo)
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
				break;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1417
			EGL_TRACE("destroying surface %d", *iter.CurrentKey());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1418
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1419
			TSurfaceInfo* surfaceInfo = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1420
			if (surfaceInfo->iNativeWindow)
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
				EglInternalFunction_DestroyWindowSurface(*surfaceInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1423
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1424
			delete surfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1425
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1426
		iDisplayMap.Remove(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1427
		CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1428
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1429
		//added for egl sync extension benefit
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1430
		if (iEglSyncExtension)
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
			iEglSyncExtension->EglSyncDisplayDestroy(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1433
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1434
		}
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
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1437
	EGL_TRACE("DestroyDisplayInfo end - ret=%d", success);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1438
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1439
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1440
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
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1443
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1444
// -----------------------------------------------------------------------------
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
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
  1447
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1448
    EGL_TRACE("EglInternalFunction_CallSetSurfaceParams begin");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1449
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1450
    RemoteFunctionCallData rfcdata;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1451
    EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1452
    eglApiData.Init(EglRFC::EeglSimulatorSetSurfaceParams);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1453
    eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1454
    eglApiData.AppendEGLSurface( aSurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1455
    EGLNativeWindowType win = (EGLNativeWindowType)aSurfaceInfo.iNativeWindow->ClientHandle();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1456
    eglApiData.AppendEGLNativeWindowType( win );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1457
    eglApiData.AppendEGLSize(aSurfaceInfo.iSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1458
    eglApiData.AppendEGLint(aSurfaceInfo.iStride);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1459
    eglApiData.AppendEGLint(aSurfaceInfo.iBuffer0Index);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1460
    eglApiData.AppendEGLint(aSurfaceInfo.iBuffer1Index);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1461
    aThreadState.ExecuteEglNeverErrorCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1462
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1463
    EGL_TRACE("EglInternalFunction_CallSetSurfaceParams end");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1464
    return EGL_TRUE;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1467
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1468
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1469
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1470
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1471
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
  1472
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1473
	// ToDo check EGL_VG_ALPHA_FORMAT ?
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1474
	EGLint colorBits, redBits, greenBits, blueBits, alphaBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1475
	EGLint wantColorBits, wantRedBits, wantGreenBits, wantBlueBits;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1476
	EGLint wantAlphaBits = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1477
	switch (aMode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1478
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1479
		case EColor64K:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1480
			wantColorBits = 12;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1481
			wantRedBits = 5;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1482
			wantGreenBits = 6;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1483
			wantBlueBits = 5;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1484
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1485
		case EColor16M:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1486
		case EColor16MU:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1487
			wantColorBits = 24;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1488
			wantRedBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1489
			wantGreenBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1490
			wantBlueBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1491
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1492
		case EColor16MA:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1493
			wantColorBits = 32;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1494
			wantRedBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1495
			wantGreenBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1496
			wantBlueBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1497
			wantAlphaBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1498
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1499
		case EColor16MAP:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1500
			wantColorBits = 32;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1501
			wantRedBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1502
			wantGreenBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1503
			wantBlueBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1504
			wantAlphaBits = 8;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1505
			break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1506
		default: // pixmap format not supported
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1507
			return EGL_BAD_NATIVE_PIXMAP;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1508
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1509
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1510
	// 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
  1511
	if (!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BUFFER_SIZE, &colorBits) || 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1512
			!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_RED_SIZE, &redBits) ||
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1513
			!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_GREEN_SIZE, &greenBits) ||
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1514
			!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_BLUE_SIZE, &blueBits) ||
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1515
			!eglGetConfigAttrib(aThreadState, aDisplay, aConfig, EGL_ALPHA_SIZE, &alphaBits) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1516
		{ // fetch failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1517
		return EGL_BAD_MATCH;
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
	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
  1521
			wantColorBits, wantRedBits, wantGreenBits, wantBlueBits, wantAlphaBits,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1522
			colorBits, redBits, greenBits, blueBits, alphaBits);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1523
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1524
	if ( (colorBits < wantColorBits) || (redBits < wantRedBits) || (greenBits < wantGreenBits) ||
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1525
			(blueBits < wantBlueBits) || (alphaBits < wantAlphaBits) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1526
		{ // config does not match bitmap
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1527
		return EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1528
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1529
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1530
	return EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1531
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1532
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
 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
  1535
 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
  1536
 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
  1537
 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
  1538
 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
  1539
 (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
  1540
 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
  1541
 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
  1542
 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
  1543
 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
  1544
 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
  1545
 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
  1546
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1547
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
  1548
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1549
	EGL_TRACE( "CGuestEGL::eglCreatePixmapSurface");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1550
	EGL_TRACE_ATTRIB_LIST(aAttribList);
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
	EGLSurface newSurfaceId = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1553
	TSurfaceInfo* surfaceInfo = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1554
	EGLint error = EGL_BAD_DISPLAY;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1555
	TSymbianPixmapTypeId pixmapType = EPixmapTypeNone;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1556
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1557
	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
  1558
	if ( pixmapMatch && ( (*pixmapMatch) != (EGLint)(aNativePixmap) ) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1559
		{ // 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
  1560
		error = EGL_BAD_MATCH;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1561
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1562
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1563
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1564
		iDisplayMapLock.WriteLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1565
		CEglDisplayInfo** pDispInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1566
		pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1567
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1568
		if (pDispInfo && *pDispInfo)
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
			RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
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
			surfaceInfo = new TSurfaceInfo();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1573
			if (surfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1574
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1575
				surfaceInfo->iConfigId = aConfig;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1576
				pixmapType = EglInternalFunction_GetNativePixmapType(aNativePixmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1577
				switch (pixmapType)
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
					case EPixmapTypeFbsBitmap:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1580
						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
  1581
								*surfaceInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1582
						break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1583
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1584
					case EPixmapTypeSgImage:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1585
						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
  1586
								*surfaceInfo);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1587
						break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1588
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1589
					default:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1590
						break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1591
					}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1592
				if (newSurfaceId == EGL_NO_SURFACE)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1593
					{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1594
					error = EGL_BAD_NATIVE_PIXMAP;
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
				else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1597
					{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1598
					error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1599
					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
  1600
					if (KErrNone != (*pDispInfo)->iSurfaceMap.Insert(newSurfaceId, surfaceInfo))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1601
						{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1602
						error = EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1603
						if (pixmapType == EPixmapTypeFbsBitmap)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1604
							{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1605
							(void) eglDestroySurface(aThreadState, aDisplay, newSurfaceId);
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
						newSurfaceId = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1608
						}
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
				if (error != EGL_SUCCESS)
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
					delete surfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1613
					surfaceInfo = NULL;
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
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1616
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1617
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1618
				error = EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1619
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1620
			CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1621
			}  // dispInfo
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1622
		iDisplayMapLock.Unlock();
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
	aThreadState.SetEglError(error);
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
	// parameter check failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1628
	if (error != EGL_SUCCESS)
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
		EGLPANIC_ASSERT_DEBUG(newSurfaceId == EGL_NO_SURFACE, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1631
		EGLPANIC_ASSERT_DEBUG(surfaceInfo == NULL, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1632
		return EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1633
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1634
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1635
	EGLPANIC_ASSERT_DEBUG(newSurfaceId != EGL_NO_SURFACE, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1636
	EGLPANIC_ASSERT_DEBUG(surfaceInfo != NULL, EEglPanicTemp);
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
	return newSurfaceId;
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
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
  1642
		const EGLint *aAttribList, TSurfaceInfo& aSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1643
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1644
	EGLSurface newSurfaceId = EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1645
	aSurfaceInfo.iSurfaceType = ESurfaceTypePixmapFbsBitmap;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1646
	aSurfaceInfo.iFbsBitmap = aBitmap;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1647
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1648
	TDisplayMode mode = ENone;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1649
	TInt stride;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1650
	aSurfaceInfo.iSize = aBitmap->SizeInPixels(); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1651
	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
  1652
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1653
	// 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
  1654
	if (!EglInternalFunction_PixmapSurfacePreviouslyCreated(aBitmap, EPixmapTypeFbsBitmap))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1655
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1656
		// error = EGL_BAD_ALLOC;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1657
		return EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1658
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1659
	else
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
		mode = aBitmap->DisplayMode();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1662
		if (EGL_SUCCESS != ConfigMatchesFbsBitmapPixmap(aThreadState, aDisplay, aConfig, aAttribList, mode))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1663
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1664
			return EGL_NO_SURFACE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1665
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1666
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1667
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1668
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1669
	stride = CFbsBitmap::ScanLineLength(aSurfaceInfo.iSize.iWidth, mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1670
	eglApiData.Init( EglRFC::EeglCreatePixmapSurface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1671
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1672
	eglApiData.AppendEGLConfig(aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1673
	eglApiData.AppendEGLNativePixmapType((EGLNativePixmapType) aBitmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1674
	eglApiData.AppendEGLint(mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1675
	eglApiData.AppendEGLSize(aSurfaceInfo.iSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1676
	eglApiData.AppendEGLint(stride);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1677
	eglApiData.AppendEGLint(EPixmapTypeFbsBitmap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1678
	eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList));
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1679
	newSurfaceId = aThreadState.ExecEglSurfaceCmd(eglApiData); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1680
	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
  1681
			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
  1682
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1683
	aSurfaceInfo.iHostSurfaceId = newSurfaceId;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1684
	return newSurfaceId;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1687
#ifdef FAISALMEMON_S4_SGIMAGE
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1688
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
  1689
		const EGLint *aAttribList, TSurfaceInfo& aSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1690
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1691
	// 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
  1692
	aSurfaceInfo.iSurfaceType = ESurfaceTypePixmapSgImage;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1693
	aSurfaceInfo.iSgId = aSgImage->Id();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1694
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1695
    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
  1696
	TSgImageInfo imgInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1697
	// ToDo ensure SgImage has correct suitable usage bits 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1698
	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
  1699
			(KErrNone == aSgImage->GetInfo(imgInfo)) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1700
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1701
		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
  1702
				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
  1703
		aSurfaceInfo.iSize = imgInfo.iSizeInPixels;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1704
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1705
        /* 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
  1706
           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
  1707
        TUint64 sgHandles;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1708
		EGLint hostResult = CVghwUtils::EglGetSgHandles(aSurfaceInfo.iSgId.iId, &sgHandles);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1709
		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
  1710
		aSurfaceInfo.iHostSurfaceId = (EGLSurface)(sgHandles&0xFFFFFFFF);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1711
		return aSurfaceInfo.iHostSurfaceId;
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
	aSurfaceInfo.iSgHandle.Close();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1715
	return EGL_NO_SURFACE;
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
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1718
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1719
// -----------------------------------------------------------------------------
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
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1722
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1723
TSurfaceInfo* CGuestEGL::EglInternalFunction_GetPlatformSurface( EGLDisplay display, EGLSurface surface )
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
	EGL_TRACE( "CGuestEGL::EglInternalFunction_GetPlatformSurface");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1726
	TSurfaceInfo* result = NULL;
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
	iDisplayMapLock.ReadLock();
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
	CEglDisplayInfo** pDispInfo = iDisplayMap.Find( display );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1731
	if (pDispInfo && *pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1732
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1733
		TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find( surface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1734
		if (pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1735
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1736
			result = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1737
			}
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
	// 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
  1741
	iDisplayMapLock.Unlock();
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
	/* 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
  1744
	if (result == NULL)
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
		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
  1747
		}
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
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1750
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1751
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
// -----------------------------------------------------------------------------
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
EGLBoolean CGuestEGL::eglWaitClient(TEglThreadState& aThreadState)
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
	EGL_TRACE( "CGuestEGL::eglWaitClient");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1759
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1760
	eglApiData.Init(EglRFC::EeglWaitClient);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1761
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(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 (result)
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
		// 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
  1766
		EGLDisplay display = eglGetCurrentDisplay(aThreadState);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1767
		EGLSurface surface = eglGetCurrentSurface(aThreadState, EGL_DRAW);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1768
		iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1769
		CEglDisplayInfo** pDispInfo = iDisplayMap.Find( display );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1770
		TSurfaceInfo* surfaceInfo = NULL;
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
		if (!pDispInfo || !*pDispInfo)
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
			EGL_TRACE( "cannot find display %d", display );
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
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1777
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1778
			TSurfaceInfo** pSurfaceInfo = (*pDispInfo)->iSurfaceMap.Find( surface );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1779
			if (!pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1780
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1781
				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
  1782
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1783
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1784
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1785
				surfaceInfo = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1786
				}
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
		iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1789
		if (surfaceInfo == NULL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1790
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1791
			return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1792
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1793
		if (surfaceInfo->iSurfaceType == ESurfaceTypePixmapFbsBitmap)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1794
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1795
			EGLPANIC_ASSERT_DEBUG(surfaceInfo->iFbsBitmap, EEglPanicTemp);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1796
			surfaceInfo->iFbsBitmap->BeginDataAccess();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1797
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1798
			RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1799
			eglApiData.Init( EglRFC::EeglSimulatorCopyImageData );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1800
			const TSize sizePixels( surfaceInfo->iFbsBitmap->Header().iSizeInPixels );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1801
			eglApiData.AppendVector( (void*)surfaceInfo->iFbsBitmap->DataAddress(),
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1802
			CFbsBitmap::ScanLineLength( sizePixels.iWidth, surfaceInfo->iFbsBitmap->DisplayMode() )*sizePixels.iHeight,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1803
				RemoteFunctionCallData::EOut );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1804
			aThreadState.ExecuteEglNeverErrorCmd(eglApiData);
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
			surfaceInfo->iFbsBitmap->EndDataAccess();
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
		}
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
	return result;
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
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
//
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
EGLSurface CGuestEGL::eglGetCurrentSurface(TEglThreadState& aThreadState, EGLint aReadDraw)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1818
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1819
	// ToDo cache in client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1820
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1821
	eglApiData.Init(EglRFC::EeglGetCurrentSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1822
	eglApiData.AppendEGLint(aReadDraw);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1823
	return ExecEglSurfaceNoErrorCmd(aThreadState, eglApiData); 
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
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
//
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
EGLDisplay CGuestEGL::eglGetCurrentDisplay(TEglThreadState& aThreadState)
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
	// ToDo cache in client
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1833
	EGL_TRACE("CGuestEGL::eglGetCurrentDisplay");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1834
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1835
	eglApiData.Init(EglRFC::EeglGetCurrentDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1836
	return ExecEglDisplayNoErrorCmd(aThreadState, eglApiData); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1837
	}
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
// -----------------------------------------------------------------------------
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
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1842
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1843
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
  1844
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1845
	TSize pixmapSize;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1846
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1847
	EGL_TRACE("CGuestEGL::eglCopyBuffers");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1848
	EGLBoolean hostResult = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1849
	TSymbianPixmapTypeId targetPixmapType = EglInternalFunction_GetNativePixmapType(aTarget);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1850
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1851
	// 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
  1852
	if ( (targetPixmapType == EPixmapTypeFbsBitmap) && EglInternalFunction_IsValidNativePixmap(aTarget, targetPixmapType) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1853
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1854
		RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1855
		CFbsBitmap* bitmap = (CFbsBitmap*)aTarget;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1856
		TSize pixmapSize = bitmap->SizeInPixels(); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1857
		bitmap->BeginDataAccess();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1858
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1859
		TDisplayMode mode = bitmap->DisplayMode();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1860
		EGLint stride = CFbsBitmap::ScanLineLength(bitmap->Header().iSizeInPixels.iWidth, mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1861
		void* data = bitmap->DataAddress();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1862
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1863
#ifdef _DEBUG
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1864
		char* modeName = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1865
		switch (mode)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1866
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1867
			case ENone: modeName = "ENone"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1868
			case EGray2: modeName = "EGray2"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1869
			case EGray4: modeName = "EGray4"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1870
			case EGray16: modeName = "EGray16"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1871
			case EGray256: modeName = "EGray256"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1872
			case EColor16: modeName = "EColor16"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1873
			case EColor256: modeName = "EColor256"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1874
			case EColor64K: modeName = "EColor64K"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1875
			case EColor16M: modeName = "EColor16M"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1876
			case ERgb: modeName = "ERgb"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1877
			case EColor4K: modeName = "EColor4K"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1878
			case EColor16MU: modeName = "EColor16MU"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1879
			case EColor16MA: modeName = "EColor16MA"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1880
			case EColor16MAP: modeName = "EColor16MAP"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1881
			case EColorLast: modeName = "EColorLast"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1882
			default: modeName = "unknown"; break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1883
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1884
		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
  1885
				bitmap, mode, modeName, stride, data);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1886
#endif
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1887
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1888
		eglApiData.Init(EglRFC::EeglCopyBuffers);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1889
		eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1890
		eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1891
		const TSize sizePixels( bitmap->Header().iSizeInPixels );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1892
		eglApiData.AppendVector((void*)bitmap->DataAddress(), 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1893
				stride*pixmapSize.iHeight,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1894
				RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1895
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1896
		eglApiData.AppendEGLint((EGLint) mode);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1897
		eglApiData.AppendEGLSize(pixmapSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1898
		eglApiData.AppendEGLint(stride);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1899
		eglApiData.AppendEGLint(targetPixmapType);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1900
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1901
		hostResult = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1902
		bitmap->EndDataAccess();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1903
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1904
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1905
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1906
		aThreadState.SetEglError(EGL_BAD_NATIVE_PIXMAP);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1907
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1908
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1909
	return hostResult;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1910
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1911
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
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1914
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1915
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1916
// 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
  1917
TBool CGuestEGL::EglInternalFunction_PixmapSurfacePreviouslyCreated(EGLNativePixmapType pixmap, TSymbianPixmapTypeId pixmapType)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1918
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1919
	// 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
  1920
	TBool result = ETrue;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1921
    if(pixmapType == EPixmapTypeFbsBitmap)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1922
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1923
		iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1924
        RHashMap<TInt, CEglDisplayInfo*>::TIter iter( iDisplayMap );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1925
        for (;;)
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
            CEglDisplayInfo** pDispInfo = const_cast<CEglDisplayInfo**>(iter.NextValue());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1928
            if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1929
                {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1930
                break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1931
                }
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
            RHashMap<TInt, TSurfaceInfo*>::TIter iter2((*pDispInfo)->iSurfaceMap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1934
            for (;;)
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
                TSurfaceInfo** pSurfaceInfo = const_cast<TSurfaceInfo**>(iter2.NextValue());
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1937
                if (!pSurfaceInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1938
                    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1939
                    break;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1940
                    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1941
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1942
                TSurfaceInfo* surfaceInfo = *pSurfaceInfo;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1943
                if ( (surfaceInfo->iSurfaceType == ESurfaceTypePixmapFbsBitmap) && (surfaceInfo->iFbsBitmap == pixmap) )
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
                    result = EFalse;
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
            }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1949
		iDisplayMapLock.Unlock();
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
	EGL_TRACE("CGuestEGL::EglInternalFunction_PixmapSurfacePreviouslyCreated %d", result);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1953
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1954
	}
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
// FAISALMEMON HOLE 2
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1957
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1958
EGLDisplay CGuestEGL::eglGetDisplay(TEglThreadState& aThreadState, EGLNativeDisplayType aDisplayId)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1959
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1960
	RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1961
	eglApiData.Init(EglRFC::EeglGetDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1962
	eglApiData.AppendEGLNativeDisplayType(aDisplayId);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1963
	EGLDisplay display = ExecEglDisplayNoErrorCmd(aThreadState, eglApiData);
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
	if (display != EGL_NO_DISPLAY)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1966
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1967
		if (!CreateDisplayInfo(display))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1968
			{ // alloc failed
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1969
			display = EGL_NO_DISPLAY;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1970
			}
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
	return display;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1973
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1974
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1975
// -----------------------------------------------------------------------------
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
// -----------------------------------------------------------------------------
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1978
//
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1979
EGLint CGuestEGL::InitialiseExtensions()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1980
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1981
	iEglSyncExtension = CEglSyncExtension::Create(*this);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1982
	return EGL_SUCCESS;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1985
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1986
// API supporting EGL sync extension
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1987
// lock the display once found
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1988
EGLint CGuestEGL::FindAndLockDisplay(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1989
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1990
	EGLint result = EGL_BAD_DISPLAY;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1991
	EGL_TRACE("CGuestEGL::FindAndLockDisplay aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1992
	iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1993
	CEglDisplayInfo** pDisp = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1994
	if (pDisp && *pDisp)
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
		CEglDisplayInfo* disp = *pDisp;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1997
		if (disp->iInitialized)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1998
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  1999
			EGL_TRACE("CGuestEGL::FindAndLockDisplay display found");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2000
			result = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2001
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2002
		else
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::FindAndLockDisplay display not initialized");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2005
			result = EGL_NOT_INITIALIZED;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2006
			}
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
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2009
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2010
		EGL_TRACE("CGuestEGL::FindAndLockDisplay cannot find display");
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
	if (result != EGL_SUCCESS)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2013
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2014
		iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2015
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2016
	return result;
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
// release the lock
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2020
void CGuestEGL::ReleaseDisplayLock(EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2021
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2022
	EGL_TRACE("CGuestEGL::ReleaseDisplayLock aDisplay=%d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2023
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2024
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2025
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2026
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2027
CEglSyncExtension* CGuestEGL::EGLSyncExtension()
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2028
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2029
    return iEglSyncExtension;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2033
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2034
 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
  2035
 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
  2036
 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
  2037
 initialized for an otherwise valid dpy.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2038
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2039
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
  2040
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2041
	if ((aDisplay == EGL_NO_DISPLAY) || !InitializeDisplayInfo(aDisplay))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2042
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2043
		aThreadState.SetEglError(EGL_BAD_DISPLAY);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2044
		return EGL_FALSE;
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2047
	RemoteFunctionCallData rfcdata; EglRFC eglApiData(rfcdata);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2048
	eglApiData.Init(EglRFC::EeglInitialize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2049
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2050
	EGLBoolean ret = aThreadState.ExecEglBooleanCmd(eglApiData);
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
	if(ret)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2053
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2054
		if(aMajor)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2055
			*aMajor = EGL_VERSION_MAJOR;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2056
		if(aMinor)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2057
			*aMinor = EGL_VERSION_MINOR;
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("eglInitialize <-" );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2060
	return ret;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2061
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2062
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2063
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2064
 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
  2065
 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
  2066
 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
  2067
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2068
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
  2069
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2070
	// ToDo more parameter validation, and possibly use cached values
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2071
	if ( (aValue == NULL) || (3 & (TUint32)aValue) )
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2072
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2073
		aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2074
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2075
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2076
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2077
	eglApiData.Init(EglRFC::EeglQuerySurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2078
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2079
	eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2080
	eglApiData.AppendEGLint(aAttribute);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2081
	eglApiData.AppendEGLintVector(aValue, 1, RemoteFunctionCallData::EOut);
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
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2084
	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
  2085
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2086
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2087
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2088
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2089
 On failure eglCreatePbufferFromClientBuffer returns EGL_NO_SURFACE. In
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2090
 addition to the errors described eglCreatePbufferSurface,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2091
 eglCreatePbufferFromClientBuffer may fail and generate errors for the
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2092
 following reasons:
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2093
 * 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
  2094
   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
  2095
 * 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
  2096
   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
  2097
   type, an EGL_BAD_PARAMETER error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2098
 * 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
  2099
   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
  2100
   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
  2101
   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
  2102
   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
  2103
   EGL_ALPHA_SIZE values of 8.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2104
 * 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
  2105
   EGL_BAD_ACCESS error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2106
 * 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
  2107
   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
  2108
   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
  2109
 * 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
  2110
   API an EGL_BAD_ACCESS error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2111
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2112
EGLSurface CGuestEGL::eglCreatePbufferFromClientBuffer(TEglThreadState& aThreadState,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2113
	      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
  2114
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2115
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2116
	// 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
  2117
    EGL_TRACE("eglCreatePbufferFromClientBuffer %d %d %d", aDisplay, aBufType, aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2118
    RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2119
    eglApiData.Init(EglRFC::EeglCreatePbufferFromClientBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2120
    eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2121
    eglApiData.AppendEGLenum(aBufType);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2122
    eglApiData.AppendEGLClientBuffer(aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2123
    eglApiData.AppendEGLConfig(aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2124
    eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2125
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2126
    return aThreadState.ExecEglSurfaceCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2127
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2128
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2129
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2130
 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
  2131
 returned, and an EGL_BAD_DISPLAY error is generated.
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
EGLBoolean CGuestEGL::eglTerminate(TEglThreadState& aThreadState, EGLDisplay aDisplay)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2134
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2135
	EGLBoolean success = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2136
	if (DestroyDisplayInfo(aDisplay))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2137
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2138
		RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2139
		eglApiData.Init(EglRFC::EeglTerminate);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2140
		eglApiData.AppendEGLDisplay(aDisplay);
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
		success = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2143
		EGL_TRACE("eglTerminate display=%d ret=%d", aDisplay, success);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2144
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2145
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2146
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2147
		aThreadState.SetEglError(EGL_BAD_DISPLAY);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2148
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2149
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2150
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2151
	}
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
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2154
 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
  2155
 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
  2156
 if num config is NULL.
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
EGLBoolean CGuestEGL::eglGetConfigs(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig *aConfigs,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2159
			 EGLint aConfigSize, EGLint *aNumConfig)
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
	EGLint error = EGL_SUCCESS;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2162
	
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2163
	if (aNumConfig == NULL)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2164
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2165
		error = EGL_BAD_PARAMETER;
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
	// ToDo check display is valid 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2169
	if (error != EGL_SUCCESS)
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
		aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2172
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2173
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2174
	if (aConfigs && !aConfigSize)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2175
		aConfigSize = 1;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2176
	else if (!aConfigs)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2177
		aConfigSize = 0;
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
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2180
	eglApiData.Init(EglRFC::EeglGetConfigs);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2181
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2182
	eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2183
	eglApiData.AppendEGLint(aConfigSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2184
	eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut);
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
	// ToDo cache successful result for next time 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2187
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2188
	return result;
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
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
  2192
				EGLConfig *aConfigs, EGLint aConfigSize, EGLint *aNumConfig)
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
	if (aConfigs && !aConfigSize)
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
		aConfigSize = 1;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2197
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2198
	else if (!aConfigs)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2199
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2200
		aConfigSize = 0;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2201
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2202
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2203
	const EGLint* surfaceType = TAttribUtils::FindAttribValue(aAttribList, EGL_SURFACE_TYPE);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2204
	if (surfaceType && (*surfaceType & EGL_PIXMAP_BIT))
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
		EGL_TRACE("CGuestEGL::eglChooseConfig for Pixmap Surface");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2207
		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
  2208
		if (pixmapMatch && *pixmapMatch)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2209
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2210
			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
  2211
			// check/copy color & alpha sizes from pixmap
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2212
			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
  2213
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2214
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2215
			{ // Pixmap to match is missing
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2216
			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
  2217
			aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2218
			return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2219
			}
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
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2222
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2223
	eglApiData.Init( EglRFC::EeglChooseConfig );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2224
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2225
	eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList));
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2226
	eglApiData.AppendEGLConfigVector(aConfigs, aConfigSize, RemoteFunctionCallData::EOut );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2227
	eglApiData.AppendEGLint(aConfigSize);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2228
	eglApiData.AppendEGLintVector(aNumConfig, 1, RemoteFunctionCallData::EOut);
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
	return aThreadState.ExecEglBooleanCmd(eglApiData); 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2231
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2232
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
 On failure returns EGL_FALSE. If attribute
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2235
 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
  2236
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2237
EGLBoolean CGuestEGL::eglGetConfigAttrib(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2238
					EGLint aAttribute, EGLint *aValue)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2239
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2240
	// 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
  2241
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2242
	eglApiData.Init(EglRFC::EeglGetConfigAttrib);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2243
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2244
	eglApiData.AppendEGLConfig(aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2245
	eglApiData.AppendEGLint(aAttribute);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2246
	eglApiData.AppendEGLintVector(aValue, 1, RemoteFunctionCallData::EOut);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2247
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2248
	EGLBoolean result = aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2249
	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
  2250
	return result;
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
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
 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
  2255
 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
  2256
 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
  2257
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2258
EGLBoolean CGuestEGL::eglSurfaceAttrib(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLSurface aSurface,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2259
			    EGLint aAttribute, EGLint aValue)
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
	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
  2262
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2263
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2264
	eglApiData.Init(EglRFC::EeglSurfaceAttrib);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2265
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2266
	eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2267
	eglApiData.AppendEGLint(aAttribute);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2268
	eglApiData.AppendEGLint(aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2269
	return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2270
	}
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
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2273
 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
  2274
 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
  2275
 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
  2276
 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
  2277
 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
  2278
 binding, then an EGL_BAD_SURFACE error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2279
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2280
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
  2281
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2282
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2283
	if ( (aBuffer == NULL) || (3 & (TUint)aBuffer))
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
		aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2286
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2287
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2288
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2289
	eglApiData.Init(EglRFC::EeglBindTexImage);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2290
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2291
	eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2292
	eglApiData.AppendEGLint(aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2293
	return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2294
	}
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
 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
  2298
 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
  2299
 (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
  2300
 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
  2301
 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
  2302
 returned.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2303
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2304
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
  2305
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2306
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2307
	if ( (aBuffer == NULL) || (3 & (TUint)aBuffer))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2308
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2309
		aThreadState.SetEglError(EGL_BAD_PARAMETER);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2310
		return EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2311
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2312
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2313
	eglApiData.Init(EglRFC::EeglReleaseTexImage);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2314
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2315
	eglApiData.AppendEGLSurface(aSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2316
	eglApiData.AppendEGLint(aBuffer);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2317
	return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2318
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2319
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2320
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2321
 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
  2322
 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
  2323
 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
  2324
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2325
EGLBoolean CGuestEGL::eglSwapInterval(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLint aInterval)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2326
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2327
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2328
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2329
	eglApiData.Init(EglRFC::EeglSwapInterval);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2330
	eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2331
	eglApiData.AppendEGLint(aInterval);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2332
	return aThreadState.ExecEglBooleanCmd(eglApiData);
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
 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
  2337
 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
  2338
 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
  2339
 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
  2340
 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
  2341
 BAD_CONTEXT error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2342
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
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2345
EGLContext CGuestEGL::eglCreateContext(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLConfig aConfig,
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2346
				EGLContext aShareContext, const EGLint *aAttribList)
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
	EGLContext result = EGL_NO_CONTEXT;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2349
    iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2350
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2351
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2352
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2353
        EGL_TRACE("cannot find display %d", aDisplay);
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
	else
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
		CEglContext* shareContext = NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2358
		if (aShareContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2359
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2360
			CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aShareContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2361
			if (!pContext || (*pContext)->IsDestroyed())
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
				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
  2364
				aThreadState.SetEglError(EGL_BAD_CONTEXT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2365
				iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2366
				return EGL_NO_CONTEXT;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2367
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2368
			}
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
		CEglContext* newContext = CEglContext::Create(aThreadState, aDisplay, aConfig, shareContext, aAttribList);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2371
		if (newContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2372
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2373
			RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2374
			TInt err = (*pDispInfo)->iContextMap.Insert(newContext->ClientContext(), newContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2375
			CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2376
			if (err != KErrNone)
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
				newContext->Destroy(aThreadState);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2379
				aThreadState.SetEglError(EGL_BAD_ALLOC);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2380
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2381
			else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2382
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2383
				result = newContext->ClientContext();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2384
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2385
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2386
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2387
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2388
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2389
	return result;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2390
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2391
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2392
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2393
 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
  2394
 not a valid context.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2395
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2396
EGLBoolean CGuestEGL::eglDestroyContext(TEglThreadState& aThreadState, EGLDisplay aDisplay, EGLContext aContext)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2397
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2398
	EGLBoolean success = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2399
    iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2400
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2401
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2402
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2403
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2404
		aThreadState.SetEglError(EGL_BAD_DISPLAY);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2405
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2406
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2407
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2408
		CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2409
		if (!pContext || (*pContext)->IsDestroyed())
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2410
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2411
			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
  2412
			aThreadState.SetEglError(EGL_BAD_CONTEXT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2413
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2414
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2415
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2416
			success = EGL_TRUE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2417
			if ((*pContext)->Destroy(aThreadState))
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2418
				{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2419
				RHeap* threadHeap = CVghwUtils::SwitchToVghwHeap();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2420
				(*pDispInfo)->iContextMap.Remove(aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2421
				CVghwUtils::SwitchFromVghwHeap(threadHeap);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2422
				}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2423
			EGL_TRACE("eglDestroyContext end");
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2424
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2425
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2426
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2427
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2428
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2429
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2430
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2431
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2432
 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
  2433
 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
  2434
 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
  2435
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2436
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
  2437
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2438
	EGLBoolean success = EGL_FALSE;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2439
    iDisplayMapLock.ReadLock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2440
    CEglDisplayInfo** pDispInfo = iDisplayMap.Find(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2441
    if (!pDispInfo || !*pDispInfo)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2442
        {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2443
        EGL_TRACE("cannot find display %d", aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2444
		aThreadState.SetEglError(EGL_BAD_DISPLAY);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2445
        }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2446
	else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2447
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2448
		CEglContext** pContext = (*pDispInfo)->iContextMap.Find(aContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2449
		if (!pContext || (*pContext)->IsDestroyed())
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2450
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2451
			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
  2452
			aThreadState.SetEglError(EGL_BAD_CONTEXT);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2453
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2454
		else
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2455
			{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2456
			success = (*pContext)->QueryAttribute(aThreadState, aAttribute, aValue);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2457
			}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2458
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2459
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2460
	iDisplayMapLock.Unlock();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2461
	return success;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2462
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2463
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2464
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2465
 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
  2466
 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
  2467
 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
  2468
 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
  2469
 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
  2470
 pbuffers, an EGL_BAD_MATCH error is generated.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2471
 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2472
 ... see also comment on exported API
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2473
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2474
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
  2475
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2476
	// ToDo validate parameters
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2477
	// ToDo store info about surface
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2478
    RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2479
    eglApiData.Init(EglRFC::EeglCreatePbufferSurface);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2480
    eglApiData.AppendEGLDisplay(aDisplay);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2481
    eglApiData.AppendEGLConfig(aConfig);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2482
    eglApiData.AppendEGLintVector(aAttribList, TAttribUtils::AttribListLength(aAttribList) );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2483
    return aThreadState.ExecEglBooleanCmd(eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2484
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2485
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2486
/*
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2487
 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
  2488
 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
  2489
 is not an error).
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2490
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2491
EGLContext CGuestEGL::eglGetCurrentContext(TEglThreadState& aThreadState)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2492
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2493
	// ToDo should have this information cached
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2494
	RemoteFunctionCallData rfcdata; EglRFC eglApiData( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2495
	eglApiData.Init(EglRFC::EeglGetCurrentContext);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2496
	return ExecEglContextNoErrorCmd(aThreadState, eglApiData);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2497
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2498
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2499
/**
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2500
 * 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2501
 * 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2502
 * @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
  2503
 * @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
  2504
 * 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2505
 * @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
  2506
 *          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
  2507
 *          Format: c1attrval1, c1attrval2, ..., c2attrval1, c2attrval2, ... cNattrvalM
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2508
 *          (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
  2509
 *          Ownership is transferred to the client.
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2510
 * @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
  2511
 * @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
  2512
 *              EMetaGetConfigsAll,   //get all the configs available
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2513
 *              EMetaGetConfigsSg,    //get configs supporting sg images
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2514
 *              EMetaGetConfigsNonSg, //get configs not supporting sg images
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2515
 *              (only sgImage implemented!)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2516
 * 
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2517
 */
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2518
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
  2519
    {
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2520
    aConfigCnt = KConfigsMaxCnt;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2521
	//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
  2522
    aConfigs = (EGLConfig*) CVghwUtils::Alloc( sizeof(EGLConfig) * aConfigCnt );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2523
    aConfigAttribsLen = KConfigsMaxCnt * 29;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2524
	//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
  2525
    aConfigAttribs = (EGLint*) CVghwUtils::Alloc( sizeof(EGLint) * aConfigAttribsLen );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2526
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2527
    RemoteFunctionCallData rfcdata; EglRFC call( rfcdata );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2528
    call.Init( EglRFC::EeglMetaGetConfigs );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2529
    call.AppendEGLintVector( aConfigs, aConfigCnt, RemoteFunctionCallData::EInOut );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2530
    call.AppendEGLintVector( aConfigAttribs, aConfigAttribsLen, RemoteFunctionCallData::EInOut );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2531
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2532
    call.AppendEGLint( (EGLint)aFetchMode );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2533
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2534
    return aThreadState.ExecEglBooleanCmd( call );
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2535
    }
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2536
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2537
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2538
// 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
  2539
// 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
  2540
ExtensionProcPointer CGuestEGL::guestGetVgProcAddress (const char *aProcName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2541
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2542
	if (!iVgApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2543
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2544
		iVgApiForEgl = CVghwUtils::VgApiForEgl();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2545
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2546
	if (iVgApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2547
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2548
		return iVgApiForEgl->guestGetVgProcAddress(aProcName);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2549
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2550
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2551
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2552
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2553
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2554
// 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
  2555
ExtensionProcPointer CGuestEGL::guestGetGles11ProcAddress (const char *aProcName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2556
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2557
	if (!iGles11ApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2558
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2559
		iGles11ApiForEgl = CVghwUtils::Gles11ApiForEgl();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2560
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2561
	if (iGles11ApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2562
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2563
		return iGles11ApiForEgl->guestGetGles11ProcAddress(aProcName);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2564
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2565
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2566
	}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2567
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2568
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2569
// 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
  2570
ExtensionProcPointer CGuestEGL::guestGetGles2ProcAddress (const char *aProcName)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2571
	{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2572
	if (!iGles2ApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2573
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2574
		iGles2ApiForEgl = CVghwUtils::Gles2ApiForEgl();
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2575
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2576
	if (iGles2ApiForEgl)
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2577
		{
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2578
		return iGles2ApiForEgl->guestGetGles2ProcAddress(aProcName);
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2579
		}
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2580
	return NULL;
220791dae4c4 Add TPIP free guest egl
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
  2581
	}