hostsupport/hostegl/src/EGLExtension.cpp
author Matt Plumtree <matt.plumtree@nokia.com>
Wed, 06 Oct 2010 17:59:01 +0100
branchbug235_bringup_0
changeset 53 c2ef9095503a
permissions -rw-r--r--
Copy code from the holdingarea into the target locations. Some initial rework of CMakeLists.txt files, but not yet tested.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     1
/* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     2
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     3
 * Permission is hereby granted, free of charge, to any person obtaining a
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     4
 * copy of this software and /or associated documentation files
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     5
 * (the "Materials "), to deal in the Materials without restriction,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     6
 * including without limitation the rights to use, copy, modify, merge,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     7
 * publish, distribute, sublicense, and/or sell copies of the Materials,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     8
 * and to permit persons to whom the Materials are furnished to do so,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     9
 * subject to the following conditions:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    10
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    11
 * The above copyright notice and this permission notice shall be included
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    12
 * in all copies or substantial portions of the Materials.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    13
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    14
 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    15
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    16
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    17
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    18
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    19
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    20
 * THE USE OR OTHER DEALINGS IN THE MATERIALS.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    21
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    22
 * Initial Contributors:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    23
 * Nokia Corporation - initial contribution.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    24
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    25
 * Contributors:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    26
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    27
 * Description:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    28
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    29
 */
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    30
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    31
#include "EGLExtension.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    32
#include "EGLState.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    33
#include "EGLImage.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    34
#include "EGLContext.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    35
#include "EGLDisplay.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    36
#include "eglInternal.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    37
#include "EGLProcess.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    38
#include "EGLThread.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    39
#include "EGLOs.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    40
#include "ImageTarget.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    41
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    42
#include <string.h>
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    43
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    44
typedef struct
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    45
	{
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    46
	const char*      extnName;		// procedure or extension name
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    47
	ProcPointer      procAddr;      // address
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    48
	} TExtnInfo;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    49
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    50
static const TExtnInfo eglProcedures[] =
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    51
    { // list of EGL extension name strings, followed by any EGLI_NEW function names
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    52
        {"eglCreateImageKHR", (ProcPointer)eglCreateImageKHR},
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    53
        {"eglDestroyImageKHR", (ProcPointer)eglDestroyImageKHR}
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    54
    };
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    55
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    56
const EGLint KEglProcCount = sizeof(eglProcedures) / sizeof(TExtnInfo); 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    57
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    58
CEGLExtension::CEGLExtension()
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    59
    {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    60
    }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    61
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    62
CEGLExtension::~CEGLExtension(void)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    63
    {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    64
    }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    65
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    66
ProcPointer CEGLExtension::eglGetProcAddress(const char* aProcname)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    67
    {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    68
    EGLint nameLength =  strlen(aProcname);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    69
	if ((nameLength > 3) && !strncmp(aProcname, "egl", 3))
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    70
		{ // EGL extensions - exhaustive search 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    71
		for (EGLint idx = 0; idx < KEglProcCount; idx++)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    72
			{
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    73
			if ( strcmp( aProcname, eglProcedures[idx].extnName ) == 0 )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    74
				return eglProcedures[idx].procAddr;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    75
			}
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    76
		}	
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    77
	return NULL;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    78
    }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    79
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    80
static EImageTarget mapImageTarget( EGLenum target )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    81
	{
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    82
	switch(target)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    83
		{
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    84
		case EGL_GL_TEXTURE_2D_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    85
			return IMAGE_TARGET_TEXTURE_2D;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    86
		case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    87
			return IMAGE_TARGET_TEXTURE_CUBE_MAP_POSITIVE_X;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    88
        case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    89
			return IMAGE_TARGET_TEXTURE_CUBE_MAP_NEGATIVE_X;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    90
        case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    91
			return IMAGE_TARGET_TEXTURE_CUBE_MAP_POSITIVE_Y;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    92
        case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    93
			return IMAGE_TARGET_TEXTURE_CUBE_MAP_NEGATIVE_Y;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    94
        case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    95
			return IMAGE_TARGET_TEXTURE_CUBE_MAP_POSITIVE_Z;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    96
        case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    97
			return IMAGE_TARGET_TEXTURE_CUBE_MAP_NEGATIVE_Z;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    98
		case EGL_GL_RENDERBUFFER_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    99
			return IMAGE_TARGET_RENDERBUFFER;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   100
		default:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   101
			EGLI_ASSERT(false);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   102
		}
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   103
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   104
	// Not reached.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   105
	return (EImageTarget)-1;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   106
	}
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   107
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   108
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR( EGLDisplay dpy,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   109
												  EGLContext ctx,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   110
												  EGLenum target,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   111
												  EGLClientBuffer buffer,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   112
												  const EGLint *attrib_list )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   113
    {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   114
    EGLI_ENTER_RET( EGL_NO_IMAGE_KHR );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   115
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   116
    CEGLImage *image = NULL;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   117
    CEGLDisplay *display = NULL;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   118
    CEGLContext *context = NULL;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   119
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   120
    display = state->GetDisplay( dpy );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   121
    // Check display
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   122
    //<dpy> must be a valid EGLDisplay
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   123
    if( !display )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   124
       {                   
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   125
       EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_DISPLAY );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   126
       }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   127
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   128
    context = display->GetContext( ctx ); 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   129
    // Check context
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   130
    //<ctx> must be a valid OpenVG API context on that display
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   131
    if( !context )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   132
       {                    
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   133
       EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_CONTEXT );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   134
       }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   135
    
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   136
    // Display and context ok, continue...
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   137
    switch( target )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   138
        {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   139
        case EGL_NATIVE_PIXMAP_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   140
            {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   141
            // Not supported
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   142
            // 1) set error code to EGL_BAD_PARAMETER
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   143
            // 2) release lock
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   144
            // 3) return no image
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   145
            EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_PARAMETER );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   146
            break;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   147
            }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   148
        case EGL_VG_PARENT_IMAGE_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   149
            {            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   150
            // Context must be client context and api must be openVG
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   151
            if( context->ClientContext() && EGL_OPENVG_API == context->ClientApi() )                    
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   152
                {                        
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   153
                EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_CONTEXT );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   154
                }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   155
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   156
            //<buffer>
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   157
            //must be a handle of a VGImage object valid in the specified context, cast
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   158
            //into the type EGLClientBuffer
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   159
            //Furthermore, the specified VGImage
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   160
            //<buffer> must not be a child image
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   161
            if ( !state->VGInterface()->IsRootImage( buffer ) )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   162
                {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   163
                EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_ACCESS );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   164
                }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   165
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   166
            // TODO:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   167
            /*
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   168
            1) We also need to check that VGImage is not bound 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   169
            to a Pbuffer surface
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   170
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   171
            2) VGimage has not been already used to create EGLImage. 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   172
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   173
            3) VGImage itself is not created from EGLImage.            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   174
            */
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   175
            //state->VGInterface()-
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   176
            // 1)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   177
            if( EGL_PBUFFER_BIT == context->Config()->GetAttribute( EGL_SURFACE_TYPE ) )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   178
                {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   179
                // If VGImage is bound to a Pbuffer no EGLImage
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   180
                EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_ACCESS );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   181
                }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   182
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   183
            // Descriptor for pixeldata data values
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   184
            SurfaceDescriptor desc; 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   185
            // data is actual pixeldata
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   186
            void* data = NULL;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   187
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   188
            //Any values
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   189
            //specified in <attr_list> are ignored.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   190
     
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   191
            // GetImageData will allocate memory for data
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   192
            // data must be deleted in CEGLImage destructor
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   193
            state->VGInterface()->GetImageData( buffer, desc, data );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   194
            if ( !data )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   195
                {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   196
                EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_ACCESS );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   197
                }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   198
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   199
            // Create CEGLImage.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   200
            image = EGLI_NEW CEGLImage( target, buffer, desc, data );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   201
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   202
            // If EGLImage creation fail then return error code.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   203
            if( !image )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   204
                {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   205
                EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_ALLOC );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   206
                }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   207
            // Add refcount to VGImage
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   208
            state->VGInterface()->AddRef( buffer );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   209
            // Add image in array
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   210
            image = display->AddEGLImage( image );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   211
            break;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   212
            }   
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   213
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   214
        case EGL_GL_TEXTURE_2D_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   215
		case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   216
        case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   217
        case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   218
        case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   219
        case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   220
        case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   221
            {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   222
            // From RFP document
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   223
            // EGL_KHR_gl_image (not required for OpenGL ES 1.1) [R12]
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   224
            /*<ctx> must be a valid OpenGL ES API context on that display.*/
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   225
			if( context->ClientContext() && (EGL_OPENGL_ES_API != context->ClientApi() || 2 != context->ClientVersion()) )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   226
                {                        
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   227
                EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_CONTEXT );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   228
                }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   229
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   230
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   231
            // From spec.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   232
            /*KHR_gl_texture_2D_image requires the presence of an OpenGL ES
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   233
            implementation (1.0 or later and/or 2.0 or later).*/
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   234
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   235
            /*Accepted as an attribute in the <attr_list> parameter of
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   236
            eglCreateImageKHR: EGL_GL_TEXTURE_LEVEL_KHR 0x30BC*/
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   237
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   238
            //EGL_GL_TEXTURE_LEVEL_KHR  
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   239
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   240
            /*If <target> is EGL_GL_TEXTURE_2D_KHR, 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   241
            <buffer> must be the name of a nonzero, EGL_GL_TEXTURE_2D target texture object, 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   242
            cast into the type EGLClientBuffer.  
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   243
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   244
            <attr_list> should specify the mipmap level
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   245
            which will be used as the EGLImage source (EGL_GL_TEXTURE_LEVEL_KHR); the
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   246
            specified mipmap level must be part of <buffer>.  If not specified, the
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   247
            default value listed in Table bbb will be used, instead.  Additional
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   248
            values specified in <attr_list> are ignored.  The texture must be complete
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   249
            unless the mipmap level to be used is 0, the texture has mipmap level 0
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   250
            specified, and no other mipmap levels are specified. */
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   251
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   252
            SurfaceDescriptor surfDesc;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   253
            EGLint textureLevel = 0;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   254
            EGLint dataSize;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   255
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   256
            if( attrib_list && attrib_list[0] != EGL_NONE )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   257
	            {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   258
                  for(int i=0; attrib_list[i] != EGL_NONE ; i+=2)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   259
                    {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   260
                    if( attrib_list[i] == EGL_GL_TEXTURE_LEVEL_KHR )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   261
                        {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   262
                        textureLevel = attrib_list[i+1];
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   263
                        }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   264
                    }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   265
	            }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   266
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   267
			EImageTarget textureTarget = mapImageTarget(target);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   268
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   269
			IEGLtoGLES2Interface* iFace = (IEGLtoGLES2Interface*)state->GLESInterface(2);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   270
			EStatus status = iFace->GetTextureInfo( context->ClientContext(), textureTarget, buffer, textureLevel, surfDesc );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   271
			if ( status != DGLES2_SUCCESS )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   272
				{
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   273
				switch( status )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   274
					{
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   275
					case DGLES2_BAD_PARAMETER:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   276
					case DGLES2_BAD_MATCH:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   277
						EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_PARAMETER );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   278
						break;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   279
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   280
					default:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   281
						EGLI_ASSERT(false);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   282
					}
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   283
                EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_ALLOC );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   284
                }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   285
			dataSize = surfDesc.m_stride * surfDesc.m_height;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   286
			unsigned char* data = new unsigned char [ dataSize ];
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   287
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   288
            iFace->GetTextureData( context->ClientContext(), textureTarget, buffer, textureLevel, data );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   289
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   290
            // Create CEGLImage.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   291
            image = EGLI_NEW CEGLImage( target, buffer, surfDesc, data );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   292
            
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   293
            // If EGLImage creation fail then return error code.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   294
            if( !image )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   295
                {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   296
                EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_ALLOC );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   297
                }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   298
            // Add image in array
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   299
            // That array is in display side.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   300
            image = display->AddEGLImage( image );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   301
            break;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   302
            }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   303
        case EGL_GL_TEXTURE_3D_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   304
            {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   305
            /*<ctx> must be a valid OpenGL ES API context on that display.*/
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   306
			//EGL_BAD_PARAMETER 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   307
            // NOT SUPPORTED 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   308
            EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_PARAMETER );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   309
            }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   310
        case EGL_GL_RENDERBUFFER_KHR:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   311
            {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   312
            //EGL_BAD_PARAMETER 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   313
            // NOT SUPPORTED 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   314
            EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_PARAMETER );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   315
            }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   316
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   317
        default:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   318
            {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   319
            //EGL_BAD_PARAMETER 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   320
            EGLI_LEAVE_RET( EGL_NO_IMAGE_KHR, EGL_BAD_PARAMETER );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   321
            }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   322
        }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   323
    EGLI_LEAVE_RET( image, EGL_SUCCESS );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   324
    }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   325
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   326
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR( EGLDisplay dpy,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   327
												  EGLImageKHR image)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   328
    {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   329
    // TODO:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   330
    /* Check display
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   331
       Delete image from display array*/ 
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   332
    EGLI_ENTER_RET( EGL_FALSE );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   333
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   334
    CEGLDisplay *display = NULL;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   335
    CEGLImage *tempImage = NULL;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   336
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   337
    display = state->GetDisplay( dpy );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   338
    // Check display
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   339
    //<dpy> must be a valid EGLDisplay
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   340
    if( !display )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   341
       {                   
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   342
       EGLI_LEAVE_RET( EGL_FALSE, EGL_BAD_DISPLAY );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   343
       }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   344
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   345
    tempImage = display->GetImage( image );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   346
    if( !tempImage )
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   347
        {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   348
        EGLI_LEAVE_RET( EGL_FALSE, EGL_BAD_PARAMETER );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   349
        }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   350
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   351
    // Display and image are both ok...
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   352
    // Let siblings know that image is destroyed...
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   353
    // Delete mother of image...
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   354
    // Remove image...
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   355
    //tempImage
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   356
    display->RemoveEGLImage( image );
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   357
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   358
    return EGL_TRUE;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   359
    }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   360