author | Jon Medhurst |
Fri, 22 Oct 2010 13:37:16 +0100 | |
branch | bug235_bringup_0 |
changeset 64 | 5023b77b78d4 |
parent 53 | c2ef9095503a |
child 68 | 8d4efe9fa1cf |
permissions | -rw-r--r-- |
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 "GLESTexture.h" |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
32 |
#include "glesInternal.h" |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
33 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
34 |
GLESTexture::GLESTexture(unsigned int name) : |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
35 |
m_name(name), |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
36 |
m_numLevels(0), |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
37 |
m_levels(NULL) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
38 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
39 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
40 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
41 |
GLESTexture::~GLESTexture() |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
42 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
43 |
delete[] m_levels; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
44 |
} |
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 |
bool GLESTexture::AllocateLevels(int numLevels) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
47 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
48 |
GLES_ASSERT(m_levels == NULL); |
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 |
m_numLevels = numLevels; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
51 |
m_levels = GLES_NEW GLESTextureLevel[numLevels]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
52 |
if(m_levels == NULL) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
53 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
54 |
return false; |
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 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
57 |
for(int i = 0; i < numLevels; i++) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
58 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
59 |
// From desktop GL spec. |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
60 |
m_levels[i].format = 1; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
61 |
m_levels[i].width = 0; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
62 |
m_levels[i].height = 0; |
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 |
m_levels[i].boundSurface = NULL; |
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 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
67 |
return true; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
68 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
69 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
70 |
GLESTextureLevel* GLESTexture::Level(int level) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
71 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
72 |
GLES_ASSERT(m_levels != NULL); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
73 |
GLES_ASSERT(level >= 0 && level < m_numLevels); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
74 |
return &m_levels[level]; |
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 |
void GLESTexture::SetLevel(int level, GLenum format, GLsizei width, GLsizei height) |
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 |
GLES_ASSERT(m_levels != NULL); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
80 |
GLES_ASSERT(level >= 0 && level < m_numLevels); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
81 |
m_levels[level].format = format; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
82 |
m_levels[level].width = width; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
83 |
m_levels[level].height = height; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
84 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
85 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
86 |
void GLESTexture::GenerateMipmap() |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
87 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
88 |
GLES_ASSERT(m_levels != NULL); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
89 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
90 |
const GLESTextureLevel& level_zero = m_levels[0]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
91 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
92 |
m_numLevels = glesLog2(GLES_MAX(level_zero.width, level_zero.height)) + 1; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
93 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
94 |
int width = level_zero.width; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
95 |
int height = level_zero.height; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
96 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
97 |
for(int level = 1; level < m_numLevels; level++) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
98 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
99 |
if(width > 1) width /= 2; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
100 |
if(height > 1) height /= 2; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
101 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
102 |
GLES_ASSERT((width > 1 || height > 1) || level == m_numLevels - 1); |
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 |
m_levels[level].format = level_zero.format; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
105 |
m_levels[level].width = width; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
106 |
m_levels[level].height = height; |
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 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
109 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
110 |
bool glesIsValidCompressedFormat(GLenum format) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
111 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
112 |
switch(format) |
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 |
case GL_PALETTE4_RGB8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
115 |
case GL_PALETTE4_RGBA8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
116 |
case GL_PALETTE4_R5_G6_B5_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
117 |
case GL_PALETTE4_RGBA4_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
118 |
case GL_PALETTE4_RGB5_A1_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
119 |
case GL_PALETTE8_RGB8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
120 |
case GL_PALETTE8_RGBA8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
121 |
case GL_PALETTE8_R5_G6_B5_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
122 |
case GL_PALETTE8_RGBA4_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
123 |
case GL_PALETTE8_RGB5_A1_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
124 |
return true; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
125 |
default: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
126 |
return false; |
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 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
129 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
130 |
GLenum glesMapCompressedToBaseFormat(GLenum format) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
131 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
132 |
switch(format) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
133 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
134 |
case GL_PALETTE4_RGB8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
135 |
case GL_PALETTE4_R5_G6_B5_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
136 |
case GL_PALETTE8_RGB8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
137 |
case GL_PALETTE8_R5_G6_B5_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
138 |
return GL_RGB; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
139 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
140 |
case GL_PALETTE4_RGBA8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
141 |
case GL_PALETTE4_RGBA4_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
142 |
case GL_PALETTE4_RGB5_A1_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
143 |
case GL_PALETTE8_RGBA8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
144 |
case GL_PALETTE8_RGBA4_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
145 |
case GL_PALETTE8_RGB5_A1_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
146 |
return GL_RGBA; |
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 |
default: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
149 |
GLES_ASSERT(false); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
150 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
151 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
152 |
// not reached |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
153 |
return 0; |
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 |
void* glesUncompressImage(int level, GLenum format, int width, int height, int imageSize, const void* data) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
157 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
158 |
const unsigned char* palette = static_cast<const unsigned char*>(data); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
159 |
int bitsPerPixel; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
160 |
int paletteEntrySize; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
161 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
162 |
switch(format) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
163 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
164 |
case GL_PALETTE4_RGB8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
165 |
bitsPerPixel = 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
166 |
paletteEntrySize = 3; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
167 |
break; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
168 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
169 |
case GL_PALETTE4_RGBA8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
170 |
bitsPerPixel = 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
171 |
paletteEntrySize = 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
172 |
break; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
173 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
174 |
case GL_PALETTE4_R5_G6_B5_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
175 |
case GL_PALETTE4_RGB5_A1_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
176 |
case GL_PALETTE4_RGBA4_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
177 |
bitsPerPixel = 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
178 |
paletteEntrySize = 2; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
179 |
break; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
180 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
181 |
case GL_PALETTE8_RGB8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
182 |
bitsPerPixel = 8; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
183 |
paletteEntrySize = 3; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
184 |
break; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
185 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
186 |
case GL_PALETTE8_RGBA8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
187 |
bitsPerPixel = 8; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
188 |
paletteEntrySize = 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
189 |
break; |
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 |
case GL_PALETTE8_R5_G6_B5_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
192 |
case GL_PALETTE8_RGBA4_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
193 |
case GL_PALETTE8_RGB5_A1_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
194 |
bitsPerPixel = 8; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
195 |
paletteEntrySize = 2; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
196 |
break; |
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 |
default: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
199 |
GLES_ASSERT(false); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
200 |
} |
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 |
int numPaletteEntries = 2 << (bitsPerPixel - 1); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
203 |
const unsigned char* imageData = palette + numPaletteEntries * paletteEntrySize; |
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 |
// Skip to the correct mip level |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
206 |
for(int i = 0; i < level; i++) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
207 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
208 |
if(bitsPerPixel == 8) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
209 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
210 |
imageData += width * height * bitsPerPixel / 8; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
211 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
212 |
else |
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 |
GLES_ASSERT(bitsPerPixel == 4); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
215 |
imageData += width * height * bitsPerPixel / 8 / 2; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
216 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
217 |
width /= 2; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
218 |
height /= 2; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
219 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
220 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
221 |
int bytesPerPixel; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
222 |
GLenum baseFormat = glesMapCompressedToBaseFormat(format); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
223 |
if(baseFormat == GL_RGB) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
224 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
225 |
bytesPerPixel = 3; |
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 |
else |
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 |
GLES_ASSERT(baseFormat == GL_RGBA); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
230 |
bytesPerPixel = 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
231 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
232 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
233 |
char* uncompressedData = GLES_NEW char[width * height * bytesPerPixel]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
234 |
if(uncompressedData == NULL) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
235 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
236 |
return NULL; |
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 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
239 |
// Don't go past the end of the data |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
240 |
int pixelsPerByte = 8 / bitsPerPixel; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
241 |
int maxPixels = (static_cast<const unsigned char*>(data) + imageSize - imageData) * pixelsPerByte; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
242 |
int end = GLES_MIN(width * height, maxPixels); |
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 |
for(int i = 0; i < end; i++) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
245 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
246 |
int index; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
247 |
if(bitsPerPixel == 4) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
248 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
249 |
if(i & 1) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
250 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
251 |
index = imageData[i / 2] & 15; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
252 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
253 |
else |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
254 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
255 |
index = imageData[i / 2] >> 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
256 |
} |
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 |
else |
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 |
GLES_ASSERT(bitsPerPixel == 8); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
261 |
index = imageData[i]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
262 |
} |
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 |
int r, g, b, a; |
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 |
switch(format) |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
267 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
268 |
case GL_PALETTE4_RGB8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
269 |
case GL_PALETTE8_RGB8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
270 |
r = palette[index*3]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
271 |
g = palette[index*3+1]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
272 |
b = palette[index*3+2]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
273 |
break; |
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 GL_PALETTE4_RGBA8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
276 |
case GL_PALETTE8_RGBA8_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
277 |
r = palette[index*4]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
278 |
g = palette[index*4+1]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
279 |
b = palette[index*4+2]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
280 |
a = palette[index*4+3]; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
281 |
break; |
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 |
case GL_PALETTE4_R5_G6_B5_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
284 |
case GL_PALETTE8_R5_G6_B5_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
285 |
r = palette[index*2+1] >> 3; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
286 |
r = (r << 3) | (r >> 2); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
287 |
g = ((palette[index*2+1] & 7) << 3) | (palette[index*2] >> 5); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
288 |
g = (g << 2) | (g >> 4); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
289 |
b = palette[index*2] & 0x1f; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
290 |
b = (b << 3) | (b >> 2); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
291 |
break; |
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 |
case GL_PALETTE4_RGBA4_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
294 |
case GL_PALETTE8_RGBA4_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
295 |
r = palette[index*2+1] >> 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
296 |
r |= (r << 4) | r; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
297 |
g = palette[index*2+1] & 0xf; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
298 |
g |= (g << 4) | g; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
299 |
b = palette[index*2] >> 4; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
300 |
b |= (b << 4) | b; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
301 |
a = palette[index*2] & 0xf; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
302 |
a |= (a << 4) | a; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
303 |
break; |
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 |
case GL_PALETTE4_RGB5_A1_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
306 |
case GL_PALETTE8_RGB5_A1_OES: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
307 |
r = palette[index*2+1] >> 3; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
308 |
r = (r << 3) | (r >> 2); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
309 |
g = ((palette[index*2+1] & 7) << 2) | (palette[index*2] >> 6); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
310 |
g = (g << 3) | (g >> 2); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
311 |
b = (palette[index*2] >> 1) & 0x1f; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
312 |
b = (b << 3) | (b >> 2); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
313 |
a = (palette[index*2] & 1) ? 255 : 0; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
314 |
break; |
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 |
default: |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
317 |
GLES_ASSERT(false); |
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 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
320 |
if(baseFormat == GL_RGB) |
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 |
uncompressedData[i*3+0] = r; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
323 |
uncompressedData[i*3+1] = g; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
324 |
uncompressedData[i*3+2] = b; |
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 |
else |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
327 |
{ |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
328 |
GLES_ASSERT(baseFormat == GL_RGBA); |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
329 |
uncompressedData[i*4+0] = r; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
330 |
uncompressedData[i*4+1] = g; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
331 |
uncompressedData[i*4+2] = b; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
332 |
uncompressedData[i*4+3] = a; |
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 |
} |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
335 |
|
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
336 |
return uncompressedData; |
c2ef9095503a
Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff
changeset
|
337 |
} |