This looks good to me:<div><br></div><div>Reviewed-by: Robert Bragg <<a href="mailto:robert@linux.intel.com">robert@linux.intel.com</a>></div><div><br></div><div>thanks,</div><div>- Robert</div><br><div class="gmail_quote">
On Tue, Nov 20, 2012 at 6:53 PM, Neil Roberts <span dir="ltr"><<a href="mailto:neil@linux.intel.com" target="_blank">neil@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There were two problems with the stencil viewport clip workaround<br>
introduced in afc5daab8:<br>
<br>
• When the viewport is changed the current clip state is not marked as<br>
  dirty. That means that when the framebuffer state is next flushed it<br>
  would continue to use the stencil from the previous viewport.<br>
<br>
• When the viewport is automatically updated due to the window being<br>
  resized the viewport age was not incremented so the clip state<br>
  wouldn't be flushed.<br>
<br>
I noticed the bugs by running cogl-sdl2-hello.<br>
<br>
This patch makes it so that the clip state is dirtied in<br>
cogl_framebuffer_set_viewport if the workaround is enabled.<br>
<br>
The automatic viewport changing code now just calls<br>
cogl_framebuffer_set_viewport instead of directly prodding the<br>
viewport values. This has the side-effect that it will also cause the<br>
journal to be flushed. This seems like the right thing to do anyway<br>
and presumably there would have been a bug before where it wouldn't<br>
have flushed the journal, although presumably this is extremely<br>
unlikely because it would have to have done a resize in the middle of<br>
painting the scene.<br>
---<br>
 cogl/cogl-framebuffer.c | 12 +++++++++---<br>
 cogl/cogl-onscreen.c    | 12 +-----------<br>
 2 files changed, 10 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c<br>
index 49d4364..54b7797 100644<br>
--- a/cogl/cogl-framebuffer.c<br>
+++ b/cogl/cogl-framebuffer.c<br>
@@ -448,6 +448,8 @@ cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,<br>
                                float width,<br>
                                float height)<br>
 {<br>
+  CoglContext *context = framebuffer->context;<br>
+<br>
   _COGL_RETURN_IF_FAIL (width > 0 && height > 0);<br>
<br>
   if (framebuffer->viewport_x == x &&<br>
@@ -464,9 +466,13 @@ cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,<br>
   framebuffer->viewport_height = height;<br>
   framebuffer->viewport_age++;<br>
<br>
-  if (framebuffer->context->current_draw_buffer == framebuffer)<br>
-    framebuffer->context->current_draw_buffer_changes |=<br>
-      COGL_FRAMEBUFFER_STATE_VIEWPORT;<br>
+  if (context->current_draw_buffer == framebuffer)<br>
+    {<br>
+      context->current_draw_buffer_changes |= COGL_FRAMEBUFFER_STATE_VIEWPORT;<br>
+<br>
+      if (context->needs_viewport_scissor_workaround)<br>
+        context->current_draw_buffer_changes |= COGL_FRAMEBUFFER_STATE_CLIP;<br>
+    }<br>
 }<br>
<br>
 float<br>
diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c<br>
index 4aaa5de..3c1e148 100644<br>
--- a/cogl/cogl-onscreen.c<br>
+++ b/cogl/cogl-onscreen.c<br>
@@ -387,17 +387,7 @@ _cogl_framebuffer_winsys_update_size (CoglFramebuffer *framebuffer,<br>
   framebuffer->width = width;<br>
   framebuffer->height = height;<br>
<br>
-  framebuffer->viewport_x = 0;<br>
-  framebuffer->viewport_y = 0;<br>
-  framebuffer->viewport_width = width;<br>
-  framebuffer->viewport_height = height;<br>
-<br>
-  /* If the framebuffer being updated is the current framebuffer we<br>
-   * mark the viewport state as changed so it will be updated the next<br>
-   * time _cogl_framebuffer_flush_state() is called. */<br>
-  if (framebuffer->context->current_draw_buffer == framebuffer)<br>
-    framebuffer->context->current_draw_buffer_changes |=<br>
-      COGL_FRAMEBUFFER_STATE_VIEWPORT;<br>
+  cogl_framebuffer_set_viewport (framebuffer, 0, 0, width, height);<br>
 }<br>
<br>
 void<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.3.g3c3efa5<br>
<br>
_______________________________________________<br>
Cogl mailing list<br>
<a href="mailto:Cogl@lists.freedesktop.org">Cogl@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/cogl" target="_blank">http://lists.freedesktop.org/mailman/listinfo/cogl</a><br>
</font></span></blockquote></div><br>