[cogl/wip/virtual-framebuffer: 8/37] avoid touching fb matrix stack directly



commit 20127d5ecea0183115a3df2e45517c5067b3b036
Author: Robert Bragg <robert linux intel com>
Date:   Sun Nov 20 18:50:29 2011 +0000

    avoid touching fb matrix stack directly
    
    This ensures we don't touch a framebuffer's matrix stack directly if we
    are also relying on _cogl_framebuffer_flush_state(). We want to get to
    the point where we can set dirty flags against framebuffer state at the
    point it changes but that means we can't allow direct access to the
    matrix stack. _cogl_texture_draw_and_read() has now been changed so it
    uses cogl_framebuffer_ methods to update the matrix stacks including
    adding a new internal _cogl_framebuffer_push_orthographic() function
    that allows to set a transient orthographic projection.

 cogl/cogl-framebuffer-private.h |   12 ++++++++++++
 cogl/cogl-texture.c             |   23 ++++++++---------------
 2 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index e168b6e..091f37f 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -334,4 +334,16 @@ _cogl_blit_framebuffer (unsigned int src_x,
                         unsigned int width,
                         unsigned int height);
 
+void
+_cogl_framebuffer_push_orthographic (CoglFramebuffer *framebuffer,
+                                     float x_1,
+                                     float y_1,
+                                     float x_2,
+                                     float y_2,
+                                     float near,
+                                     float far);
+
+void
+_cogl_framebuffer_pop_orthographic (CoglFramebuffer *framebuffer);
+
 #endif /* __COGL_FRAMEBUFFER_PRIVATE_H */
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index 23fcf8c..0c8b032 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -874,8 +874,6 @@ _cogl_texture_draw_and_read (CoglTexture *texture,
   CoglFramebuffer *framebuffer;
   float viewport[4];
   CoglBitmap *alpha_bmp;
-  CoglMatrixStack *projection_stack;
-  CoglMatrixStack *modelview_stack;
   int target_width = _cogl_bitmap_get_width (target_bmp);
   int target_height = _cogl_bitmap_get_height (target_bmp);
   int target_rowstride = _cogl_bitmap_get_rowstride (target_bmp);
@@ -896,18 +894,13 @@ _cogl_texture_draw_and_read (CoglTexture *texture,
    * works)
    */
 
-  projection_stack = _cogl_framebuffer_get_projection_stack (framebuffer);
-  _cogl_matrix_stack_push (projection_stack);
-  _cogl_matrix_stack_load_identity (projection_stack);
-  _cogl_matrix_stack_ortho (projection_stack,
-                            0, viewport[2],
-                            viewport[3], 0,
-                            0,
-                            100);
+  _cogl_framebuffer_push_orthographic (framebuffer,
+                                       0, 0,
+                                       viewport[2], viewport[3],
+                                       0, 100);
 
-  modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer);
-  _cogl_matrix_stack_push (modelview_stack);
-  _cogl_matrix_stack_load_identity (modelview_stack);
+  cogl_framebuffer_push_matrix (framebuffer);
+  cogl_framebuffer_identity_matrix (framebuffer);
 
   /* Direct copy operation */
 
@@ -999,8 +992,8 @@ _cogl_texture_draw_and_read (CoglTexture *texture,
     }
 
   /* Restore old state */
-  _cogl_matrix_stack_pop (modelview_stack);
-  _cogl_matrix_stack_pop (projection_stack);
+  cogl_framebuffer_pop_matrix (framebuffer);
+  _cogl_framebuffer_pop_orthographic (framebuffer);
 
   /* restore the original pipeline */
   cogl_pop_source ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]