mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
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>
This commit is contained in:
parent
5ca78668af
commit
652c8c31cf
@ -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 */
|
||||
|
@ -1915,6 +1915,27 @@ cogl_framebuffer_orthographic (CoglFramebuffer *framebuffer,
|
||||
_cogl_matrix_stack_set (projection_stack, &ortho);
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -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 ();
|
||||
|
Loading…
Reference in New Issue
Block a user