clip: rename get_clip_stack + add framebuffer_get_stack

Instead of having _cogl_get/set_clip stack which reference the global
CoglContext this instead makes those into CoglClipState method functions
named _cogl_clip_state_get/set_stack that take an explicit pointer to a
CoglClipState.

This also adds _cogl_framebuffer_get/set_clip_stack convenience
functions that avoid having to first get the ClipState from a
framebuffer then the stack from that - so we can maintain the
convenience of _cogl_get_clip_stack.
This commit is contained in:
Robert Bragg 2011-01-12 19:30:30 +00:00
parent cf92670fbb
commit e1563436b1
5 changed files with 53 additions and 37 deletions

View File

@ -251,30 +251,15 @@ _cogl_clip_state_destroy (CoglClipState *clip_state)
}
CoglClipStack *
_cogl_get_clip_stack (void)
_cogl_clip_state_get_stack (CoglClipState *clip_state)
{
CoglFramebuffer *framebuffer;
CoglClipState *clip_state;
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
return clip_state->stacks->data;
}
void
_cogl_set_clip_stack (CoglClipStack *stack)
_cogl_clip_state_set_stack (CoglClipState *clip_state,
CoglClipStack *stack)
{
CoglFramebuffer *framebuffer;
CoglClipState *clip_state;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
framebuffer = _cogl_get_framebuffer ();
clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
/* Replace the top of the stack of stacks */
_cogl_clip_stack_ref (stack);
_cogl_clip_stack_unref (clip_state->stacks->data);

View File

@ -43,26 +43,11 @@ _cogl_clip_state_destroy (CoglClipState *state);
void
_cogl_clip_state_flush (CoglClipState *clip_state);
/*
* _cogl_get_clip_stack:
*
* Gets a pointer to the current clip stack. This can be used to later
* return to the same clip stack state with _cogl_set_clip_stack(). A
* reference is not taken on the stack so if you want to keep it you
* should call _cogl_clip_stack_ref().
*
* Return value: a pointer to the current clip stack.
*/
CoglClipStack *
_cogl_get_clip_stack (void);
_cogl_clip_state_get_stack (CoglClipState *clip_state);
/*
* _cogl_set_clip_stack:
* @stack: a pointer to the replacement clip stack
*
* Replaces the current clip stack with @stack.
*/
void
_cogl_set_clip_stack (CoglClipStack *stack);
_cogl_clip_state_set_stack (CoglClipState *clip_state,
CoglClipStack *clip_stack);
#endif /* __COGL_CLIP_STATE_H */

View File

@ -126,6 +126,32 @@ _cogl_framebuffer_get_height (CoglFramebuffer *framebuffer);
CoglClipState *
_cogl_framebuffer_get_clip_state (CoglFramebuffer *framebuffer);
/*
* _cogl_framebuffer_get_clip_stack:
* @framebuffer: A #CoglFramebuffer
*
* Gets a pointer to the current clip stack. This can be used to later
* return to the same clip stack state with
* _cogl_framebuffer_set_clip_stack(). A reference is not taken on the
* stack so if you want to keep it you should call
* _cogl_clip_stack_ref().
*
* Return value: a pointer to the @framebuffer clip stack.
*/
CoglClipStack *
_cogl_framebuffer_get_clip_stack (CoglFramebuffer *framebuffer);
/*
* _cogl_framebuffer_set_clip_stack:
* @framebuffer: A #CoglFramebuffer
* @stack: a pointer to the replacement clip stack
*
* Replaces the @framebuffer clip stack with @stack.
*/
void
_cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer,
CoglClipStack *stack);
void
_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
int x,

View File

@ -331,6 +331,23 @@ _cogl_framebuffer_get_clip_state (CoglFramebuffer *framebuffer)
return &framebuffer->clip_state;
}
CoglClipStack *
_cogl_framebuffer_get_clip_stack (CoglFramebuffer *framebuffer)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
return _cogl_clip_state_get_stack (clip_state);
}
void
_cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer,
CoglClipStack *stack)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
_cogl_clip_state_set_stack (clip_state, stack);
}
void
_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
int x,

View File

@ -1318,6 +1318,7 @@ _cogl_journal_log_quad (CoglJournal *journal,
guint32 disable_layers;
CoglJournalEntry *entry;
CoglPipeline *source;
CoglClipStack *clip_stack;
CoglPipelineFlushOptions flush_options;
COGL_STATIC_TIMER (log_timer,
"Mainloop", /* parent */
@ -1413,7 +1414,9 @@ _cogl_journal_log_quad (CoglJournal *journal,
}
entry->pipeline = _cogl_pipeline_journal_ref (source);
entry->clip_stack = _cogl_clip_stack_ref (_cogl_get_clip_stack ());
clip_stack = _cogl_framebuffer_get_clip_stack (_cogl_get_framebuffer ());
entry->clip_stack = _cogl_clip_stack_ref (clip_stack);
if (G_UNLIKELY (source != pipeline))
cogl_handle_unref (source);