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
=== modified file 'debian/compiz-plugins.install.armel'
--- debian/compiz-plugins.install.armel 2013-02-03 22:55:55 +0000
+++ debian/compiz-plugins.install.armel 2013-07-07 15:20:32 +0000
@@ -44,6 +44,7 @@
44debian/tmp/usr/*/compiz/*wallpaper.*44debian/tmp/usr/*/compiz/*wallpaper.*
45debian/tmp/usr/*/compiz/*water.*45debian/tmp/usr/*/compiz/*water.*
46debian/tmp/usr/*/compiz/*winrules.*46debian/tmp/usr/*/compiz/*winrules.*
47debian/tmp/usr/*/compiz/*wizard.*
47debian/tmp/usr/*/compiz/*wobbly.*48debian/tmp/usr/*/compiz/*wobbly.*
48debian/tmp/usr/*/compiz/*workspacenames.*49debian/tmp/usr/*/compiz/*workspacenames.*
4950
5051
=== modified file 'debian/compiz-plugins.install.armhf'
--- debian/compiz-plugins.install.armhf 2013-02-03 22:55:55 +0000
+++ debian/compiz-plugins.install.armhf 2013-07-07 15:20:32 +0000
@@ -44,6 +44,7 @@
44debian/tmp/usr/*/compiz/*wallpaper.*44debian/tmp/usr/*/compiz/*wallpaper.*
45debian/tmp/usr/*/compiz/*water.*45debian/tmp/usr/*/compiz/*water.*
46debian/tmp/usr/*/compiz/*winrules.*46debian/tmp/usr/*/compiz/*winrules.*
47debian/tmp/usr/*/compiz/*wizard.*
47debian/tmp/usr/*/compiz/*wobbly.*48debian/tmp/usr/*/compiz/*wobbly.*
48debian/tmp/usr/*/compiz/*workspacenames.*49debian/tmp/usr/*/compiz/*workspacenames.*
4950
5051
=== modified file 'plugins/CMakeLists.txt'
--- plugins/CMakeLists.txt 2013-03-08 18:42:22 +0000
+++ plugins/CMakeLists.txt 2013-07-07 15:20:32 +0000
@@ -32,7 +32,6 @@
32 set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON)32 set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON)
33 set (COMPIZ_DISABLE_PLUGIN_WIDGET ON)33 set (COMPIZ_DISABLE_PLUGIN_WIDGET ON)
34 set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON)34 set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON)
35 set (COMPIZ_DISABLE_PLUGIN_WIZARD ON)
3635
37endif (BUILD_GLES)36endif (BUILD_GLES)
3837
3938
=== modified file 'plugins/wizard/include/wizard.h'
--- plugins/wizard/include/wizard.h 2010-09-14 01:57:47 +0000
+++ plugins/wizard/include/wizard.h 2013-07-07 15:20:32 +0000
@@ -32,6 +32,11 @@
32#include "wizard_options.h"32#include "wizard_options.h"
33#include "wizard_tex.h"33#include "wizard_tex.h"
3434
35extern const unsigned short CACHESIZE_FACTOR;
36extern const unsigned short COORD_COMPONENTS;
37extern const unsigned short VERTEX_COMPONENTS;
38extern const unsigned short COLOR_COMPONENTS;
39
35static float40static float
36rRange (float avg, float range)41rRange (float avg, float range)
37{42{
@@ -147,14 +152,13 @@
147 int ne; // Emitter count152 int ne; // Emitter count
148 int ng; // GPoint count153 int ng; // GPoint count
149154
150 GLfloat *vertices_cache;155 /* Cache used in drawParticles
151 int vertex_cache_count;156 It's here to avoid multiple mem allocation
152 GLfloat *coords_cache;157 during drawing */
153 int coords_cache_count;158 std::vector<GLfloat> vertices_cache;
154 GLfloat *colors_cache;159 std::vector<GLfloat> coords_cache;
155 int color_cache_count;160 std::vector<GLushort> colors_cache;
156 GLfloat *dcolors_cache;161 std::vector<GLushort> dcolors_cache;
157 int dcolors_cache_count;
158};162};
159163
160class WizardScreen :164class WizardScreen :
@@ -183,7 +187,8 @@
183187
184 void loadEmitters (ParticleSystem *ps);188 void loadEmitters (ParticleSystem *ps);
185189
186 void drawParticles (ParticleSystem * ps);190 void drawParticles (ParticleSystem *ps,
191 const GLMatrix &transform);
187192
188 void positionUpdate (const CompPoint &pos);193 void positionUpdate (const CompPoint &pos);
189194
190195
=== modified file 'plugins/wizard/src/wizard.cpp'
--- plugins/wizard/src/wizard.cpp 2013-05-09 13:43:07 +0000
+++ plugins/wizard/src/wizard.cpp 2013-07-07 15:20:32 +0000
@@ -29,6 +29,18 @@
2929
30#include "wizard.h"30#include "wizard.h"
3131
32/* 3 vertices per triangle, 2 triangles per particle */
33const unsigned short CACHESIZE_FACTOR = 3 * 2;
34
35/* 2 coordinates, x and y */
36const unsigned short COORD_COMPONENTS = CACHESIZE_FACTOR * 2;
37
38/* each vertex is stored as 3 GLfloats */
39const unsigned short VERTEX_COMPONENTS = CACHESIZE_FACTOR * 3;
40
41/* 4 colors, RGBA */
42const unsigned short COLOR_COMPONENTS = CACHESIZE_FACTOR * 4;
43
32static void44static void
33initParticles (int hardLimit, int softLimit, ParticleSystem * ps)45initParticles (int hardLimit, int softLimit, ParticleSystem * ps)
34{46{
@@ -42,14 +54,10 @@
42 ps->lastCount = 0;54 ps->lastCount = 0;
4355
44 // Initialize cache56 // Initialize cache
45 ps->vertices_cache = NULL;57 ps->vertices_cache.clear ();
46 ps->colors_cache = NULL;58 ps->coords_cache.clear ();
47 ps->coords_cache = NULL;59 ps->colors_cache.clear ();
48 ps->dcolors_cache = NULL;60 ps->dcolors_cache.clear ();
49 ps->vertex_cache_count = 0;
50 ps->color_cache_count = 0;
51 ps->coords_cache_count = 0;
52 ps->dcolors_cache_count = 0;
5361
54 Particle *part = ps->particles;62 Particle *part = ps->particles;
55 int i;63 int i;
@@ -277,77 +285,41 @@
277}285}
278286
279void287void
280WizardScreen::drawParticles (ParticleSystem * ps)288WizardScreen::drawParticles (ParticleSystem *ps,
289 const GLMatrix &transform)
281{290{
282 glPushMatrix ();291 int i, j, k, l;
292
293 /* Check that the cache is big enough */
294 if (ps->vertices_cache.size () < (unsigned int)ps->hardLimit * VERTEX_COMPONENTS)
295 ps->vertices_cache.resize (ps->hardLimit * VERTEX_COMPONENTS);
296
297 if (ps->coords_cache.size () < (unsigned int)ps->hardLimit * COORD_COMPONENTS)
298 ps->coords_cache.resize (ps->hardLimit * COORD_COMPONENTS);
299
300 if (ps->colors_cache.size () < (unsigned int)ps->hardLimit * COLOR_COMPONENTS)
301 ps->colors_cache.resize (ps->hardLimit * COLOR_COMPONENTS);
302
303 if (ps->darken > 0)
304 if (ps->dcolors_cache.size () < (unsigned int)ps->hardLimit * COLOR_COMPONENTS)
305 ps->dcolors_cache.resize (ps->hardLimit * COLOR_COMPONENTS);
283306
284 glEnable (GL_BLEND);307 glEnable (GL_BLEND);
308
285 if (ps->tex)309 if (ps->tex)
286 {310 {
287 glBindTexture (GL_TEXTURE_2D, ps->tex);311 glBindTexture (GL_TEXTURE_2D, ps->tex);
288 glEnable (GL_TEXTURE_2D);312 glEnable (GL_TEXTURE_2D);
289 }313 }
290 glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);314
291315 i = j = k = l = 0;
292 /* Check that the cache is big enough */
293 if (ps->hardLimit > ps->vertex_cache_count)
294 {
295 ps->vertices_cache =
296 (GLfloat*) realloc (ps->vertices_cache,
297 ps->hardLimit * 4 * 3 * sizeof (GLfloat));
298 ps->vertex_cache_count = ps->hardLimit;
299 }
300
301 if (ps->hardLimit > ps->coords_cache_count)
302 {
303 ps->coords_cache =
304 (GLfloat*) realloc (ps->coords_cache,
305 ps->hardLimit * 4 * 2 * sizeof (GLfloat));
306 ps->coords_cache_count = ps->hardLimit;
307 }
308
309 if (ps->hardLimit > ps->color_cache_count)
310 {
311 ps->colors_cache =
312 (GLfloat*) realloc (ps->colors_cache,
313 ps->hardLimit * 4 * 4 * sizeof (GLfloat));
314 ps->color_cache_count = ps->hardLimit;
315 }
316
317 if (ps->darken > 0)
318 {
319 if (ps->dcolors_cache_count < ps->hardLimit)
320 {
321 ps->dcolors_cache =
322 (GLfloat*) realloc (ps->dcolors_cache,
323 ps->hardLimit * 4 * 4 * sizeof (GLfloat));
324 ps->dcolors_cache_count = ps->hardLimit;
325 }
326 }
327
328 GLfloat *dcolors = ps->dcolors_cache;
329 GLfloat *vertices = ps->vertices_cache;
330 GLfloat *coords = ps->coords_cache;
331 GLfloat *colors = ps->colors_cache;
332
333 int cornersSize = sizeof (GLfloat) * 8;
334 int colorSize = sizeof (GLfloat) * 4;
335
336 GLfloat cornerCoords[8] = {0.0, 0.0,
337 0.0, 1.0,
338 1.0, 1.0,
339 1.0, 0.0};
340
341 int numActive = 0;
342316
343 Particle *part = ps->particles;317 Particle *part = ps->particles;
344 int i;318 int m;
345 for (i = 0; i < ps->hardLimit; i++, part++)319 for (m = 0; m < ps->hardLimit; m++, part++)
346 {320 {
347 if (part->t > 0.0f)321 if (part->t > 0.0f)
348 {322 {
349 numActive += 4;
350
351 float cOff = part->s / 2.; //Corner offset from center323 float cOff = part->s / 2.; //Corner offset from center
352324
353 if (part->t > ps->tnew) //New particles start larger325 if (part->t > ps->tnew) //New particles start larger
@@ -360,88 +332,167 @@
360 float offA = cOff * (cos (part->phi) - sin (part->phi));332 float offA = cOff * (cos (part->phi) - sin (part->phi));
361 float offB = cOff * (cos (part->phi) + sin (part->phi));333 float offB = cOff * (cos (part->phi) + sin (part->phi));
362334
363 vertices[0] = part->x - offB;335 GLushort r, g, b, a, dark_a;
364 vertices[1] = part->y - offA;336
365 vertices[2] = 0;337 r = part->c[0] * 65535.0f;
366338 g = part->c[1] * 65535.0f;
367 vertices[3] = part->x - offA;339 b = part->c[2] * 65535.0f;
368 vertices[4] = part->y + offB;
369 vertices[5] = 0;
370
371 vertices[6] = part->x + offB;
372 vertices[7] = part->y + offA;
373 vertices[8] = 0;
374
375 vertices[9] = part->x + offA;
376 vertices[10] = part->y - offB;
377 vertices[11] = 0;
378
379 vertices += 12;
380
381 memcpy (coords, cornerCoords, cornersSize);
382
383 coords += 8;
384
385 colors[0] = part->c[0];
386 colors[1] = part->c[1];
387 colors[2] = part->c[2];
388340
389 if (part->t > ps->tnew) //New particles start at a == 1341 if (part->t > ps->tnew) //New particles start at a == 1
390 colors[3] = part->a + (1. - part->a) * (part->t - ps->tnew)342 a = part->a + (1. - part->a) * (part->t - ps->tnew)
391 / (1. - ps->tnew);343 / (1. - ps->tnew) * 65535.0f;
392 else if (part->t < ps->told) //Old particles fade to a = 0344 else if (part->t < ps->told) //Old particles fade to a = 0
393 colors[3] = part->a * part->t / ps->told;345 a = part->a * part->t / ps->told * 65535.0f;
394 else //The others have their own a346 else //The others have their own a
395 colors[3] = part->a;347 a = part->a * 65535.0f;
396348
397 memcpy (colors + 4, colors, colorSize);349 dark_a = a * ps->darken;
398 memcpy (colors + 8, colors, colorSize);350
399 memcpy (colors + 12, colors, colorSize);351 //first triangle
400352 ps->vertices_cache[i + 0] = part->x - offB;
401 colors += 16;353 ps->vertices_cache[i + 1] = part->y - offA;
354 ps->vertices_cache[i + 2] = 0;
355
356 ps->vertices_cache[i + 3] = part->x - offA;
357 ps->vertices_cache[i + 4] = part->y + offB;
358 ps->vertices_cache[i + 5] = 0;
359
360 ps->vertices_cache[i + 6] = part->x + offB;
361 ps->vertices_cache[i + 7] = part->y + offA;
362 ps->vertices_cache[i + 8] = 0;
363
364 //second triangle
365 ps->vertices_cache[i + 9] = part->x + offB;
366 ps->vertices_cache[i + 10] = part->y + offA;
367 ps->vertices_cache[i + 11] = 0;
368
369 ps->vertices_cache[i + 12] = part->x + offA;
370 ps->vertices_cache[i + 13] = part->y - offB;
371 ps->vertices_cache[i + 14] = 0;
372
373 ps->vertices_cache[i + 15] = part->x - offB;
374 ps->vertices_cache[i + 16] = part->y - offA;
375 ps->vertices_cache[i + 17] = 0;
376
377 i += 18;
378
379 ps->coords_cache[j + 0] = 0.0;
380 ps->coords_cache[j + 1] = 0.0;
381
382 ps->coords_cache[j + 2] = 0.0;
383 ps->coords_cache[j + 3] = 1.0;
384
385 ps->coords_cache[j + 4] = 1.0;
386 ps->coords_cache[j + 5] = 1.0;
387
388 //second
389 ps->coords_cache[j + 6] = 1.0;
390 ps->coords_cache[j + 7] = 1.0;
391
392 ps->coords_cache[j + 8] = 1.0;
393 ps->coords_cache[j + 9] = 0.0;
394
395 ps->coords_cache[j + 10] = 0.0;
396 ps->coords_cache[j + 11] = 0.0;
397
398 j += 12;
399
400 ps->colors_cache[k + 0] = r;
401 ps->colors_cache[k + 1] = g;
402 ps->colors_cache[k + 2] = b;
403 ps->colors_cache[k + 3] = a;
404
405 ps->colors_cache[k + 4] = r;
406 ps->colors_cache[k + 5] = g;
407 ps->colors_cache[k + 6] = b;
408 ps->colors_cache[k + 7] = a;
409
410 ps->colors_cache[k + 8] = r;
411 ps->colors_cache[k + 9] = g;
412 ps->colors_cache[k + 10] = b;
413 ps->colors_cache[k + 11] = a;
414
415 //second
416 ps->colors_cache[k + 12] = r;
417 ps->colors_cache[k + 13] = g;
418 ps->colors_cache[k + 14] = b;
419 ps->colors_cache[k + 15] = a;
420
421 ps->colors_cache[k + 16] = r;
422 ps->colors_cache[k + 17] = g;
423 ps->colors_cache[k + 18] = b;
424 ps->colors_cache[k + 19] = a;
425
426 ps->colors_cache[k + 20] = r;
427 ps->colors_cache[k + 21] = g;
428 ps->colors_cache[k + 22] = b;
429 ps->colors_cache[k + 23] = a;
430
431 k += 24;
402432
403 if (ps->darken > 0)433 if (ps->darken > 0)
404 {434 {
405 dcolors[0] = colors[0];435 ps->dcolors_cache[l + 0] = r;
406 dcolors[1] = colors[1];436 ps->dcolors_cache[l + 1] = g;
407 dcolors[2] = colors[2];437 ps->dcolors_cache[l + 2] = b;
408 dcolors[3] = colors[3] * ps->darken;438 ps->dcolors_cache[l + 3] = dark_a;
409 memcpy (dcolors + 4, dcolors, colorSize);439
410 memcpy (dcolors + 8, dcolors, colorSize);440 ps->dcolors_cache[l + 4] = r;
411 memcpy (dcolors + 12, dcolors, colorSize);441 ps->dcolors_cache[l + 5] = g;
412442 ps->dcolors_cache[l + 6] = b;
413 dcolors += 16;443 ps->dcolors_cache[l + 7] = dark_a;
444
445 ps->dcolors_cache[l + 8] = r;
446 ps->dcolors_cache[l + 9] = g;
447 ps->dcolors_cache[l + 10] = b;
448 ps->dcolors_cache[l + 11] = dark_a;
449
450 //second
451 ps->dcolors_cache[l + 12] = r;
452 ps->dcolors_cache[l + 13] = g;
453 ps->dcolors_cache[l + 14] = b;
454 ps->dcolors_cache[l + 15] = dark_a;
455
456 ps->dcolors_cache[l + 16] = r;
457 ps->dcolors_cache[l + 17] = g;
458 ps->dcolors_cache[l + 18] = b;
459 ps->dcolors_cache[l + 19] = dark_a;
460
461 ps->dcolors_cache[l + 20] = r;
462 ps->dcolors_cache[l + 21] = g;
463 ps->dcolors_cache[l + 22] = b;
464 ps->dcolors_cache[l + 23] = dark_a;
465
466 l += 24;
414 }467 }
415 }468 }
416 }469 }
417 glEnableClientState (GL_VERTEX_ARRAY);470
418 glEnableClientState (GL_TEXTURE_COORD_ARRAY);471 GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
419 glEnableClientState (GL_COLOR_ARRAY);472
420
421 glTexCoordPointer (2, GL_FLOAT, 2 * sizeof (GLfloat), ps->coords_cache);
422 glVertexPointer (3, GL_FLOAT, 3 * sizeof (GLfloat), ps->vertices_cache);
423
424 // darken the background
425 if (ps->darken > 0)473 if (ps->darken > 0)
426 {474 {
427 glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);475 glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
428 glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), ps->dcolors_cache);476 stream->begin (GL_TRIANGLES);
429 glDrawArrays (GL_QUADS, 0, numActive);477 stream->addVertices (i / 3, &ps->vertices_cache[0]);
478 stream->addTexCoords (0, j / 2, &ps->coords_cache[0]);
479 stream->addColors (l / 4, &ps->dcolors_cache[0]);
480
481 if (stream->end ())
482 stream->render (transform);
430 }483 }
431 // draw particles484
485 /* draw particles */
432 glBlendFunc (GL_SRC_ALPHA, ps->blendMode);486 glBlendFunc (GL_SRC_ALPHA, ps->blendMode);
433487 stream->begin (GL_TRIANGLES);
434 glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), ps->colors_cache);488
435489 stream->addVertices (i / 3, &ps->vertices_cache[0]);
436 glDrawArrays (GL_QUADS, 0, numActive);490 stream->addTexCoords (0, j / 2, &ps->coords_cache[0]);
437491 stream->addColors (k / 4, &ps->colors_cache[0]);
438 glDisableClientState (GL_COLOR_ARRAY);492
439 glDisableClientState (GL_TEXTURE_COORD_ARRAY);493 if (stream->end ())
440 glDisableClientState (GL_VERTEX_ARRAY);494 stream->render (transform);
441495
442 glPopMatrix ();
443 glColor4usv (defaultColor);
444 gScreen->setTexEnvMode (GL_REPLACE);
445 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);496 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
446 glDisable (GL_TEXTURE_2D);497 glDisable (GL_TEXTURE_2D);
447 glDisable (GL_BLEND);498 glDisable (GL_BLEND);
@@ -537,16 +588,9 @@
537 if (ps->tex)588 if (ps->tex)
538 glDeleteTextures (1, &ps->tex);589 glDeleteTextures (1, &ps->tex);
539590
540 if (ps->vertices_cache)
541 free (ps->vertices_cache);
542 if (ps->colors_cache)
543 free (ps->colors_cache);
544 if (ps->coords_cache)
545 free (ps->coords_cache);
546 if (ps->dcolors_cache)
547 free (ps->dcolors_cache);
548}591}
549592
593
550static void594static void
551genNewParticles (ParticleSystem *ps, Emitter *e)595genNewParticles (ParticleSystem *ps, Emitter *e)
552{596{
@@ -874,26 +918,15 @@
874 CompOutput *output,918 CompOutput *output,
875 unsigned int mask)919 unsigned int mask)
876{920{
877 bool status;921 bool status = gScreen->glPaintOutput (sa, transform, region, output, mask);
878 GLMatrix sTransform;922 GLMatrix sTransform = transform;
879
880 status = gScreen->glPaintOutput (sa, transform, region, output, mask);
881923
882 if (!ps || !ps->active)924 if (!ps || !ps->active)
883 return status;925 return status;
884926
885 sTransform.reset ();
886
887 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);927 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
888928
889 glPushMatrix ();929 drawParticles (ps, sTransform);
890 glLoadMatrixf (sTransform.getMatrix ());
891
892 drawParticles (ps);
893
894 glPopMatrix ();
895
896 glColor4usv (defaultColor);
897930
898 return status;931 return status;
899}932}

Subscribers

People subscribed via source and target branches