author | Matt Plumtree <matt.plumtree@nokia.com> |
Wed, 06 Oct 2010 15:50:10 +0100 | |
branch | bug235_bringup_0 |
changeset 52 | 39e5f73667ba |
parent 24 | a3f46bb01be2 |
permissions | -rw-r--r-- |
24 | 1 |
/* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 |
* |
|
3 |
* Permission is hereby granted, free of charge, to any person obtaining a |
|
4 |
* copy of this software and /or associated documentation files |
|
5 |
* (the "Materials "), to deal in the Materials without restriction, |
|
6 |
* including without limitation the rights to use, copy, modify, merge, |
|
7 |
* publish, distribute, sublicense, and/or sell copies of the Materials, |
|
8 |
* and to permit persons to whom the Materials are furnished to do so, |
|
9 |
* subject to the following conditions: |
|
10 |
* |
|
11 |
* The above copyright notice and this permission notice shall be included |
|
12 |
* in all copies or substantial portions of the Materials. |
|
13 |
* |
|
14 |
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
15 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
17 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
|
18 |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
19 |
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR |
|
20 |
* THE USE OR OTHER DEALINGS IN THE MATERIALS. |
|
21 |
* |
|
22 |
* Initial Contributors: |
|
23 |
* Nokia Corporation - initial contribution. |
|
24 |
* |
|
25 |
* Contributors: |
|
26 |
* |
|
27 |
* Description: |
|
28 |
* |
|
29 |
*/ |
|
30 |
||
31 |
#include "EGLInterface.h" |
|
32 |
#include <new> |
|
33 |
#include "glesInternal.h" |
|
34 |
#include "GLESContext.h" |
|
35 |
#include "SurfaceDescriptor.h" |
|
36 |
#include "GLESTexture.h" |
|
37 |
||
38 |
#include <stdlib.h> |
|
39 |
#include <string.h> |
|
40 |
||
41 |
namespace |
|
42 |
{ |
|
43 |
EGLtoGLESInterface g_EGLtoGLESInterface; |
|
44 |
} |
|
45 |
||
46 |
GLES_API_CALL IEGLtoGLESInterface* getGLESInterface(void) |
|
47 |
{ |
|
48 |
return &g_EGLtoGLESInterface; |
|
49 |
} |
|
50 |
||
51 |
void glesReleaseTexImage(void* surface, int name, int level) |
|
52 |
{ |
|
53 |
EGLtoGLESInterface::GetEGLInterface()->ReleaseTexImage(surface, name, level); |
|
54 |
} |
|
55 |
||
56 |
EGLtoGLESInterface::EGLtoGLESInterface() : |
|
57 |
m_egl(NULL) |
|
58 |
{ |
|
59 |
} |
|
60 |
||
61 |
void EGLtoGLESInterface::SetEGLInterface( IGLEStoEGLInterface* egl ) |
|
62 |
{ |
|
63 |
m_egl = egl; |
|
64 |
} |
|
65 |
||
66 |
void* EGLtoGLESInterface::CreateContext(void* nativeContext) |
|
67 |
{ |
|
68 |
GLESContext* newContext = NULL; |
|
69 |
||
70 |
newContext = GLES_NEW GLESContext(nativeContext); |
|
71 |
if(newContext == NULL) |
|
72 |
{ |
|
73 |
return NULL; |
|
74 |
} |
|
75 |
m_contexts.insert(newContext); |
|
76 |
return newContext; |
|
77 |
} |
|
78 |
||
79 |
bool EGLtoGLESInterface::ReleaseContext(void* context) |
|
80 |
{ |
|
81 |
GLES_ASSERT(context != NULL); |
|
82 |
||
83 |
GLESContext* ctx = static_cast<GLESContext*>(context); |
|
84 |
if(m_contexts.find(ctx) == m_contexts.end()) |
|
85 |
{ |
|
86 |
return false; |
|
87 |
} |
|
88 |
||
89 |
delete ctx; |
|
90 |
m_contexts.erase(ctx); |
|
91 |
||
92 |
return true; |
|
93 |
} |
|
94 |
||
95 |
void* EGLtoGLESInterface::GetNativeContext(void* context) |
|
96 |
{ |
|
97 |
GLES_ASSERT(context != NULL); |
|
98 |
||
99 |
GLESContext* ctx = static_cast<GLESContext*>(context); |
|
100 |
if(m_contexts.find(ctx) == m_contexts.end()) |
|
101 |
{ |
|
102 |
return false; |
|
103 |
} |
|
104 |
||
105 |
return ctx->NativeContext(); |
|
106 |
} |
|
107 |
||
108 |
fpGLProc EGLtoGLESInterface::GetGLProcAddress( const char *procname ) |
|
109 |
{ |
|
110 |
if(strcmp(procname, "glPointSizePointerOES") == 0) |
|
111 |
{ |
|
112 |
return (fpGLProc)glPointSizePointerOES; |
|
113 |
} |
|
114 |
else |
|
115 |
{ |
|
116 |
return NULL; |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
static SurfaceDescriptor createSurfaceDescriptor(int redBits, int redShift, int greenBits, int greenShift, int blueBits, int blueShift, int alphaBits, int alphaShift, int luminanceBits, int luminanceShift, CColorDescriptor::ColorFormat format, int bpp) |
|
121 |
{ |
|
122 |
SurfaceDescriptor desc; |
|
123 |
desc.m_colorDescriptor.m_redSize = redBits; |
|
124 |
desc.m_colorDescriptor.m_greenSize = greenBits; |
|
125 |
desc.m_colorDescriptor.m_blueSize = blueBits; |
|
126 |
desc.m_colorDescriptor.m_alphaSize = alphaBits; |
|
127 |
desc.m_colorDescriptor.m_luminanceSize = luminanceBits; |
|
128 |
desc.m_redShift = redShift; |
|
129 |
desc.m_greenShift = greenShift; |
|
130 |
desc.m_blueShift = blueShift; |
|
131 |
desc.m_alphaShift = alphaShift; |
|
132 |
desc.m_luminanceShift = luminanceShift; |
|
133 |
desc.m_colorDescriptor.m_format = format; |
|
134 |
desc.m_colorDescriptor.m_bpp = bpp; |
|
135 |
return desc; |
|
136 |
} |
|
137 |
||
20
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
138 |
typedef struct |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
139 |
{ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
140 |
SurfaceDescriptor desc; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
141 |
GLenum internal_format; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
142 |
GLenum data_format; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
143 |
GLenum data_type; |
24 | 144 |
} DescToEnumMapping; |
145 |
||
20
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
146 |
static bool isDescEqualToMapping(const SurfaceDescriptor& desc, const DescToEnumMapping& mapping) |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
147 |
{ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
148 |
if ((desc.m_colorDescriptor.m_redSize == mapping.desc.m_colorDescriptor.m_redSize) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
149 |
(desc.m_colorDescriptor.m_greenSize == mapping.desc.m_colorDescriptor.m_greenSize) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
150 |
(desc.m_colorDescriptor.m_blueSize == mapping.desc.m_colorDescriptor.m_blueSize) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
151 |
(desc.m_colorDescriptor.m_alphaSize == mapping.desc.m_colorDescriptor.m_alphaSize) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
152 |
(desc.m_colorDescriptor.m_luminanceSize == mapping.desc.m_colorDescriptor.m_luminanceSize) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
153 |
(desc.m_redShift == mapping.desc.m_redShift) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
154 |
(desc.m_greenShift == mapping.desc.m_greenShift) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
155 |
(desc.m_blueShift == mapping.desc.m_blueShift) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
156 |
(desc.m_alphaShift == mapping.desc.m_alphaShift) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
157 |
(desc.m_luminanceShift == mapping.desc.m_luminanceShift) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
158 |
(desc.m_colorDescriptor.m_format == mapping.desc.m_colorDescriptor.m_format) && |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
159 |
(desc.m_colorDescriptor.m_bpp == mapping.desc.m_colorDescriptor.m_bpp)) |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
160 |
return true; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
161 |
|
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
162 |
return false; |
24 | 163 |
} |
164 |
||
20
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
165 |
static void surfaceDescriptorToGLEnums(const SurfaceDescriptor& desc, GLenum& internal_format, GLenum& data_format, GLenum& data_type) |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
166 |
{ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
167 |
static const DescToEnumMapping map[] = { |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
168 |
/* RGB{A,X} channel ordering */ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
169 |
// sRGBX_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
170 |
{createSurfaceDescriptor(8, 24, 8, 16, 8, 8, 0, 0, 0, 0, CColorDescriptor::sRGBA, 32), GL_SRGB8, GL_RGBA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
171 |
// sRGBA_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
172 |
{createSurfaceDescriptor(8, 24, 8, 16, 8, 8, 8, 0, 0, 0, CColorDescriptor::sRGBA, 32), GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
173 |
// sRGBA_8888_PRE |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
174 |
{createSurfaceDescriptor(8, 24, 8, 16, 8, 8, 8, 0, 0, 0, CColorDescriptor::sRGBA_PRE, 32), GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
175 |
// sRGB_565 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
176 |
{createSurfaceDescriptor(5, 11, 6, 5, 5, 0, 0, 0, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
177 |
// sRGBA_5551 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
178 |
{createSurfaceDescriptor(5, 11, 5, 6, 5, 1, 1, 0, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
179 |
// sRGBA_4444 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
180 |
{createSurfaceDescriptor(4, 12, 4, 8, 4, 4, 4, 0, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
181 |
// sL_8 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
182 |
{createSurfaceDescriptor(0, 0, 0, 0, 0, 0, 0, 0, 8, 0, CColorDescriptor::sLA, 8), GL_SLUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
183 |
// lRGBX_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
184 |
{createSurfaceDescriptor(8, 24, 8, 16, 8, 8, 0, 0, 0, 0, CColorDescriptor::lRGBA, 32), GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
185 |
// lRGBA_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
186 |
{createSurfaceDescriptor(8, 24, 8, 16, 8, 8, 8, 0, 0, 0, CColorDescriptor::lRGBA, 32), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
187 |
// lRGBA_8888_PRE |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
188 |
{createSurfaceDescriptor(8, 24, 8, 16, 8, 8, 8, 0, 0, 0, CColorDescriptor::lRGBA_PRE, 32), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
189 |
// lL_8 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
190 |
{createSurfaceDescriptor(0, 0, 0, 0, 0, 0, 0, 0, 8, 0, CColorDescriptor::lLA, 8), GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
191 |
// A_8 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
192 |
{createSurfaceDescriptor(0, 0, 0, 0, 0, 0, 8, 0, 0, 0, CColorDescriptor::lRGBA, 8), GL_ALPHA8, GL_ALPHA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
193 |
// These should be converted to a compatible format by VG. |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
194 |
/* |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
195 |
// BW_1 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
196 |
{createSurfaceDescriptor(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, CColorDescriptor::lLA, 1), 0, 0, 0}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
197 |
// A_1 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
198 |
{createSurfaceDescriptor(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, CColorDescriptor::lRGBA, 1), 0, 0, 0}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
199 |
// A_4 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
200 |
{createSurfaceDescriptor(0, 0, 0, 0, 0, 0, 4, 0, 0, 0, CColorDescriptor::lRGBA, 4), 0, 0, 0}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
201 |
*/ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
202 |
|
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
203 |
/* {A,X}RGB channel ordering */ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
204 |
// sXRGB_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
205 |
{createSurfaceDescriptor(8, 16, 8, 8, 8, 0, 0, 0, 0, 0, CColorDescriptor::sRGBA, 32), GL_SRGB8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
206 |
// sARGB_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
207 |
{createSurfaceDescriptor(8, 16, 8, 8, 8, 0, 8, 24, 0, 0, CColorDescriptor::sRGBA, 32), GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
208 |
// sARGB_8888_PRE |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
209 |
{createSurfaceDescriptor(8, 16, 8, 8, 8, 0, 8, 24, 0, 0, CColorDescriptor::sRGBA_PRE, 32), GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
210 |
// sARGB_1555 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
211 |
{createSurfaceDescriptor(5, 10, 5, 5, 5, 0, 1, 15, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
212 |
// sARGB_4444 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
213 |
{createSurfaceDescriptor(4, 8, 4, 4, 4, 0, 4, 12, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
214 |
// lXRGB_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
215 |
{createSurfaceDescriptor(8, 16, 8, 8, 8, 0, 0, 0, 0, 0, CColorDescriptor::lRGBA, 32), GL_RGB8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
216 |
// lARGB_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
217 |
{createSurfaceDescriptor(8, 16, 8, 8, 8, 0, 8, 24, 0, 0, CColorDescriptor::lRGBA, 32), GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
218 |
// lARGB_8888_PRE |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
219 |
{createSurfaceDescriptor(8, 16, 8, 8, 8, 0, 8, 24, 0, 0, CColorDescriptor::lRGBA_PRE, 32), GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
220 |
|
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
221 |
/* BGR{A,X} channel ordering */ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
222 |
// sBGRX_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
223 |
{createSurfaceDescriptor(8, 8, 8, 16, 8, 24, 0, 0, 0, 0, CColorDescriptor::sRGBA, 32), GL_SRGB8, GL_BGRA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
224 |
// sBGRA_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
225 |
{createSurfaceDescriptor(8, 8, 8, 16, 8, 24, 8, 0, 0, 0, CColorDescriptor::sRGBA, 32), GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
226 |
// sBGRA_8888_PRE |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
227 |
{createSurfaceDescriptor(8, 8, 8, 16, 8, 24, 8, 0, 0, 0, CColorDescriptor::sRGBA_PRE, 32), GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
228 |
// sBGR_565 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
229 |
{createSurfaceDescriptor(5, 0, 6, 5, 5, 11, 0, 0, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8, GL_BGR, GL_UNSIGNED_SHORT_5_6_5}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
230 |
// sBGRA_5551 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
231 |
{createSurfaceDescriptor(5, 1, 5, 6, 5, 11, 1, 0, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
232 |
// sBGRA_4444 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
233 |
{createSurfaceDescriptor(4, 4, 4, 8, 4, 12, 4, 0, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
234 |
// lBGRX_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
235 |
{createSurfaceDescriptor(8, 8, 8, 16, 8, 24, 0, 0, 0, 0, CColorDescriptor::lRGBA, 32), GL_RGB8, GL_BGRA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
236 |
// lBGRA_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
237 |
{createSurfaceDescriptor(8, 8, 8, 16, 8, 24, 8, 0, 0, 0, CColorDescriptor::lRGBA, 32), GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
238 |
// lBGRA_8888_PRE |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
239 |
{createSurfaceDescriptor(8, 8, 8, 16, 8, 24, 8, 0, 0, 0, CColorDescriptor::lRGBA_PRE, 32), GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
240 |
|
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
241 |
/* {A,X}BGR channel ordering */ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
242 |
// sXBGR_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
243 |
{createSurfaceDescriptor(8, 0, 8, 8, 8, 16, 0, 0, 0, 0, CColorDescriptor::sRGBA, 32), GL_SRGB8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
244 |
// sABGR_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
245 |
{createSurfaceDescriptor(8, 0, 8, 8, 8, 16, 8, 24, 0, 0, CColorDescriptor::sRGBA, 32), GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
246 |
// sABGR_8888_PRE |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
247 |
{createSurfaceDescriptor(8, 0, 8, 8, 8, 16, 8, 24, 0, 0, CColorDescriptor::sRGBA_PRE, 32), GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
248 |
// sABGR_1555 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
249 |
{createSurfaceDescriptor(5, 0, 5, 5, 5, 10, 1, 15, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
250 |
// sABGR_4444 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
251 |
{createSurfaceDescriptor(4, 0, 4, 4, 4, 8, 4, 12, 0, 0, CColorDescriptor::sRGBA, 16), GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
252 |
// lXBGR_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
253 |
{createSurfaceDescriptor(8, 0, 8, 8, 8, 16, 0, 0, 0, 0, CColorDescriptor::lRGBA, 32), GL_RGB8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
254 |
// lABGR_8888 |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
255 |
{createSurfaceDescriptor(8, 0, 8, 8, 8, 16, 8, 24, 0, 0, CColorDescriptor::lRGBA, 32), GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}, |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
256 |
// lABGR_8888_PRE: |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
257 |
{createSurfaceDescriptor(8, 0, 8, 8, 8, 16, 8, 24, 0, 0, CColorDescriptor::lRGBA_PRE, 32), GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}}; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
258 |
|
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
259 |
for (size_t i = 0; i < sizeof(map)/sizeof(map[0]); i++) |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
260 |
{ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
261 |
if (isDescEqualToMapping(desc, map[i])) |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
262 |
{ |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
263 |
internal_format = map[i].internal_format; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
264 |
data_format = map[i].data_format; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
265 |
data_type = map[i].data_type; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
266 |
GLES_ASSERT(internal_format != 0 && data_format != 0 && data_type != 0); |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
267 |
return; |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
268 |
} |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
269 |
} |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
270 |
GLES_ASSERT(false); |
d2d6724aef32
Initial contribution of Khronos API implmentations suitable for simulator host-side.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
271 |
return; |
24 | 272 |
} |
273 |
||
274 |
int EGLtoGLESInterface::BindTexImage( void* surface, int level, bool generateMipmap, const SurfaceDescriptor* desc, void* buffer ) |
|
275 |
{ |
|
276 |
GLES_ENTER_RET(NULL); |
|
277 |
||
278 |
GLuint ret = 0; |
|
279 |
||
280 |
// Store the current error and clear the error flag. |
|
281 |
ctx->GetHostError(); |
|
282 |
||
283 |
if(level < 0) |
|
284 |
{ |
|
285 |
level = 0; |
|
286 |
} |
|
287 |
else if(level > (int)ctx->MaxTextureLevel()) |
|
288 |
{ |
|
289 |
level = ctx->MaxTextureLevel(); |
|
290 |
} |
|
291 |
||
292 |
GLint origGenMipmapParam; |
|
293 |
ctx->DGL().glGetTexParameteriv(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, &origGenMipmapParam); |
|
294 |
||
295 |
if(!generateMipmap) |
|
296 |
{ |
|
297 |
// Disable automatic mipmap generation. |
|
298 |
ctx->DGL().glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE); |
|
299 |
} |
|
300 |
||
301 |
// Clear all mipmap levels. |
|
302 |
for(unsigned int i = 0; i < ctx->MaxTextureLevel(); i++) |
|
303 |
{ |
|
304 |
ctx->DGL().glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
|
305 |
} |
|
306 |
||
307 |
GLenum internalFormat, dataFormat, dataType; |
|
308 |
surfaceDescriptorToGLEnums(*desc, internalFormat, dataFormat, dataType); |
|
309 |
ctx->DGL().glTexImage2D(GL_TEXTURE_2D, level, internalFormat, desc->m_width, desc->m_height, 0, |
|
310 |
dataFormat, dataType, buffer); |
|
311 |
||
312 |
if(!generateMipmap) |
|
313 |
{ |
|
314 |
// Restore original state. |
|
315 |
ctx->DGL().glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, origGenMipmapParam); |
|
316 |
} |
|
317 |
||
318 |
// Clear any possible error flag. |
|
319 |
if(ctx->DGL().glGetError() == GL_NO_ERROR) |
|
320 |
{ |
|
321 |
GLESTexture* texture = ctx->Texture(ctx->TextureBinding()); |
|
322 |
GLES_ASSERT(texture != NULL); |
|
323 |
texture->SetLevel(level, GL_RGBA, desc->m_width, desc->m_height); |
|
324 |
||
325 |
if(generateMipmap && origGenMipmapParam && level == 0) |
|
326 |
{ |
|
327 |
texture->GenerateMipmap(); |
|
328 |
} |
|
329 |
||
330 |
if(texture->Level(level)->boundSurface != NULL) |
|
331 |
{ |
|
332 |
glesReleaseTexImage(texture->Level(level)->boundSurface, texture->Name(), level); |
|
333 |
} |
|
334 |
texture->Level(level)->boundSurface = surface; |
|
335 |
||
336 |
ret = texture->Name(); |
|
337 |
} |
|
338 |
||
339 |
GLES_LEAVE_NO_ERROR_CHECK_RET(ret); |
|
340 |
} |
|
341 |
||
342 |
bool EGLtoGLESInterface::ReleaseTexImage( int name, int level ) |
|
343 |
{ |
|
344 |
GLES_ENTER_RET(false); |
|
345 |
||
346 |
ctx->GetHostError(); |
|
347 |
||
348 |
GLuint binding; |
|
349 |
ctx->DGL().glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&binding); |
|
350 |
ctx->DGL().glBindTexture(GL_TEXTURE_2D, (GLuint)name); |
|
351 |
ctx->DGL().glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
|
352 |
ctx->DGL().glBindTexture(GL_TEXTURE_2D, binding); |
|
353 |
||
354 |
GLES_LEAVE_NO_ERROR_CHECK_RET(ctx->DGL().glGetError() == GL_NO_ERROR); |
|
355 |
} |
|
356 |
||
357 |
bool EGLtoGLESInterface::CopyBuffers( void* buf, const SurfaceDescriptor* desc ) |
|
358 |
{ |
|
359 |
GLES_ENTER_RET(false); |
|
360 |
||
361 |
// Store the current error and clear the error flag. |
|
362 |
ctx->GetHostError(); |
|
363 |
||
364 |
GLenum internal_format, data_format, data_type; |
|
365 |
surfaceDescriptorToGLEnums(*desc, internal_format, data_format, data_type); |
|
366 |
||
367 |
GLint pack_alignment; |
|
368 |
ctx->DGL().glGetIntegerv(GL_PACK_ALIGNMENT, &pack_alignment); |
|
369 |
ctx->DGL().glPixelStorei(GL_PACK_ALIGNMENT, 1); |
|
370 |
ctx->DGL().glReadPixels(0, 0, desc->m_width, desc->m_height, data_format, data_type, buf); |
|
371 |
ctx->DGL().glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment); |
|
372 |
||
373 |
GLES_LEAVE_NO_ERROR_CHECK_RET(ctx->DGL().glGetError() == GL_NO_ERROR); |
|
374 |
} |
|
375 |
||
376 |
bool EGLtoGLESInterface::UpdateBuffers( void* buf, const SurfaceDescriptor* desc ) |
|
377 |
{ |
|
378 |
GLES_ENTER_RET(false); |
|
379 |
||
380 |
// Store the current error and clear the error flag. |
|
381 |
ctx->GetHostError(); |
|
382 |
||
383 |
GLenum internal_format, data_format, data_type; |
|
384 |
surfaceDescriptorToGLEnums(*desc, internal_format, data_format, data_type); |
|
385 |
||
386 |
GLint unpack_alignment; |
|
387 |
ctx->DGL().glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack_alignment); |
|
388 |
ctx->DGL().glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
|
389 |
ctx->DGL().glDrawPixels( desc->m_width, desc->m_height, data_format, data_type, buf ); |
|
390 |
ctx->DGL().glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment); |
|
391 |
||
392 |
GLES_LEAVE_NO_ERROR_CHECK_RET(ctx->DGL().glGetError() == GL_NO_ERROR); |
|
393 |
} |
|
394 |
||
395 |
void EGLtoGLESInterface::Flush() |
|
396 |
{ |
|
397 |
GLES_ENTER(); |
|
398 |
||
399 |
// Store the current error and clear the error flag. |
|
400 |
ctx->GetHostError(); |
|
401 |
||
402 |
ctx->DGL().glFlush(); |
|
403 |
||
404 |
ctx->DGL().glGetError(); |
|
405 |
||
406 |
GLES_LEAVE(); |
|
407 |
} |
|
408 |
||
409 |
void EGLtoGLESInterface::Finish() |
|
410 |
{ |
|
411 |
GLES_ENTER(); |
|
412 |
||
413 |
// Store the current error and clear the error flag. |
|
414 |
ctx->GetHostError(); |
|
415 |
||
416 |
ctx->DGL().glFinish(); |
|
417 |
||
418 |
ctx->DGL().glGetError(); |
|
419 |
||
420 |
GLES_LEAVE(); |
|
421 |
} |
|
422 |
||
423 |
/*static*/ IGLEStoEGLInterface* EGLtoGLESInterface::GetEGLInterface() |
|
424 |
{ |
|
425 |
return g_EGLtoGLESInterface.m_egl; |
|
426 |
} |