Merge lp:~bitzesmichail/compiz/wizardGLES into lp:compiz/0.9.10

Proposed by Michail Bitzes
Status: Merged
Approved by: MC Return
Approved revision: 3754
Merged at revision: 3756
Proposed branch: lp:~bitzesmichail/compiz/wizardGLES
Merge into: lp:compiz/0.9.10
Diff against target: 508 lines (+204/-165)
5 files modified
debian/compiz-plugins.install.armel (+1/-0)
debian/compiz-plugins.install.armhf (+1/-0)
plugins/CMakeLists.txt (+0/-1)
plugins/wizard/include/wizard.h (+14/-9)
plugins/wizard/src/wizard.cpp (+188/-155)
To merge this branch: bzr merge lp:~bitzesmichail/compiz/wizardGLES
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
MC Return Approve
Review via email: mp+173358@code.launchpad.net

Commit message

Plugin wizard ported to OpenGL|ES.

Use GLVertexBuffer.
Enable building for GLES. Enable architectures armel and armhf.

(LP: #1196003)

Description of the change

Just the OpenGL|ES port. Bug #1195996 not fixed in this branch.

To post a comment you must log in.
Revision history for this message
MC Return (mc-return) wrote :

Hey Michail !

LGTM @ a first glance. I will test this ASAP (on OpenGL hw). :)
But knowing you, I'm sure it is perfect ;)

The merge of this might take a while though, as the release of 0.9.10.0 gets prepared currently...

Revision history for this message
MC Return (mc-return) wrote :

This is now tested and worx perfectly as expected. :)
+1

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

Andyrock told me trunk is unblocked, so this can still make it to 0.9.10.0 it seems. :)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/compiz-plugins.install.armel'
2--- debian/compiz-plugins.install.armel 2013-02-03 22:55:55 +0000
3+++ debian/compiz-plugins.install.armel 2013-07-07 15:20:32 +0000
4@@ -44,6 +44,7 @@
5 debian/tmp/usr/*/compiz/*wallpaper.*
6 debian/tmp/usr/*/compiz/*water.*
7 debian/tmp/usr/*/compiz/*winrules.*
8+debian/tmp/usr/*/compiz/*wizard.*
9 debian/tmp/usr/*/compiz/*wobbly.*
10 debian/tmp/usr/*/compiz/*workspacenames.*
11
12
13=== modified file 'debian/compiz-plugins.install.armhf'
14--- debian/compiz-plugins.install.armhf 2013-02-03 22:55:55 +0000
15+++ debian/compiz-plugins.install.armhf 2013-07-07 15:20:32 +0000
16@@ -44,6 +44,7 @@
17 debian/tmp/usr/*/compiz/*wallpaper.*
18 debian/tmp/usr/*/compiz/*water.*
19 debian/tmp/usr/*/compiz/*winrules.*
20+debian/tmp/usr/*/compiz/*wizard.*
21 debian/tmp/usr/*/compiz/*wobbly.*
22 debian/tmp/usr/*/compiz/*workspacenames.*
23
24
25=== modified file 'plugins/CMakeLists.txt'
26--- plugins/CMakeLists.txt 2013-03-08 18:42:22 +0000
27+++ plugins/CMakeLists.txt 2013-07-07 15:20:32 +0000
28@@ -32,7 +32,6 @@
29 set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON)
30 set (COMPIZ_DISABLE_PLUGIN_WIDGET ON)
31 set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON)
32- set (COMPIZ_DISABLE_PLUGIN_WIZARD ON)
33
34 endif (BUILD_GLES)
35
36
37=== modified file 'plugins/wizard/include/wizard.h'
38--- plugins/wizard/include/wizard.h 2010-09-14 01:57:47 +0000
39+++ plugins/wizard/include/wizard.h 2013-07-07 15:20:32 +0000
40@@ -32,6 +32,11 @@
41 #include "wizard_options.h"
42 #include "wizard_tex.h"
43
44+extern const unsigned short CACHESIZE_FACTOR;
45+extern const unsigned short COORD_COMPONENTS;
46+extern const unsigned short VERTEX_COMPONENTS;
47+extern const unsigned short COLOR_COMPONENTS;
48+
49 static float
50 rRange (float avg, float range)
51 {
52@@ -147,14 +152,13 @@
53 int ne; // Emitter count
54 int ng; // GPoint count
55
56- GLfloat *vertices_cache;
57- int vertex_cache_count;
58- GLfloat *coords_cache;
59- int coords_cache_count;
60- GLfloat *colors_cache;
61- int color_cache_count;
62- GLfloat *dcolors_cache;
63- int dcolors_cache_count;
64+ /* Cache used in drawParticles
65+ It's here to avoid multiple mem allocation
66+ during drawing */
67+ std::vector<GLfloat> vertices_cache;
68+ std::vector<GLfloat> coords_cache;
69+ std::vector<GLushort> colors_cache;
70+ std::vector<GLushort> dcolors_cache;
71 };
72
73 class WizardScreen :
74@@ -183,7 +187,8 @@
75
76 void loadEmitters (ParticleSystem *ps);
77
78- void drawParticles (ParticleSystem * ps);
79+ void drawParticles (ParticleSystem *ps,
80+ const GLMatrix &transform);
81
82 void positionUpdate (const CompPoint &pos);
83
84
85=== modified file 'plugins/wizard/src/wizard.cpp'
86--- plugins/wizard/src/wizard.cpp 2013-05-09 13:43:07 +0000
87+++ plugins/wizard/src/wizard.cpp 2013-07-07 15:20:32 +0000
88@@ -29,6 +29,18 @@
89
90 #include "wizard.h"
91
92+/* 3 vertices per triangle, 2 triangles per particle */
93+const unsigned short CACHESIZE_FACTOR = 3 * 2;
94+
95+/* 2 coordinates, x and y */
96+const unsigned short COORD_COMPONENTS = CACHESIZE_FACTOR * 2;
97+
98+/* each vertex is stored as 3 GLfloats */
99+const unsigned short VERTEX_COMPONENTS = CACHESIZE_FACTOR * 3;
100+
101+/* 4 colors, RGBA */
102+const unsigned short COLOR_COMPONENTS = CACHESIZE_FACTOR * 4;
103+
104 static void
105 initParticles (int hardLimit, int softLimit, ParticleSystem * ps)
106 {
107@@ -42,14 +54,10 @@
108 ps->lastCount = 0;
109
110 // Initialize cache
111- ps->vertices_cache = NULL;
112- ps->colors_cache = NULL;
113- ps->coords_cache = NULL;
114- ps->dcolors_cache = NULL;
115- ps->vertex_cache_count = 0;
116- ps->color_cache_count = 0;
117- ps->coords_cache_count = 0;
118- ps->dcolors_cache_count = 0;
119+ ps->vertices_cache.clear ();
120+ ps->coords_cache.clear ();
121+ ps->colors_cache.clear ();
122+ ps->dcolors_cache.clear ();
123
124 Particle *part = ps->particles;
125 int i;
126@@ -277,77 +285,41 @@
127 }
128
129 void
130-WizardScreen::drawParticles (ParticleSystem * ps)
131+WizardScreen::drawParticles (ParticleSystem *ps,
132+ const GLMatrix &transform)
133 {
134- glPushMatrix ();
135+ int i, j, k, l;
136+
137+ /* Check that the cache is big enough */
138+ if (ps->vertices_cache.size () < (unsigned int)ps->hardLimit * VERTEX_COMPONENTS)
139+ ps->vertices_cache.resize (ps->hardLimit * VERTEX_COMPONENTS);
140+
141+ if (ps->coords_cache.size () < (unsigned int)ps->hardLimit * COORD_COMPONENTS)
142+ ps->coords_cache.resize (ps->hardLimit * COORD_COMPONENTS);
143+
144+ if (ps->colors_cache.size () < (unsigned int)ps->hardLimit * COLOR_COMPONENTS)
145+ ps->colors_cache.resize (ps->hardLimit * COLOR_COMPONENTS);
146+
147+ if (ps->darken > 0)
148+ if (ps->dcolors_cache.size () < (unsigned int)ps->hardLimit * COLOR_COMPONENTS)
149+ ps->dcolors_cache.resize (ps->hardLimit * COLOR_COMPONENTS);
150
151 glEnable (GL_BLEND);
152+
153 if (ps->tex)
154 {
155 glBindTexture (GL_TEXTURE_2D, ps->tex);
156 glEnable (GL_TEXTURE_2D);
157 }
158- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
159-
160- /* Check that the cache is big enough */
161- if (ps->hardLimit > ps->vertex_cache_count)
162- {
163- ps->vertices_cache =
164- (GLfloat*) realloc (ps->vertices_cache,
165- ps->hardLimit * 4 * 3 * sizeof (GLfloat));
166- ps->vertex_cache_count = ps->hardLimit;
167- }
168-
169- if (ps->hardLimit > ps->coords_cache_count)
170- {
171- ps->coords_cache =
172- (GLfloat*) realloc (ps->coords_cache,
173- ps->hardLimit * 4 * 2 * sizeof (GLfloat));
174- ps->coords_cache_count = ps->hardLimit;
175- }
176-
177- if (ps->hardLimit > ps->color_cache_count)
178- {
179- ps->colors_cache =
180- (GLfloat*) realloc (ps->colors_cache,
181- ps->hardLimit * 4 * 4 * sizeof (GLfloat));
182- ps->color_cache_count = ps->hardLimit;
183- }
184-
185- if (ps->darken > 0)
186- {
187- if (ps->dcolors_cache_count < ps->hardLimit)
188- {
189- ps->dcolors_cache =
190- (GLfloat*) realloc (ps->dcolors_cache,
191- ps->hardLimit * 4 * 4 * sizeof (GLfloat));
192- ps->dcolors_cache_count = ps->hardLimit;
193- }
194- }
195-
196- GLfloat *dcolors = ps->dcolors_cache;
197- GLfloat *vertices = ps->vertices_cache;
198- GLfloat *coords = ps->coords_cache;
199- GLfloat *colors = ps->colors_cache;
200-
201- int cornersSize = sizeof (GLfloat) * 8;
202- int colorSize = sizeof (GLfloat) * 4;
203-
204- GLfloat cornerCoords[8] = {0.0, 0.0,
205- 0.0, 1.0,
206- 1.0, 1.0,
207- 1.0, 0.0};
208-
209- int numActive = 0;
210+
211+ i = j = k = l = 0;
212
213 Particle *part = ps->particles;
214- int i;
215- for (i = 0; i < ps->hardLimit; i++, part++)
216+ int m;
217+ for (m = 0; m < ps->hardLimit; m++, part++)
218 {
219 if (part->t > 0.0f)
220 {
221- numActive += 4;
222-
223 float cOff = part->s / 2.; //Corner offset from center
224
225 if (part->t > ps->tnew) //New particles start larger
226@@ -360,88 +332,167 @@
227 float offA = cOff * (cos (part->phi) - sin (part->phi));
228 float offB = cOff * (cos (part->phi) + sin (part->phi));
229
230- vertices[0] = part->x - offB;
231- vertices[1] = part->y - offA;
232- vertices[2] = 0;
233-
234- vertices[3] = part->x - offA;
235- vertices[4] = part->y + offB;
236- vertices[5] = 0;
237-
238- vertices[6] = part->x + offB;
239- vertices[7] = part->y + offA;
240- vertices[8] = 0;
241-
242- vertices[9] = part->x + offA;
243- vertices[10] = part->y - offB;
244- vertices[11] = 0;
245-
246- vertices += 12;
247-
248- memcpy (coords, cornerCoords, cornersSize);
249-
250- coords += 8;
251-
252- colors[0] = part->c[0];
253- colors[1] = part->c[1];
254- colors[2] = part->c[2];
255+ GLushort r, g, b, a, dark_a;
256+
257+ r = part->c[0] * 65535.0f;
258+ g = part->c[1] * 65535.0f;
259+ b = part->c[2] * 65535.0f;
260
261 if (part->t > ps->tnew) //New particles start at a == 1
262- colors[3] = part->a + (1. - part->a) * (part->t - ps->tnew)
263- / (1. - ps->tnew);
264+ a = part->a + (1. - part->a) * (part->t - ps->tnew)
265+ / (1. - ps->tnew) * 65535.0f;
266 else if (part->t < ps->told) //Old particles fade to a = 0
267- colors[3] = part->a * part->t / ps->told;
268+ a = part->a * part->t / ps->told * 65535.0f;
269 else //The others have their own a
270- colors[3] = part->a;
271-
272- memcpy (colors + 4, colors, colorSize);
273- memcpy (colors + 8, colors, colorSize);
274- memcpy (colors + 12, colors, colorSize);
275-
276- colors += 16;
277+ a = part->a * 65535.0f;
278+
279+ dark_a = a * ps->darken;
280+
281+ //first triangle
282+ ps->vertices_cache[i + 0] = part->x - offB;
283+ ps->vertices_cache[i + 1] = part->y - offA;
284+ ps->vertices_cache[i + 2] = 0;
285+
286+ ps->vertices_cache[i + 3] = part->x - offA;
287+ ps->vertices_cache[i + 4] = part->y + offB;
288+ ps->vertices_cache[i + 5] = 0;
289+
290+ ps->vertices_cache[i + 6] = part->x + offB;
291+ ps->vertices_cache[i + 7] = part->y + offA;
292+ ps->vertices_cache[i + 8] = 0;
293+
294+ //second triangle
295+ ps->vertices_cache[i + 9] = part->x + offB;
296+ ps->vertices_cache[i + 10] = part->y + offA;
297+ ps->vertices_cache[i + 11] = 0;
298+
299+ ps->vertices_cache[i + 12] = part->x + offA;
300+ ps->vertices_cache[i + 13] = part->y - offB;
301+ ps->vertices_cache[i + 14] = 0;
302+
303+ ps->vertices_cache[i + 15] = part->x - offB;
304+ ps->vertices_cache[i + 16] = part->y - offA;
305+ ps->vertices_cache[i + 17] = 0;
306+
307+ i += 18;
308+
309+ ps->coords_cache[j + 0] = 0.0;
310+ ps->coords_cache[j + 1] = 0.0;
311+
312+ ps->coords_cache[j + 2] = 0.0;
313+ ps->coords_cache[j + 3] = 1.0;
314+
315+ ps->coords_cache[j + 4] = 1.0;
316+ ps->coords_cache[j + 5] = 1.0;
317+
318+ //second
319+ ps->coords_cache[j + 6] = 1.0;
320+ ps->coords_cache[j + 7] = 1.0;
321+
322+ ps->coords_cache[j + 8] = 1.0;
323+ ps->coords_cache[j + 9] = 0.0;
324+
325+ ps->coords_cache[j + 10] = 0.0;
326+ ps->coords_cache[j + 11] = 0.0;
327+
328+ j += 12;
329+
330+ ps->colors_cache[k + 0] = r;
331+ ps->colors_cache[k + 1] = g;
332+ ps->colors_cache[k + 2] = b;
333+ ps->colors_cache[k + 3] = a;
334+
335+ ps->colors_cache[k + 4] = r;
336+ ps->colors_cache[k + 5] = g;
337+ ps->colors_cache[k + 6] = b;
338+ ps->colors_cache[k + 7] = a;
339+
340+ ps->colors_cache[k + 8] = r;
341+ ps->colors_cache[k + 9] = g;
342+ ps->colors_cache[k + 10] = b;
343+ ps->colors_cache[k + 11] = a;
344+
345+ //second
346+ ps->colors_cache[k + 12] = r;
347+ ps->colors_cache[k + 13] = g;
348+ ps->colors_cache[k + 14] = b;
349+ ps->colors_cache[k + 15] = a;
350+
351+ ps->colors_cache[k + 16] = r;
352+ ps->colors_cache[k + 17] = g;
353+ ps->colors_cache[k + 18] = b;
354+ ps->colors_cache[k + 19] = a;
355+
356+ ps->colors_cache[k + 20] = r;
357+ ps->colors_cache[k + 21] = g;
358+ ps->colors_cache[k + 22] = b;
359+ ps->colors_cache[k + 23] = a;
360+
361+ k += 24;
362
363 if (ps->darken > 0)
364 {
365- dcolors[0] = colors[0];
366- dcolors[1] = colors[1];
367- dcolors[2] = colors[2];
368- dcolors[3] = colors[3] * ps->darken;
369- memcpy (dcolors + 4, dcolors, colorSize);
370- memcpy (dcolors + 8, dcolors, colorSize);
371- memcpy (dcolors + 12, dcolors, colorSize);
372-
373- dcolors += 16;
374+ ps->dcolors_cache[l + 0] = r;
375+ ps->dcolors_cache[l + 1] = g;
376+ ps->dcolors_cache[l + 2] = b;
377+ ps->dcolors_cache[l + 3] = dark_a;
378+
379+ ps->dcolors_cache[l + 4] = r;
380+ ps->dcolors_cache[l + 5] = g;
381+ ps->dcolors_cache[l + 6] = b;
382+ ps->dcolors_cache[l + 7] = dark_a;
383+
384+ ps->dcolors_cache[l + 8] = r;
385+ ps->dcolors_cache[l + 9] = g;
386+ ps->dcolors_cache[l + 10] = b;
387+ ps->dcolors_cache[l + 11] = dark_a;
388+
389+ //second
390+ ps->dcolors_cache[l + 12] = r;
391+ ps->dcolors_cache[l + 13] = g;
392+ ps->dcolors_cache[l + 14] = b;
393+ ps->dcolors_cache[l + 15] = dark_a;
394+
395+ ps->dcolors_cache[l + 16] = r;
396+ ps->dcolors_cache[l + 17] = g;
397+ ps->dcolors_cache[l + 18] = b;
398+ ps->dcolors_cache[l + 19] = dark_a;
399+
400+ ps->dcolors_cache[l + 20] = r;
401+ ps->dcolors_cache[l + 21] = g;
402+ ps->dcolors_cache[l + 22] = b;
403+ ps->dcolors_cache[l + 23] = dark_a;
404+
405+ l += 24;
406 }
407 }
408 }
409- glEnableClientState (GL_VERTEX_ARRAY);
410- glEnableClientState (GL_TEXTURE_COORD_ARRAY);
411- glEnableClientState (GL_COLOR_ARRAY);
412-
413- glTexCoordPointer (2, GL_FLOAT, 2 * sizeof (GLfloat), ps->coords_cache);
414- glVertexPointer (3, GL_FLOAT, 3 * sizeof (GLfloat), ps->vertices_cache);
415-
416- // darken the background
417+
418+ GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
419+
420 if (ps->darken > 0)
421 {
422 glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
423- glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), ps->dcolors_cache);
424- glDrawArrays (GL_QUADS, 0, numActive);
425+ stream->begin (GL_TRIANGLES);
426+ stream->addVertices (i / 3, &ps->vertices_cache[0]);
427+ stream->addTexCoords (0, j / 2, &ps->coords_cache[0]);
428+ stream->addColors (l / 4, &ps->dcolors_cache[0]);
429+
430+ if (stream->end ())
431+ stream->render (transform);
432 }
433- // draw particles
434+
435+ /* draw particles */
436 glBlendFunc (GL_SRC_ALPHA, ps->blendMode);
437-
438- glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), ps->colors_cache);
439-
440- glDrawArrays (GL_QUADS, 0, numActive);
441-
442- glDisableClientState (GL_COLOR_ARRAY);
443- glDisableClientState (GL_TEXTURE_COORD_ARRAY);
444- glDisableClientState (GL_VERTEX_ARRAY);
445-
446- glPopMatrix ();
447- glColor4usv (defaultColor);
448- gScreen->setTexEnvMode (GL_REPLACE);
449+ stream->begin (GL_TRIANGLES);
450+
451+ stream->addVertices (i / 3, &ps->vertices_cache[0]);
452+ stream->addTexCoords (0, j / 2, &ps->coords_cache[0]);
453+ stream->addColors (k / 4, &ps->colors_cache[0]);
454+
455+ if (stream->end ())
456+ stream->render (transform);
457+
458 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
459 glDisable (GL_TEXTURE_2D);
460 glDisable (GL_BLEND);
461@@ -537,16 +588,9 @@
462 if (ps->tex)
463 glDeleteTextures (1, &ps->tex);
464
465- if (ps->vertices_cache)
466- free (ps->vertices_cache);
467- if (ps->colors_cache)
468- free (ps->colors_cache);
469- if (ps->coords_cache)
470- free (ps->coords_cache);
471- if (ps->dcolors_cache)
472- free (ps->dcolors_cache);
473 }
474
475+
476 static void
477 genNewParticles (ParticleSystem *ps, Emitter *e)
478 {
479@@ -874,26 +918,15 @@
480 CompOutput *output,
481 unsigned int mask)
482 {
483- bool status;
484- GLMatrix sTransform;
485-
486- status = gScreen->glPaintOutput (sa, transform, region, output, mask);
487+ bool status = gScreen->glPaintOutput (sa, transform, region, output, mask);
488+ GLMatrix sTransform = transform;
489
490 if (!ps || !ps->active)
491 return status;
492
493- sTransform.reset ();
494-
495 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
496
497- glPushMatrix ();
498- glLoadMatrixf (sTransform.getMatrix ());
499-
500- drawParticles (ps);
501-
502- glPopMatrix ();
503-
504- glColor4usv (defaultColor);
505+ drawParticles (ps, sTransform);
506
507 return status;
508 }

Subscribers

People subscribed via source and target branches