Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-opengles-mipmap-path-fix into lp:ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Merged
Approved by: Tim Peeters
Approved revision: 1682
Merged at revision: 1684
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-opengles-mipmap-path-fix
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 194 lines (+98/-30)
3 files modified
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+0/-1)
src/Ubuntu/Components/plugin/ucubuntushapetexture.h (+57/-3)
src/Ubuntu/Components/tools/createshapetextures.cpp (+41/-26)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-opengles-mipmap-path-fix
Reviewer Review Type Date Requested Status
Tim Peeters Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+274176@code.launchpad.net

Commit message

Fixed OpenGL ES 2 mipmap fallback.

OpenGL ES 2 doesn't support GL_TEXTURE_MAX_LEVEL by default, it is only available via an extension. It was working on the devices where this extension is available but not on the emulator.

Description of the change

Fixed OpenGL ES 2 mipmap fallback.

OpenGL ES 2 doesn't support GL_TEXTURE_MAX_LEVEL by default, it is only available via an extension. It was working on the devices where this extension is available but not on the emulator.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

Thanks. This prevents the need for setting texture max level and doesn't increase the size of the texture much.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
2--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-09-25 09:44:34 +0000
3+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-10-12 17:38:04 +0000
4@@ -1103,7 +1103,6 @@
5 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
6 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
7 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
8- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, shapeTextureMipmapCount - 1);
9 for (int j = 0; j < shapeTextureMipmapCount; j++) {
10 glTexImage2D(GL_TEXTURE_2D, j, GL_RGBA, shapeTextureMipmapWidth >> j,
11 shapeTextureMipmapHeight >> j, 0, GL_RGBA, GL_UNSIGNED_BYTE,
12
13=== modified file 'src/Ubuntu/Components/plugin/ucubuntushapetexture.h'
14--- src/Ubuntu/Components/plugin/ucubuntushapetexture.h 2015-09-10 11:04:16 +0000
15+++ src/Ubuntu/Components/plugin/ucubuntushapetexture.h 2015-10-12 17:38:04 +0000
16@@ -524,9 +524,11 @@
17
18 const int shapeTextureMipmapWidth = 256;
19 const int shapeTextureMipmapHeight = 256;
20-const int shapeTextureMipmapCount = 5;
21-static const int shapeTextureMipmapOffset[5] = { 0, 262144, 327680, 344064, 348160 };
22-static const unsigned char shapeTextureMipmapData[2][349185] = {
23+const int shapeTextureMipmapCount = 9;
24+static const int shapeTextureMipmapOffset[9] = {
25+ 0, 262144, 327680, 344064, 348160, 349184, 349440, 349504, 349520
26+};
27+static const unsigned char shapeTextureMipmapData[2][349525] = {
28 // Mipmap level 0.
29 "\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00"
30 "\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00"
31@@ -22356,6 +22358,32 @@
32 "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
33 "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
34 "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
35+ // Mipmap level 5.
36+ "\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x12\x00"
37+ "\x5e\x5e\x45\x00\x5e\x5e\x55\x00\x5e\x5e\x65\x00\x5e\x5e\x75\x06"
38+ "\x5e\x5e\x00\x00\x5e\x5e\x0d\x00\x5e\x42\xa1\x34\x30\x11\xfc\x9d"
39+ "\x18\x05\xff\xd5\x13\x03\xff\xe5\x0e\x01\xff\xf5\x0a\x00\xff\xff"
40+ "\x5e\x5e\x00\x00\x57\x3f\xa1\x53\x05\x00\xff\xfd\x00\x00\xff\xff"
41+ "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
42+ "\x5e\x5e\x12\x03\x13\x0e\xfc\xe7\x00\x00\xff\xff\x00\x00\xff\xff"
43+ "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
44+ "\x5e\x5e\x45\x34\x05\x03\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
45+ "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
46+ "\x5e\x5e\x56\x4f\x02\x02\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
47+ "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
48+ "\x5e\x5e\x65\x5e\x01\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
49+ "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
50+ "\x58\x55\x75\x6e\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
51+ "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
52+ // Mipmap level 6.
53+ "\x5e\x5e\x03\x00\x5e\x5e\x5a\x25\x53\x2b\xa7\x6f\x3f\x1d\xb7\x7f"
54+ "\x5e\x5e\x5b\x3f\x00\x00\xff\xfe\x00\x00\xff\xff\x00\x00\xff\xff"
55+ "\x28\x24\xa7\x9f\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
56+ "\x19\x18\xb7\xb3\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
57+ // Mipmap level 7.
58+ "\x5e\x5e\x70\x5a\x00\x00\xd8\xbc\x00\x00\xd8\xd5\x00\x00\xff\xff"
59+ // Mipmap level 8.
60+ "\x00\x00\xb7\xab"
61 ,
62 // Mipmap level 0.
63 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
64@@ -44186,4 +44214,30 @@
65 "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
66 "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
67 "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
68+ // Mipmap level 5.
69+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00"
70+ "\x3e\x00\x00\x00\x52\x00\x00\x00\x62\x00\x00\x00\x71\x03\x00\x00"
71+ "\x00\x00\x00\x00\x02\x00\x00\x00\x7c\x1d\x16\x00\xf5\x8d\x6e\x00"
72+ "\xff\xce\x8b\x00\xff\xe2\x92\x00\xff\xf2\x9a\x00\xff\xff\xa1\x00"
73+ "\x00\x00\x00\x00\x69\x28\x16\x00\xff\xf0\x9e\x00\xff\xff\xc8\x00"
74+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
75+ "\x00\x00\x00\x00\xd5\xb1\x6e\x00\xff\xff\xc8\x00\xff\xff\xcc\x00"
76+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
77+ "\x0d\x05\x00\x00\xff\xf7\x8b\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
78+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
79+ "\x1e\x17\x00\x00\xff\xff\x93\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
80+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
81+ "\x2d\x26\x00\x00\xff\xff\x9a\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
82+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
83+ "\x3d\x36\x00\x00\xff\xff\xa1\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
84+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
85+ // Mipmap level 6.
86+ "\x01\x00\x00\x00\x4c\x1b\x00\x00\xa3\x6b\x41\x00\xb5\x7d\x58\x00"
87+ "\x3f\x27\x00\x00\xff\xfa\xcb\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
88+ "\x8b\x83\x41\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
89+ "\x9b\x97\x58\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
90+ // Mipmap level 7.
91+ "\x63\x50\x00\x00\xd7\xbb\xc2\x00\xc8\xc5\xc2\x00\xff\xff\xcc\x00"
92+ // Mipmap level 8.
93+ "\xb2\xa6\xcc\x00"
94 };
95
96=== modified file 'src/Ubuntu/Components/tools/createshapetextures.cpp'
97--- src/Ubuntu/Components/tools/createshapetextures.cpp 2015-09-10 11:04:16 +0000
98+++ src/Ubuntu/Components/tools/createshapetextures.cpp 2015-10-12 17:38:04 +0000
99@@ -46,7 +46,7 @@
100 const int widthMipmap = 256;
101 const int heightMipmap = 256;
102 const int sizeMipmap = widthMipmap * heightMipmap;
103-const int mipmapCount = 5; // Minimum size is 16.
104+const int mipmapCount = 9; // Minimum size is 1.
105 const int biggestSize = size > sizeMipmap ? size : sizeMipmap;
106
107 // Shape buffers.
108@@ -317,31 +317,45 @@
109 cppOut.setIntegerBase(16);
110 cppOut.setFieldWidth(2);
111 cppOut.setPadChar('0');
112- for (int i = 0; i < size; i += 4) {
113- cppOut << " \""
114- << "\\x" << (data[i] & 0xff)
115- << "\\x" << ((data[i] >> 8) & 0xff)
116- << "\\x" << ((data[i] >> 16) & 0xff)
117- << "\\x" << ((data[i] >> 24) & 0xff)
118- << "\\x" << (data[i+1] & 0xff)
119- << "\\x" << ((data[i+1] >> 8) & 0xff)
120- << "\\x" << ((data[i+1] >> 16) & 0xff)
121- << "\\x" << ((data[i+1] >> 24) & 0xff)
122- << "\\x" << (data[i+2] & 0xff)
123- << "\\x" << ((data[i+2] >> 8) & 0xff)
124- << "\\x" << ((data[i+2] >> 16) & 0xff)
125- << "\\x" << ((data[i+2] >> 24) & 0xff)
126- << "\\x" << (data[i+3] & 0xff)
127- << "\\x" << ((data[i+3] >> 8) & 0xff)
128- << "\\x" << ((data[i+3] >> 16) & 0xff)
129- << "\\x" << ((data[i+3] >> 24) & 0xff);
130- cppOut.setFieldWidth(1);
131+ if (size >= 16) {
132+ for (int i = 0; i < size; i += 4) {
133+ cppOut << " \""
134+ << "\\x" << (data[i] & 0xff)
135+ << "\\x" << ((data[i] >> 8) & 0xff)
136+ << "\\x" << ((data[i] >> 16) & 0xff)
137+ << "\\x" << ((data[i] >> 24) & 0xff)
138+ << "\\x" << (data[i+1] & 0xff)
139+ << "\\x" << ((data[i+1] >> 8) & 0xff)
140+ << "\\x" << ((data[i+1] >> 16) & 0xff)
141+ << "\\x" << ((data[i+1] >> 24) & 0xff)
142+ << "\\x" << (data[i+2] & 0xff)
143+ << "\\x" << ((data[i+2] >> 8) & 0xff)
144+ << "\\x" << ((data[i+2] >> 16) & 0xff)
145+ << "\\x" << ((data[i+2] >> 24) & 0xff)
146+ << "\\x" << (data[i+3] & 0xff)
147+ << "\\x" << ((data[i+3] >> 8) & 0xff)
148+ << "\\x" << ((data[i+3] >> 16) & 0xff)
149+ << "\\x" << ((data[i+3] >> 24) & 0xff);
150+ cppOut.setFieldWidth(0);
151+ cppOut << "\"\n";
152+ cppOut.setFieldWidth(2);
153+ }
154+ cppOut.setIntegerBase(10);
155+ cppOut.setFieldWidth(0);
156+ cppOut.setPadChar(' ');
157+ } else {
158+ cppOut << " \"";
159+ for (int i = 0; i < size; i++) {
160+ cppOut << "\\x" << (data[i] & 0xff)
161+ << "\\x" << ((data[i] >> 8) & 0xff)
162+ << "\\x" << ((data[i] >> 16) & 0xff)
163+ << "\\x" << ((data[i] >> 24) & 0xff);
164+ }
165+ cppOut.setIntegerBase(10);
166+ cppOut.setFieldWidth(0);
167+ cppOut.setPadChar(' ');
168 cppOut << "\"\n";
169- cppOut.setFieldWidth(2);
170 }
171- cppOut.setIntegerBase(10);
172- cppOut.setFieldWidth(0);
173- cppOut.setPadChar(' ');
174 }
175
176 int main(int argc, char* argv[])
177@@ -392,14 +406,15 @@
178 cppOut << "const int shapeTextureMipmapWidth = " << widthMipmap << ";\n"
179 << "const int shapeTextureMipmapHeight = " << heightMipmap << ";\n"
180 << "const int shapeTextureMipmapCount = " << mipmapCount << ";\n"
181- << "static const int shapeTextureMipmapOffset[" << mipmapCount << "] = { 0";
182+ << "static const int shapeTextureMipmapOffset[" << mipmapCount << "] = {\n"
183+ << " 0";
184 int size = 0, i = 0;
185 for (int i = 0; i < mipmapCount-1; i++) {
186 size += (widthMipmap >> i) * (heightMipmap >> i) * 4;
187 cppOut << ", " << size;
188 }
189 size += (widthMipmap >> (mipmapCount-1)) * (heightMipmap >> (mipmapCount-1)) * 4;
190- cppOut << " };\n";
191+ cppOut << "\n};\n";
192 cppOut << "static const unsigned char shapeTextureMipmapData[" << textureCount
193 << "][" << size + 1 << "] = {\n";
194 for (int i = 0; i < mipmapCount; i++) {

Subscribers

People subscribed via source and target branches