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
f6f375cb36
commit
84b87e811e
@ -40,6 +40,7 @@
|
|||||||
#include "cogl-util.h"
|
#include "cogl-util.h"
|
||||||
#include "cogl-path-private.h"
|
#include "cogl-path-private.h"
|
||||||
|
|
||||||
|
typedef struct _CoglClipStack CoglClipStack;
|
||||||
typedef struct _CoglClipStackEntry CoglClipStackEntry;
|
typedef struct _CoglClipStackEntry CoglClipStackEntry;
|
||||||
typedef struct _CoglClipStackEntryRect CoglClipStackEntryRect;
|
typedef struct _CoglClipStackEntryRect CoglClipStackEntryRect;
|
||||||
typedef struct _CoglClipStackEntryWindowRect CoglClipStackEntryWindowRect;
|
typedef struct _CoglClipStackEntryWindowRect CoglClipStackEntryWindowRect;
|
||||||
@ -94,6 +95,8 @@ typedef enum
|
|||||||
|
|
||||||
struct _CoglClipStack
|
struct _CoglClipStack
|
||||||
{
|
{
|
||||||
|
CoglHandleObject _parent;
|
||||||
|
|
||||||
CoglClipStackEntry *stack_top;
|
CoglClipStackEntry *stack_top;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -144,6 +147,12 @@ struct _CoglClipStackEntryPath
|
|||||||
CoglHandle path;
|
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
|
static void
|
||||||
project_vertex (const CoglMatrix *modelview_matrix,
|
project_vertex (const CoglMatrix *modelview_matrix,
|
||||||
const CoglMatrix *projection_matrix,
|
const CoglMatrix *projection_matrix,
|
||||||
@ -400,12 +409,13 @@ _cogl_clip_stack_push_entry (CoglClipStack *clip_stack,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_window_rectangle (CoglClipStack *stack,
|
_cogl_clip_stack_push_window_rectangle (CoglHandle handle,
|
||||||
int x_offset,
|
int x_offset,
|
||||||
int y_offset,
|
int y_offset,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
|
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||||
CoglClipStackEntryWindowRect *entry;
|
CoglClipStackEntryWindowRect *entry;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
@ -421,13 +431,14 @@ _cogl_clip_stack_push_window_rectangle (CoglClipStack *stack,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
_cogl_clip_stack_push_rectangle (CoglHandle handle,
|
||||||
float x_1,
|
float x_1,
|
||||||
float y_1,
|
float y_1,
|
||||||
float x_2,
|
float x_2,
|
||||||
float y_2,
|
float y_2,
|
||||||
const CoglMatrix *modelview_matrix)
|
const CoglMatrix *modelview_matrix)
|
||||||
{
|
{
|
||||||
|
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||||
CoglClipStackEntryRect *entry;
|
CoglClipStackEntryRect *entry;
|
||||||
|
|
||||||
/* Make a new entry */
|
/* Make a new entry */
|
||||||
@ -444,10 +455,11 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_from_path (CoglClipStack *stack,
|
_cogl_clip_stack_push_from_path (CoglHandle handle,
|
||||||
CoglHandle path,
|
CoglHandle path,
|
||||||
const CoglMatrix *modelview_matrix)
|
const CoglMatrix *modelview_matrix)
|
||||||
{
|
{
|
||||||
|
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||||
CoglClipStackEntryPath *entry;
|
CoglClipStackEntryPath *entry;
|
||||||
|
|
||||||
entry = _cogl_clip_stack_push_entry (stack,
|
entry = _cogl_clip_stack_push_entry (stack,
|
||||||
@ -492,8 +504,9 @@ _cogl_clip_stack_entry_unref (CoglClipStackEntry *entry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_pop (CoglClipStack *stack)
|
_cogl_clip_stack_pop (CoglHandle handle)
|
||||||
{
|
{
|
||||||
|
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||||
CoglClipStackEntry *entry;
|
CoglClipStackEntry *entry;
|
||||||
|
|
||||||
g_return_if_fail (stack->stack_top != NULL);
|
g_return_if_fail (stack->stack_top != NULL);
|
||||||
@ -514,9 +527,10 @@ _cogl_clip_stack_pop (CoglClipStack *stack)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_flush (CoglClipStack *stack,
|
_cogl_clip_stack_flush (CoglHandle handle,
|
||||||
gboolean *stencil_used_p)
|
gboolean *stencil_used_p)
|
||||||
{
|
{
|
||||||
|
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
||||||
int has_clip_planes;
|
int has_clip_planes;
|
||||||
gboolean using_clip_planes = FALSE;
|
gboolean using_clip_planes = FALSE;
|
||||||
gboolean using_stencil_buffer = FALSE;
|
gboolean using_stencil_buffer = FALSE;
|
||||||
@ -647,7 +661,7 @@ _cogl_clip_stack_flush (CoglClipStack *stack,
|
|||||||
*stencil_used_p = using_stencil_buffer;
|
*stencil_used_p = using_stencil_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglClipStack *
|
CoglHandle
|
||||||
_cogl_clip_stack_new (void)
|
_cogl_clip_stack_new (void)
|
||||||
{
|
{
|
||||||
CoglClipStack *stack;
|
CoglClipStack *stack;
|
||||||
@ -655,7 +669,7 @@ _cogl_clip_stack_new (void)
|
|||||||
stack = g_slice_new (CoglClipStack);
|
stack = g_slice_new (CoglClipStack);
|
||||||
stack->stack_top = NULL;
|
stack->stack_top = NULL;
|
||||||
|
|
||||||
return stack;
|
return _cogl_clip_stack_handle_new (stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -24,23 +24,18 @@
|
|||||||
#ifndef __COGL_CLIP_STACK_H
|
#ifndef __COGL_CLIP_STACK_H
|
||||||
#define __COGL_CLIP_STACK_H
|
#define __COGL_CLIP_STACK_H
|
||||||
|
|
||||||
typedef struct _CoglClipStack CoglClipStack;
|
CoglHandle
|
||||||
|
|
||||||
CoglClipStack *
|
|
||||||
_cogl_clip_stack_new (void);
|
_cogl_clip_stack_new (void);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_free (CoglClipStack *stack);
|
_cogl_clip_stack_push_window_rectangle (CoglHandle handle,
|
||||||
|
|
||||||
void
|
|
||||||
_cogl_clip_stack_push_window_rectangle (CoglClipStack *stack,
|
|
||||||
int x_offset,
|
int x_offset,
|
||||||
int y_offset,
|
int y_offset,
|
||||||
int width,
|
int width,
|
||||||
int height);
|
int height);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
_cogl_clip_stack_push_rectangle (CoglHandle handle,
|
||||||
float x_1,
|
float x_1,
|
||||||
float y_1,
|
float y_1,
|
||||||
float x_2,
|
float x_2,
|
||||||
@ -48,14 +43,14 @@ _cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
|||||||
const CoglMatrix *modelview_matrix);
|
const CoglMatrix *modelview_matrix);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_from_path (CoglClipStack *stack,
|
_cogl_clip_stack_push_from_path (CoglHandle handle,
|
||||||
CoglHandle path,
|
CoglHandle path,
|
||||||
const CoglMatrix *modelview_matrix);
|
const CoglMatrix *modelview_matrix);
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_pop (CoglClipStack *stack);
|
_cogl_clip_stack_pop (CoglHandle handle);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_flush (CoglClipStack *stack,
|
_cogl_clip_stack_flush (CoglHandle handle,
|
||||||
gboolean *stencil_used_p);
|
gboolean *stencil_used_p);
|
||||||
|
|
||||||
#endif /* __COGL_CLIP_STACK_H */
|
#endif /* __COGL_CLIP_STACK_H */
|
||||||
|
@ -47,7 +47,7 @@ cogl_clip_push_window_rectangle (int x_offset,
|
|||||||
{
|
{
|
||||||
CoglHandle framebuffer;
|
CoglHandle framebuffer;
|
||||||
CoglClipState *clip_state;
|
CoglClipState *clip_state;
|
||||||
CoglClipStack *stack;
|
CoglHandle stack;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ cogl_clip_push_rectangle (float x_1,
|
|||||||
{
|
{
|
||||||
CoglHandle framebuffer;
|
CoglHandle framebuffer;
|
||||||
CoglClipState *clip_state;
|
CoglClipState *clip_state;
|
||||||
CoglClipStack *stack;
|
CoglHandle stack;
|
||||||
CoglMatrix modelview_matrix;
|
CoglMatrix modelview_matrix;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
@ -219,7 +219,7 @@ cogl_clip_push_from_path_preserve (void)
|
|||||||
{
|
{
|
||||||
CoglHandle framebuffer;
|
CoglHandle framebuffer;
|
||||||
CoglClipState *clip_state;
|
CoglClipState *clip_state;
|
||||||
CoglClipStack *stack;
|
CoglHandle stack;
|
||||||
CoglMatrix modelview_matrix;
|
CoglMatrix modelview_matrix;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
@ -252,7 +252,7 @@ cogl_clip_push_from_path (void)
|
|||||||
static void
|
static void
|
||||||
_cogl_clip_pop_real (CoglClipState *clip_state)
|
_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
|
/* We don't log clip stack changes in the journal so we must flush
|
||||||
* it before making modifications */
|
* it before making modifications */
|
||||||
@ -282,7 +282,7 @@ cogl_clip_pop (void)
|
|||||||
void
|
void
|
||||||
_cogl_clip_state_flush (CoglClipState *clip_state)
|
_cogl_clip_state_flush (CoglClipState *clip_state)
|
||||||
{
|
{
|
||||||
CoglClipStack *stack;
|
CoglHandle stack;
|
||||||
|
|
||||||
if (!clip_state->stack_dirty)
|
if (!clip_state->stack_dirty)
|
||||||
return;
|
return;
|
||||||
@ -316,7 +316,7 @@ cogl_clip_ensure (void)
|
|||||||
static void
|
static void
|
||||||
_cogl_clip_stack_save_real (CoglClipState *clip_state)
|
_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
|
/* We don't log clip stack changes in the journal so we must flush
|
||||||
* it before making modifications */
|
* it before making modifications */
|
||||||
@ -345,7 +345,7 @@ cogl_clip_stack_save (void)
|
|||||||
static void
|
static void
|
||||||
_cogl_clip_stack_restore_real (CoglClipState *clip_state)
|
_cogl_clip_stack_restore_real (CoglClipState *clip_state)
|
||||||
{
|
{
|
||||||
CoglClipStack *stack;
|
CoglHandle stack;
|
||||||
|
|
||||||
g_return_if_fail (clip_state->stacks != NULL);
|
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;
|
stack = clip_state->stacks->data;
|
||||||
|
|
||||||
_cogl_clip_stack_free (stack);
|
cogl_handle_unref (stack);
|
||||||
|
|
||||||
/* Revert to an old stack */
|
/* Revert to an old stack */
|
||||||
clip_state->stacks = g_slist_delete_link (clip_state->stacks,
|
clip_state->stacks = g_slist_delete_link (clip_state->stacks,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user