mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
cogl-clip-stack: Convert to be a CoglHandle
CoglClipStacks can now be reference counted via a CoglHandle. The ClipClipState now stores handles in the list rather than CoglClipStack pointers.
This commit is contained in:
parent
aba7fb63cb
commit
3a58bc440b
@ -40,6 +40,7 @@
|
||||
#include "cogl-util.h"
|
||||
#include "cogl-path-private.h"
|
||||
|
||||
typedef struct _CoglClipStack CoglClipStack;
|
||||
typedef struct _CoglClipStackEntry CoglClipStackEntry;
|
||||
typedef struct _CoglClipStackEntryRect CoglClipStackEntryRect;
|
||||
typedef struct _CoglClipStackEntryWindowRect CoglClipStackEntryWindowRect;
|
||||
@ -94,6 +95,8 @@ typedef enum
|
||||
|
||||
struct _CoglClipStack
|
||||
{
|
||||
CoglHandleObject _parent;
|
||||
|
||||
CoglClipStackEntry *stack_top;
|
||||
};
|
||||
|
||||
@ -144,6 +147,12 @@ struct _CoglClipStackEntryPath
|
||||
CoglHandle path;
|
||||
};
|
||||
|
||||
static void _cogl_clip_stack_free (CoglClipStack *stack);
|
||||
|
||||
COGL_HANDLE_DEFINE (ClipStack, clip_stack);
|
||||
|
||||
#define COGL_CLIP_STACK(stack) ((CoglClipStack *) (stack))
|
||||
|
||||
static void
|
||||
project_vertex (const CoglMatrix *modelview_matrix,
|
||||
const CoglMatrix *projection_matrix,
|
||||
@ -400,12 +409,13 @@ _cogl_clip_stack_push_entry (CoglClipStack *clip_stack,
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_clip_stack_push_window_rectangle (CoglClipStack *stack,
|
||||
_cogl_clip_stack_push_window_rectangle (CoglHandle handle,
|
||||
int x_offset,
|
||||
int y_offset,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||
CoglClipStackEntryWindowRect *entry;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
@ -421,13 +431,14 @@ _cogl_clip_stack_push_window_rectangle (CoglClipStack *stack,
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
||||
_cogl_clip_stack_push_rectangle (CoglHandle handle,
|
||||
float x_1,
|
||||
float y_1,
|
||||
float x_2,
|
||||
float y_2,
|
||||
const CoglMatrix *modelview_matrix)
|
||||
{
|
||||
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||
CoglClipStackEntryRect *entry;
|
||||
|
||||
/* Make a new entry */
|
||||
@ -444,10 +455,11 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_clip_stack_push_from_path (CoglClipStack *stack,
|
||||
_cogl_clip_stack_push_from_path (CoglHandle handle,
|
||||
CoglHandle path,
|
||||
const CoglMatrix *modelview_matrix)
|
||||
{
|
||||
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||
CoglClipStackEntryPath *entry;
|
||||
|
||||
entry = _cogl_clip_stack_push_entry (stack,
|
||||
@ -492,8 +504,9 @@ _cogl_clip_stack_entry_unref (CoglClipStackEntry *entry)
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_clip_stack_pop (CoglClipStack *stack)
|
||||
_cogl_clip_stack_pop (CoglHandle handle)
|
||||
{
|
||||
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||
CoglClipStackEntry *entry;
|
||||
|
||||
g_return_if_fail (stack->stack_top != NULL);
|
||||
@ -514,9 +527,10 @@ _cogl_clip_stack_pop (CoglClipStack *stack)
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_clip_stack_flush (CoglClipStack *stack,
|
||||
_cogl_clip_stack_flush (CoglHandle handle,
|
||||
gboolean *stencil_used_p)
|
||||
{
|
||||
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||
int has_clip_planes;
|
||||
gboolean using_clip_planes = FALSE;
|
||||
gboolean using_stencil_buffer = FALSE;
|
||||
@ -647,7 +661,7 @@ _cogl_clip_stack_flush (CoglClipStack *stack,
|
||||
*stencil_used_p = using_stencil_buffer;
|
||||
}
|
||||
|
||||
CoglClipStack *
|
||||
CoglHandle
|
||||
_cogl_clip_stack_new (void)
|
||||
{
|
||||
CoglClipStack *stack;
|
||||
@ -655,7 +669,7 @@ _cogl_clip_stack_new (void)
|
||||
stack = g_slice_new (CoglClipStack);
|
||||
stack->stack_top = NULL;
|
||||
|
||||
return stack;
|
||||
return _cogl_clip_stack_handle_new (stack);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -24,23 +24,18 @@
|
||||
#ifndef __COGL_CLIP_STACK_H
|
||||
#define __COGL_CLIP_STACK_H
|
||||
|
||||
typedef struct _CoglClipStack CoglClipStack;
|
||||
|
||||
CoglClipStack *
|
||||
CoglHandle
|
||||
_cogl_clip_stack_new (void);
|
||||
|
||||
void
|
||||
_cogl_clip_stack_free (CoglClipStack *stack);
|
||||
|
||||
void
|
||||
_cogl_clip_stack_push_window_rectangle (CoglClipStack *stack,
|
||||
_cogl_clip_stack_push_window_rectangle (CoglHandle handle,
|
||||
int x_offset,
|
||||
int y_offset,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
void
|
||||
_cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
||||
_cogl_clip_stack_push_rectangle (CoglHandle handle,
|
||||
float x_1,
|
||||
float y_1,
|
||||
float x_2,
|
||||
@ -48,14 +43,14 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
||||
const CoglMatrix *modelview_matrix);
|
||||
|
||||
void
|
||||
_cogl_clip_stack_push_from_path (CoglClipStack *stack,
|
||||
_cogl_clip_stack_push_from_path (CoglHandle handle,
|
||||
CoglHandle path,
|
||||
const CoglMatrix *modelview_matrix);
|
||||
void
|
||||
_cogl_clip_stack_pop (CoglClipStack *stack);
|
||||
_cogl_clip_stack_pop (CoglHandle handle);
|
||||
|
||||
void
|
||||
_cogl_clip_stack_flush (CoglClipStack *stack,
|
||||
_cogl_clip_stack_flush (CoglHandle handle,
|
||||
gboolean *stencil_used_p);
|
||||
|
||||
#endif /* __COGL_CLIP_STACK_H */
|
||||
|
@ -47,7 +47,7 @@ cogl_clip_push_window_rectangle (int x_offset,
|
||||
{
|
||||
CoglHandle framebuffer;
|
||||
CoglClipState *clip_state;
|
||||
CoglClipStack *stack;
|
||||
CoglHandle stack;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -174,7 +174,7 @@ cogl_clip_push_rectangle (float x_1,
|
||||
{
|
||||
CoglHandle framebuffer;
|
||||
CoglClipState *clip_state;
|
||||
CoglClipStack *stack;
|
||||
CoglHandle stack;
|
||||
CoglMatrix modelview_matrix;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
@ -219,7 +219,7 @@ cogl_clip_push_from_path_preserve (void)
|
||||
{
|
||||
CoglHandle framebuffer;
|
||||
CoglClipState *clip_state;
|
||||
CoglClipStack *stack;
|
||||
CoglHandle stack;
|
||||
CoglMatrix modelview_matrix;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
@ -252,7 +252,7 @@ cogl_clip_push_from_path (void)
|
||||
static void
|
||||
_cogl_clip_pop_real (CoglClipState *clip_state)
|
||||
{
|
||||
CoglClipStack *stack;
|
||||
CoglHandle stack;
|
||||
|
||||
/* We don't log clip stack changes in the journal so we must flush
|
||||
* it before making modifications */
|
||||
@ -282,7 +282,7 @@ cogl_clip_pop (void)
|
||||
void
|
||||
_cogl_clip_state_flush (CoglClipState *clip_state)
|
||||
{
|
||||
CoglClipStack *stack;
|
||||
CoglHandle stack;
|
||||
|
||||
if (!clip_state->stack_dirty)
|
||||
return;
|
||||
@ -316,7 +316,7 @@ cogl_clip_ensure (void)
|
||||
static void
|
||||
_cogl_clip_stack_save_real (CoglClipState *clip_state)
|
||||
{
|
||||
CoglClipStack *stack;
|
||||
CoglHandle stack;
|
||||
|
||||
/* We don't log clip stack changes in the journal so we must flush
|
||||
* it before making modifications */
|
||||
@ -345,7 +345,7 @@ cogl_clip_stack_save (void)
|
||||
static void
|
||||
_cogl_clip_stack_restore_real (CoglClipState *clip_state)
|
||||
{
|
||||
CoglClipStack *stack;
|
||||
CoglHandle stack;
|
||||
|
||||
g_return_if_fail (clip_state->stacks != NULL);
|
||||
|
||||
@ -355,7 +355,7 @@ _cogl_clip_stack_restore_real (CoglClipState *clip_state)
|
||||
|
||||
stack = clip_state->stacks->data;
|
||||
|
||||
_cogl_clip_stack_free (stack);
|
||||
cogl_handle_unref (stack);
|
||||
|
||||
/* Revert to an old stack */
|
||||
clip_state->stacks = g_slist_delete_link (clip_state->stacks,
|
||||
|
Loading…
Reference in New Issue
Block a user