[cogl] avoid touching fb matrix stack directly
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] avoid touching fb matrix stack directly
- Date: Tue, 6 Dec 2011 19:00:15 +0000 (UTC)
commit 652c8c31cfdd98ef38803b88325d76aee187ea5e
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 new internal _cogl_framebuffer_push/pop_projection() functions
that allow us to set transient projections.
Reviewed-by: Neil Roberts <neil linux intel com>
cogl/cogl-framebuffer-private.h | 6 ++++++
cogl/cogl-framebuffer.c | 21 +++++++++++++++++++++
cogl/cogl-texture.c | 24 +++++++++---------------
3 files changed, 36 insertions(+), 15 deletions(-)
---
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index e168b6e..6499c80 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -334,4 +334,10 @@ _cogl_blit_framebuffer (unsigned int src_x,
unsigned int width,
unsigned int height);
+void
+_cogl_framebuffer_push_projection (CoglFramebuffer *framebuffer);
+
+void
+_cogl_framebuffer_pop_projection (CoglFramebuffer *framebuffer);
+
#endif /* __COGL_FRAMEBUFFER_PRIVATE_H */
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index f5cc877..c372963 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1916,6 +1916,27 @@ cogl_framebuffer_orthographic (CoglFramebuffer *framebuffer,
}
void
+_cogl_framebuffer_push_projection (CoglFramebuffer *framebuffer)
+{
+ CoglMatrixStack *projection_stack =
+ _cogl_framebuffer_get_projection_stack (framebuffer);
+ _cogl_matrix_stack_push (projection_stack);
+
+ framebuffer->context->current_draw_buffer_changes |=
+ COGL_FRAMEBUFFER_STATE_PROJECTION;
+}
+
+void
+_cogl_framebuffer_pop_projection (CoglFramebuffer *framebuffer)
+{
+ CoglMatrixStack *projection_stack =
+ _cogl_framebuffer_get_projection_stack (framebuffer);
+ _cogl_matrix_stack_pop (projection_stack);
+ framebuffer->context->current_draw_buffer_changes |=
+ COGL_FRAMEBUFFER_STATE_PROJECTION;
+}
+
+void
cogl_framebuffer_get_modelview_matrix (CoglFramebuffer *framebuffer,
CoglMatrix *matrix)
{
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index 23fcf8c..a072d91 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,14 @@ _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_projection (framebuffer);
+ cogl_framebuffer_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 +993,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_projection (framebuffer);
/* restore the original pipeline */
cogl_pop_source ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]