Merge lp:~mc-return/compiz/compiz.merge-annotate-cleanup into lp:compiz/0.9.10

Proposed by MC Return
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3706
Merged at revision: 3714
Proposed branch: lp:~mc-return/compiz/compiz.merge-annotate-cleanup
Merge into: lp:compiz/0.9.10
Diff against target: 911 lines (+269/-271)
2 files modified
plugins/annotate/src/annotate.cpp (+201/-204)
plugins/annotate/src/annotate.h (+68/-67)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-annotate-cleanup
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Sam Spilsbury Approve
MC Return Needs Resubmitting
Review via email: mp+163876@code.launchpad.net

Commit message

Annotate plugin, code cleanup:

Use prefix instead of postfix increment.
Declaration and assignment of local variables in one line.
Removed redundant brackets.
Added and removed newlines if appropriate.
Fixed indentation.

Annotate plugin, fixes:

Use GL_LINE_LOOP to draw the rectangle outline as glRecti is not supported on GLES.
Simplified the coordinate calculation as the offset is not really needed here.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

25 /* draw rectangle outline */
626 -/* streamingBuffer->begin ();
627 + streamingBuffer->begin ();
628
629 streamingBuffer->addColors (1, optionGetStrokeColor ());
630
631 @@ -777,7 +761,7 @@
632 glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,
633 rectangle.x2 () + offset, rectangle.y1 () - offset);
634 glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,
635 - rectangle.x2 () + offset, rectangle.y2 () - offset);*/
636 + rectangle.x2 () + offset, rectangle.y2 () - offset);

That will break on GLES builds, glRecti isn't supported there.

Can you convert this to use GL_TRIANGLE_STRIP?

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

> 25 /* draw rectangle outline */
> 626 -/* streamingBuffer->begin ();
> 627 + streamingBuffer->begin ();
> 628
> 629 streamingBuffer->addColors (1, optionGetStrokeColor ());
> 630
> 631 @@ -777,7 +761,7 @@
> 632 glRecti (rectangle.x1 () - offset, rectangle.y1 () +
> offset,
> 633 rectangle.x2 () + offset, rectangle.y1 () -
> offset);
> 634 glRecti (rectangle.x1 () - offset, rectangle.y2 () +
> offset,
> 635 - rectangle.x2 () + offset, rectangle.y2 () -
> offset);*/
> 636 + rectangle.x2 () + offset, rectangle.y2 () -
> offset);
>
> That will break on GLES builds, glRecti isn't supported there.
>
> Can you convert this to use GL_TRIANGLE_STRIP?

Not sure really -> I am still fighting with converting our particle plugins to TRIANGLE_STRIP -> I have to fully grasp and understand the OpenGL vs. 2d coordinate systems -> I do not get the order of the coordinates of the vertices right somehow, so I am not sure if I can convert those, although they seem to be simpler, because no texturing is involved here...

Still - Maybe I'll do the cleanup only first here...

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

F*ck it, I'll fix it. :)

Btw, we need GL_LINE_LOOP in this case...

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

Unfortunately there is some flickering left here, when using ellipse or rectangle draw mode...
GL_BLEND seems to be correctly enabled, I guess the damaging is somehow done wrongly - it seems to stop damaging, when the shape does not change -> then flickering begins...

Investigating.

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

I'll leave the damage handling as is for now...

3706. By MC Return

Merged latest lp:compiz

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Is this a resubmit then?

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

> Is this a resubmit then?

Yep ;)

review: Needs Resubmitting
Revision history for this message
Sam Spilsbury (smspillaz) :
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 'plugins/annotate/src/annotate.cpp'
2--- plugins/annotate/src/annotate.cpp 2013-05-09 13:43:07 +0000
3+++ plugins/annotate/src/annotate.cpp 2013-05-15 14:34:27 +0000
4@@ -30,7 +30,7 @@
5 #define DEG2RAD (M_PI / 180.0f)
6
7 void
8-AnnoScreen::cairoClear (cairo_t *cr)
9+AnnoScreen::cairoClear (cairo_t *cr)
10 {
11 cairo_save (cr);
12 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
13@@ -47,12 +47,11 @@
14 {
15 XRenderPictFormat *format;
16 Screen *xScreen;
17- int w, h;
18
19 xScreen = ScreenOfDisplay (screen->dpy (), screen->screenNum ());
20
21- w = screen->width ();
22- h = screen->height ();
23+ int w = screen->width ();
24+ int h = screen->height ();
25
26 format = XRenderFindStandardFormat (screen->dpy (),
27 PictStandardARGB32);
28@@ -75,10 +74,9 @@
29 damage = XDamageCreate (screen->dpy (), pixmap,
30 XDamageReportBoundingBox);
31
32- surface =
33- cairo_xlib_surface_create_with_xrender_format (screen->dpy (),
34- pixmap, xScreen,
35- format, w, h);
36+ surface = cairo_xlib_surface_create_with_xrender_format (screen->dpy (),
37+ pixmap, xScreen,
38+ format, w, h);
39
40 cairo = cairo_create (surface);
41
42@@ -91,9 +89,9 @@
43 cairoBuffer.c_str (),
44 CAIRO_FORMAT_ARGB32,
45 w, h, stride);
46-
47+
48 if (cr && raw_source)
49- {
50+ {
51 cairo_set_source_surface (cr, raw_source, 0, 0);
52 cairo_paint (cr);
53
54@@ -102,7 +100,7 @@
55 cairoBuffer.clear ();
56 }
57 }
58- else
59+ else
60 cairoClear (cairo);
61 }
62
63@@ -110,7 +108,7 @@
64 }
65
66 void
67-AnnoScreen::setSourceColor (cairo_t *cr,
68+AnnoScreen::setSourceColor (cairo_t *cr,
69 unsigned short *color)
70 {
71 cairo_set_source_rgba (cr,
72@@ -121,22 +119,22 @@
73 }
74
75 void
76-AnnoScreen::drawEllipse (double xc,
77- double yc,
78- double radiusX,
79- double radiusY,
80- unsigned short *fillColor,
81- unsigned short *strokeColor,
82- double strokeWidth)
83+AnnoScreen::drawEllipse (double xc,
84+ double yc,
85+ double radiusX,
86+ double radiusY,
87+ unsigned short *fillColor,
88+ unsigned short *strokeColor,
89+ double strokeWidth)
90 {
91- cairo_t *cr;
92+ cairo_t *cr = cairoContext ();
93
94- cr = cairoContext ();
95 if (cr)
96 {
97 setSourceColor (cr, fillColor);
98 cairo_save (cr);
99 cairo_translate (cr, xc, yc);
100+
101 if (radiusX > radiusY)
102 {
103 cairo_scale (cr, 1.0, radiusY/radiusX);
104@@ -147,6 +145,7 @@
105 cairo_scale (cr, radiusX/radiusY, 1.0);
106 cairo_arc (cr, 0, 0, radiusY, 0, 2 * M_PI);
107 }
108+
109 cairo_restore (cr);
110 cairo_fill_preserve (cr);
111 cairo_set_line_width (cr, strokeWidth);
112@@ -158,17 +157,16 @@
113 }
114
115 void
116-AnnoScreen::drawRectangle (double x,
117- double y,
118- double w,
119- double h,
120+AnnoScreen::drawRectangle (double x,
121+ double y,
122+ double w,
123+ double h,
124 unsigned short *fillColor,
125 unsigned short *strokeColor,
126- double strokeWidth)
127+ double strokeWidth)
128 {
129- cairo_t *cr;
130+ cairo_t *cr = cairoContext ();
131
132- cr = cairoContext ();
133 if (cr)
134 {
135 double ex1, ey1, ex2, ey2;
136@@ -186,16 +184,15 @@
137 }
138
139 void
140-AnnoScreen::drawLine (double x1,
141- double y1,
142- double x2,
143- double y2,
144- double width,
145+AnnoScreen::drawLine (double x1,
146+ double y1,
147+ double x2,
148+ double y2,
149+ double width,
150 unsigned short *color)
151 {
152- cairo_t *cr;
153+ cairo_t *cr = cairoContext ();
154
155- cr = cairoContext ();
156 if (cr)
157 {
158 double ex1, ey1, ex2, ey2;
159@@ -213,21 +210,20 @@
160 }
161
162 void
163-AnnoScreen::drawText (double x,
164- double y,
165- const char *text,
166- const char *fontFamily,
167- double fontSize,
168- cairo_font_slant_t fontSlant,
169- cairo_font_weight_t fontWeight,
170- unsigned short *fillColor,
171- unsigned short *strokeColor,
172- double strokeWidth)
173+AnnoScreen::drawText (double x,
174+ double y,
175+ const char *text,
176+ const char *fontFamily,
177+ double fontSize,
178+ cairo_font_slant_t fontSlant,
179+ cairo_font_weight_t fontWeight,
180+ unsigned short *fillColor,
181+ unsigned short *strokeColor,
182+ double strokeWidth)
183 {
184 REGION reg;
185- cairo_t *cr;
186+ cairo_t *cr = cairoContext ();
187
188- cr = cairoContext ();
189 if (cr)
190 {
191 cairo_text_extents_t extents;
192@@ -297,105 +293,97 @@
193 bool
194 AnnoScreen::draw (CompAction *action,
195 CompAction::State state,
196- CompOption::Vector& options)
197+ CompOption::Vector &options)
198 {
199- cairo_t *cr;
200+ cairo_t *cr = cairoContext ();
201
202- cr = cairoContext ();
203 if (cr)
204 {
205- const char *tool;
206- unsigned short *fillColor, *strokeColor;
207- double strokeWidth;
208-
209- tool =
210- CompOption::getStringOptionNamed (options, "tool", "line").c_str ();
211-
212- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
213- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
214-
215- fillColor = optionGetFillColor ();
216- fillColor = CompOption::getColorOptionNamed (options, "fill_color",
217- fillColor);
218-
219- strokeColor = optionGetStrokeColor ();
220- strokeColor = CompOption::getColorOptionNamed (options,
221- "stroke_color", strokeColor);
222-
223- strokeWidth = optionGetStrokeWidth ();
224- strokeWidth = CompOption::getFloatOptionNamed (options, "stroke_width",
225- strokeWidth);
226-
227- if (strcasecmp (tool, "rectangle") == 0)
228- {
229- double x, y, w, h;
230-
231- x = CompOption::getFloatOptionNamed (options, "x", 0);
232- y = CompOption::getFloatOptionNamed (options, "y", 0);
233- w = CompOption::getFloatOptionNamed (options, "w", 100);
234- h = CompOption::getFloatOptionNamed (options, "h", 100);
235+ const char *tool;
236+ unsigned short *fillColor, *strokeColor;
237+
238+ tool = CompOption::getStringOptionNamed (options, "tool", "line").c_str ();
239+
240+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
241+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
242+
243+ fillColor = optionGetFillColor ();
244+ fillColor = CompOption::getColorOptionNamed (options, "fill_color",
245+ fillColor);
246+
247+ strokeColor = optionGetStrokeColor ();
248+ strokeColor = CompOption::getColorOptionNamed (options,
249+ "stroke_color", strokeColor);
250+
251+ double strokeWidth = optionGetStrokeWidth ();
252+ strokeWidth = CompOption::getFloatOptionNamed (options, "stroke_width",
253+ strokeWidth);
254+
255+ if (strcasecmp (tool, "rectangle") == 0)
256+ {
257+ double x = CompOption::getFloatOptionNamed (options, "x", 0);
258+ double y = CompOption::getFloatOptionNamed (options, "y", 0);
259+ double w = CompOption::getFloatOptionNamed (options, "w", 100);
260+ double h = CompOption::getFloatOptionNamed (options, "h", 100);
261
262 drawRectangle (x, y, w, h, fillColor, strokeColor,
263- strokeWidth);
264- }
265- else if (strcasecmp (tool, "ellipse") == 0)
266- {
267- double xc, yc, xr, yr;
268-
269- xc = CompOption::getFloatOptionNamed (options, "xc", 0);
270- yc = CompOption::getFloatOptionNamed (options, "yc", 0);
271- xr = CompOption::getFloatOptionNamed (options, "radiusX", 100);
272- yr = CompOption::getFloatOptionNamed (options, "radiusY", 100);
273+ strokeWidth);
274+ }
275+ else if (strcasecmp (tool, "ellipse") == 0)
276+ {
277+ double xc = CompOption::getFloatOptionNamed (options, "xc", 0);
278+ double yc = CompOption::getFloatOptionNamed (options, "yc", 0);
279+ double xr = CompOption::getFloatOptionNamed (options, "radiusX", 100);
280+ double yr = CompOption::getFloatOptionNamed (options, "radiusY", 100);
281
282 drawEllipse (xc, yc, xr, yr, fillColor, strokeColor,
283- strokeWidth);
284- }
285- else if (strcasecmp (tool, "line") == 0)
286- {
287- double x1, y1, x2, y2;
288-
289- x1 = CompOption::getFloatOptionNamed (options, "x1", 0);
290- y1 = CompOption::getFloatOptionNamed (options, "y1", 0);
291- x2 = CompOption::getFloatOptionNamed (options, "x2", 100);
292- y2 = CompOption::getFloatOptionNamed (options, "y2", 100);
293+ strokeWidth);
294+ }
295+ else if (strcasecmp (tool, "line") == 0)
296+ {
297+ double x1 = CompOption::getFloatOptionNamed (options, "x1", 0);
298+ double y1 = CompOption::getFloatOptionNamed (options, "y1", 0);
299+ double x2 = CompOption::getFloatOptionNamed (options, "x2", 100);
300+ double y2 = CompOption::getFloatOptionNamed (options, "y2", 100);
301
302 drawLine (x1, y1, x2, y2, strokeWidth, fillColor);
303- }
304- else if (strcasecmp (tool, "text") == 0)
305- {
306- double x, y, size;
307- const char *text, *family;
308- cairo_font_slant_t slant;
309+ }
310+ else if (strcasecmp (tool, "text") == 0)
311+ {
312+ const char *text, *family;
313+ cairo_font_slant_t slant;
314 cairo_font_weight_t weight;
315- const char *str;
316-
317- str =
318- CompOption::getStringOptionNamed (options, "slant", "").c_str ();
319+ const char *str;
320+
321+ str = CompOption::getStringOptionNamed (options, "slant", "").c_str ();
322+
323 if (strcasecmp (str, "oblique") == 0)
324- slant = CAIRO_FONT_SLANT_OBLIQUE;
325+ slant = CAIRO_FONT_SLANT_OBLIQUE;
326 else if (strcasecmp (str, "italic") == 0)
327- slant = CAIRO_FONT_SLANT_ITALIC;
328+ slant = CAIRO_FONT_SLANT_ITALIC;
329 else
330- slant = CAIRO_FONT_SLANT_NORMAL;
331-
332- str =
333- CompOption::getStringOptionNamed (options, "weight", "").c_str ();
334+ slant = CAIRO_FONT_SLANT_NORMAL;
335+
336+ str = CompOption::getStringOptionNamed (options, "weight", "").c_str ();
337+
338 if (strcasecmp (str, "bold") == 0)
339- weight = CAIRO_FONT_WEIGHT_BOLD;
340+ weight = CAIRO_FONT_WEIGHT_BOLD;
341 else
342- weight = CAIRO_FONT_WEIGHT_NORMAL;
343-
344- x = CompOption::getFloatOptionNamed (options, "x", 0);
345- y = CompOption::getFloatOptionNamed (options, "y", 0);
346- text =
347- CompOption::getStringOptionNamed (options, "text", "").c_str ();
348+ weight = CAIRO_FONT_WEIGHT_NORMAL;
349+
350+ double x = CompOption::getFloatOptionNamed (options, "x", 0);
351+ double y = CompOption::getFloatOptionNamed (options, "y", 0);
352+
353+ text = CompOption::getStringOptionNamed (options, "text", "").c_str ();
354+
355 family = CompOption::getStringOptionNamed (options, "family",
356- "Sans").c_str ();
357- size = CompOption::getFloatOptionNamed (options, "size", 36.0);
358+ "Sans").c_str ();
359+
360+ double size = CompOption::getFloatOptionNamed (options, "size", 36.0);
361
362 drawText (x, y, text, family, size, slant, weight,
363- fillColor, strokeColor, strokeWidth);
364- }
365+ fillColor, strokeColor, strokeWidth);
366+ }
367 }
368
369 return true;
370@@ -408,8 +396,8 @@
371 {
372 if (grabIndex)
373 {
374- screen->removeGrab (grabIndex, NULL);
375- grabIndex = 0;
376+ screen->removeGrab (grabIndex, NULL);
377+ grabIndex = 0;
378 }
379
380 action->setState (action->state () & ~(CompAction::StateTermKey |
381@@ -456,19 +444,19 @@
382 bool
383 AnnoScreen::initiateErase (CompAction *action,
384 CompAction::State state,
385- CompOption::Vector& options)
386+ CompOption::Vector &options)
387 {
388 if (screen->otherGrabExist (NULL))
389- return false;
390+ return false;
391
392 if (!grabIndex)
393- grabIndex = screen->pushGrab (None, "annotate");
394+ grabIndex = screen->pushGrab (None, "annotate");
395
396 if (state & CompAction::StateInitButton)
397- action->setState (action->state () | CompAction::StateTermButton);
398+ action->setState (action->state () | CompAction::StateTermButton);
399
400 if (state & CompAction::StateInitKey)
401- action->setState (action->state () | CompAction::StateTermKey);
402+ action->setState (action->state () | CompAction::StateTermKey);
403
404 annoLastPointerX = pointerX;
405 annoLastPointerY = pointerY;
406@@ -483,19 +471,19 @@
407 bool
408 AnnoScreen::initiateFreeDraw (CompAction *action,
409 CompAction::State state,
410- CompOption::Vector& options)
411+ CompOption::Vector &options)
412 {
413 if (screen->otherGrabExist (NULL))
414- return false;
415+ return false;
416
417 if (!grabIndex)
418- grabIndex = screen->pushGrab (None, "annotate");
419+ grabIndex = screen->pushGrab (None, "annotate");
420
421 if (state & CompAction::StateInitButton)
422- action->setState (action->state () | CompAction::StateTermButton);
423+ action->setState (action->state () | CompAction::StateTermButton);
424
425 if (state & CompAction::StateInitKey)
426- action->setState (action->state () | CompAction::StateTermKey);
427+ action->setState (action->state () | CompAction::StateTermKey);
428
429 annoLastPointerX = pointerX;
430 annoLastPointerY = pointerY;
431@@ -510,19 +498,19 @@
432 bool
433 AnnoScreen::initiateLine (CompAction *action,
434 CompAction::State state,
435- CompOption::Vector& options)
436+ CompOption::Vector &options)
437 {
438 if (screen->otherGrabExist (NULL))
439- return false;
440+ return false;
441
442 if (!grabIndex)
443- grabIndex = screen->pushGrab (None, "annotate");
444+ grabIndex = screen->pushGrab (None, "annotate");
445
446 if (state & CompAction::StateInitButton)
447- action->setState (action->state () | CompAction::StateTermButton);
448+ action->setState (action->state () | CompAction::StateTermButton);
449
450 if (state & CompAction::StateInitKey)
451- action->setState (action->state () | CompAction::StateTermKey);
452+ action->setState (action->state () | CompAction::StateTermKey);
453
454 initialPointerX = pointerX;
455 initialPointerY = pointerY;
456@@ -537,19 +525,19 @@
457 bool
458 AnnoScreen::initiateRectangle (CompAction *action,
459 CompAction::State state,
460- CompOption::Vector& options)
461+ CompOption::Vector &options)
462 {
463 if (screen->otherGrabExist (NULL))
464- return false;
465+ return false;
466
467 if (!grabIndex)
468- grabIndex = screen->pushGrab (None, "annotate");
469+ grabIndex = screen->pushGrab (None, "annotate");
470
471 if (state & CompAction::StateInitButton)
472- action->setState (action->state () | CompAction::StateTermButton);
473+ action->setState (action->state () | CompAction::StateTermButton);
474
475 if (state & CompAction::StateInitKey)
476- action->setState (action->state () | CompAction::StateTermKey);
477+ action->setState (action->state () | CompAction::StateTermKey);
478
479 drawMode = RectangleMode;
480
481@@ -566,19 +554,19 @@
482 bool
483 AnnoScreen::initiateEllipse (CompAction *action,
484 CompAction::State state,
485- CompOption::Vector& options)
486+ CompOption::Vector &options)
487 {
488 if (screen->otherGrabExist (NULL))
489- return false;
490+ return false;
491
492 if (!grabIndex)
493- grabIndex = screen->pushGrab (None, "annotate");
494+ grabIndex = screen->pushGrab (None, "annotate");
495
496 if (state & CompAction::StateInitButton)
497- action->setState (action->state () | CompAction::StateTermButton);
498+ action->setState (action->state () | CompAction::StateTermButton);
499
500 if (state & CompAction::StateInitKey)
501- action->setState (action->state () | CompAction::StateTermKey);
502+ action->setState (action->state () | CompAction::StateTermKey);
503
504 drawMode = EllipseMode;
505
506@@ -596,17 +584,16 @@
507 bool
508 AnnoScreen::clear (CompAction *action,
509 CompAction::State state,
510- CompOption::Vector& options)
511+ CompOption::Vector &options)
512 {
513 if (content)
514 {
515- cairo_t *cr;
516+ cairo_t *cr = cairoContext ();
517
518- cr = cairoContext ();
519- if (cr)
520+ if (cr)
521 cairoClear (cairo);
522
523- cScreen->damageScreen ();
524+ cScreen->damageScreen ();
525
526 /* We don't need to refresh the screen or handle events anymore */
527 screen->handleEventSetEnabled (this, false);
528@@ -618,28 +605,25 @@
529
530 bool
531 AnnoScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
532- const GLMatrix &transform,
533- const CompRegion &region,
534- CompOutput *output,
535- unsigned int mask)
536+ const GLMatrix &transform,
537+ const CompRegion &region,
538+ CompOutput *output,
539+ unsigned int mask)
540 {
541- bool status;
542-
543- status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
544+ bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
545
546 if (status)
547 {
548 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
549 GLfloat vertexData[18];
550 GLfloat textureData[12];
551- CompRect rect;
552- GLMatrix sTransform = transform;
553- int numRect;
554- int pos = 0;
555- float offset;
556- int angle;
557+ CompRect rect;
558+ GLMatrix sTransform = transform;
559+ int numRect;
560+ int pos = 0;
561+ int angle;
562
563- offset = optionGetStrokeWidth () / 2;
564+ float offset = optionGetStrokeWidth () / 2;
565
566 /* This replaced prepareXCoords (s, output, -DEFAULT_Z_CAMERA) */
567 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
568@@ -650,23 +634,23 @@
569 {
570 foreach (GLTexture *tex, texture)
571 {
572- CompRect::vector rect = region.rects ();
573- numRect = region.rects ().size ();
574-
575- tex->enable (GLTexture::Fast);
576-
577- streamingBuffer->begin (GL_TRIANGLES);
578-
579- while (numRect--)
580- {
581+ CompRect::vector rect = region.rects ();
582+ numRect = region.rects ().size ();
583+
584+ tex->enable (GLTexture::Fast);
585+
586+ streamingBuffer->begin (GL_TRIANGLES);
587+
588+ while (numRect--)
589+ {
590 GLfloat tx1 = COMP_TEX_COORD_X (tex->matrix (),
591- rect.at (pos).x1 ());
592+ rect.at (pos).x1 ());
593 GLfloat tx2 = COMP_TEX_COORD_X (tex->matrix (),
594- rect.at (pos).x2 ());
595+ rect.at (pos).x2 ());
596 GLfloat ty1 = COMP_TEX_COORD_Y (tex->matrix (),
597- rect.at (pos).y1 ());
598+ rect.at (pos).y1 ());
599 GLfloat ty2 = COMP_TEX_COORD_Y (tex->matrix (),
600- rect.at (pos).y2 ());
601+ rect.at (pos).y2 ());
602
603 vertexData[0] = rect.at (pos).x1 ();
604 vertexData[1] = rect.at (pos).y1 ();
605@@ -709,13 +693,13 @@
606
607 streamingBuffer->addVertices (6, vertexData);
608 streamingBuffer->addTexCoords (0, 6, textureData);
609- pos++;
610- }
611+ ++pos;
612+ }
613
614 streamingBuffer->end ();
615 streamingBuffer->render (sTransform);
616
617- tex->disable ();
618+ tex->disable ();
619 }
620 }
621
622@@ -764,20 +748,29 @@
623 streamingBuffer->render (sTransform);
624
625 /* draw rectangle outline */
626-/* streamingBuffer->begin ();
627+ vertexData[0] = rectangle.x1 ();
628+ vertexData[1] = rectangle.y1 ();
629+ vertexData[2] = 0.0f;
630+ vertexData[3] = rectangle.x2 ();
631+ vertexData[4] = rectangle.y1 ();
632+ vertexData[5] = 0.0f;
633+ vertexData[6] = rectangle.x2 ();
634+ vertexData[7] = rectangle.y2 ();
635+ vertexData[8] = 0.0f;
636+ vertexData[9] = rectangle.x1 ();
637+ vertexData[10] = rectangle.y2 ();
638+ vertexData[11] = 0.0f;
639+
640+ glLineWidth (optionGetStrokeWidth ());
641+
642+ streamingBuffer->begin (GL_LINE_LOOP);
643
644 streamingBuffer->addColors (1, optionGetStrokeColor ());
645-
646- vertexData[0] = rectangle.x1 () - offset;
647- vertexData[3] = rectangle.x1 () - offset;
648 streamingBuffer->addVertices (4, vertexData);
649
650- glRecti (rectangle.x2 () - offset, rectangle.y2 (),
651- rectangle.x2 () + offset, rectangle.y1 ());
652- glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,
653- rectangle.x2 () + offset, rectangle.y1 () - offset);
654- glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,
655- rectangle.x2 () + offset, rectangle.y2 () - offset);*/
656+ streamingBuffer->end ();
657+ streamingBuffer->render (sTransform);
658+
659 break;
660
661 case EllipseMode:
662@@ -854,14 +847,15 @@
663 }
664
665 void
666-AnnoScreen::handleMotionEvent (int xRoot,
667- int yRoot)
668+AnnoScreen::handleMotionEvent (int xRoot,
669+ int yRoot)
670 {
671 CompRect damageRect;
672
673 if (grabIndex)
674 {
675 static unsigned short clearColor[] = { 0, 0, 0, 0 };
676+
677 switch (drawMode)
678 {
679 case EraseMode:
680@@ -931,8 +925,8 @@
681 break;
682 }
683
684- if (cScreen && (drawMode == LineMode ||
685- drawMode == RectangleMode ||
686+ if (cScreen && (drawMode == LineMode ||
687+ drawMode == RectangleMode ||
688 drawMode == EllipseMode))
689 {
690 /* Add border width to the damage region */
691@@ -959,7 +953,7 @@
692 }
693
694 void
695-AnnoScreen::handleEvent (XEvent *event)
696+AnnoScreen::handleEvent (XEvent *event)
697 {
698 switch (event->type)
699 {
700@@ -968,13 +962,16 @@
701 case LeaveNotify:
702 handleMotionEvent (pointerX, pointerY);
703 break;
704+
705 default:
706 if (event->type == cScreen->damageEvent () + XDamageNotify)
707 {
708 XDamageNotifyEvent *de = (XDamageNotifyEvent *) event;
709+
710 if (pixmap == de->drawable)
711 cScreen->damageRegion (CompRegion (CompRect (de->area)));
712 }
713+
714 break;
715 }
716
717
718=== modified file 'plugins/annotate/src/annotate.h'
719--- plugins/annotate/src/annotate.h 2012-09-04 15:33:44 +0000
720+++ plugins/annotate/src/annotate.h 2013-05-15 14:34:27 +0000
721@@ -38,9 +38,9 @@
722
723 typedef struct _Ellipse
724 {
725- CompPoint center;
726- int radiusX;
727- int radiusY;
728+ CompPoint center;
729+ int radiusX;
730+ int radiusY;
731 } Ellipse;
732
733 enum DrawMode
734@@ -64,24 +64,25 @@
735 AnnoScreen (CompScreen *screen);
736 ~AnnoScreen ();
737
738- CompositeScreen *cScreen;
739- GLScreen *gScreen;
740+ CompositeScreen *cScreen;
741+ GLScreen *gScreen;
742
743 CompScreen::GrabHandle grabIndex;
744
745- Pixmap pixmap;
746- GLTexture::List texture;
747- cairo_surface_t *surface;
748- cairo_t *cairo;
749- CompString cairoBuffer; // used for serialization
750- bool content;
751- Damage damage;
752-
753- CompRect rectangle, lastRect;
754- DrawMode drawMode;
755-
756- CompPoint lineVector;
757- Ellipse ellipse;
758+ Pixmap pixmap;
759+ GLTexture::List texture;
760+ cairo_surface_t *surface;
761+ cairo_t *cairo;
762+ CompString cairoBuffer; // used for serialization
763+ bool content;
764+ Damage damage;
765+
766+ CompRect rectangle;
767+ CompRect lastRect;
768+ DrawMode drawMode;
769+
770+ CompPoint lineVector;
771+ Ellipse ellipse;
772
773 void handleEvent (XEvent *);
774
775@@ -100,88 +101,88 @@
776 unsigned short *color);
777
778 void
779- drawLine (double x1,
780- double y1,
781- double x2,
782- double y2,
783- double width,
784+ drawLine (double x1,
785+ double y1,
786+ double x2,
787+ double y2,
788+ double width,
789 unsigned short *color);
790
791 void
792- drawRectangle (double x,
793- double y,
794- double w,
795- double h,
796+ drawRectangle (double x,
797+ double y,
798+ double w,
799+ double h,
800 unsigned short *fillColor,
801 unsigned short *strokeColor,
802- double strokeWidth);
803-
804- void
805- drawEllipse (double xc,
806- double yc,
807- double radiusX,
808- double radiusY,
809- unsigned short *fillColor,
810- unsigned short *strokeColor,
811- double strokeWidth);
812-
813- void
814- drawText (double x,
815- double y,
816- const char *text,
817- const char *fontFamily,
818- double fontSize,
819- cairo_font_slant_t fontSlant,
820- cairo_font_weight_t fontWeight,
821- unsigned short *fillColor,
822- unsigned short *strokeColor,
823- double strokeWidth);
824+ double strokeWidth);
825+
826+ void
827+ drawEllipse (double xc,
828+ double yc,
829+ double radiusX,
830+ double radiusY,
831+ unsigned short *fillColor,
832+ unsigned short *strokeColor,
833+ double strokeWidth);
834+
835+ void
836+ drawText (double x,
837+ double y,
838+ const char *text,
839+ const char *fontFamily,
840+ double fontSize,
841+ cairo_font_slant_t fontSlant,
842+ cairo_font_weight_t fontWeight,
843+ unsigned short *fillColor,
844+ unsigned short *strokeColor,
845+ double strokeWidth);
846
847 /* Actions */
848
849 bool
850- draw (CompAction *action,
851- CompAction::State state,
852+ draw (CompAction *action,
853+ CompAction::State state,
854 CompOption::Vector& options);
855
856 bool
857- terminate (CompAction *action,
858- CompAction::State state,
859+ terminate (CompAction *action,
860+ CompAction::State state,
861 CompOption::Vector& options);
862
863 bool
864- initiateErase (CompAction *action,
865- CompAction::State state,
866+ initiateErase (CompAction *action,
867+ CompAction::State state,
868 CompOption::Vector& options);
869
870 bool
871- initiateFreeDraw (CompAction *action,
872- CompAction::State state,
873+ initiateFreeDraw (CompAction *action,
874+ CompAction::State state,
875 CompOption::Vector& options);
876
877 bool
878- initiateLine (CompAction *action,
879- CompAction::State state,
880+ initiateLine (CompAction *action,
881+ CompAction::State state,
882 CompOption::Vector& options);
883
884 bool
885- initiateRectangle (CompAction *action,
886- CompAction::State state,
887+ initiateRectangle (CompAction *action,
888+ CompAction::State state,
889 CompOption::Vector& options);
890
891 bool
892- initiateEllipse (CompAction *action,
893- CompAction::State state,
894+ initiateEllipse (CompAction *action,
895+ CompAction::State state,
896 CompOption::Vector& options);
897
898 bool
899- clear (CompAction *action,
900- CompAction::State state,
901+ clear (CompAction *action,
902+ CompAction::State state,
903 CompOption::Vector& options);
904
905 void
906- handleMotionEvent (int xRoot,
907- int yRoot);
908+ handleMotionEvent (int xRoot,
909+ int yRoot);
910
911 };
912

Subscribers

People subscribed via source and target branches

to all changes: