mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
clip_stack: Remove use of CoglHandle in the CoglClipStack API
This replaces the use of CoglHandle with strongly type CoglClipStack * pointers instead. The only function not converted for now is cogl_is_clip_stack which will be done in a later commit.
This commit is contained in:
parent
29da1d0d3e
commit
311db34d08
@ -40,7 +40,6 @@
|
|||||||
#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;
|
||||||
@ -63,11 +62,11 @@ typedef enum
|
|||||||
* For example, the following sequence of operations would generate
|
* For example, the following sequence of operations would generate
|
||||||
* the tree below:
|
* the tree below:
|
||||||
*
|
*
|
||||||
* CoglHandle stack_a = _cogl_clip_stack_new ();
|
* CoglClipStack *stack_a = _cogl_clip_stack_new ();
|
||||||
* _cogl_set_clip_stack (stack_a);
|
* _cogl_set_clip_stack (stack_a);
|
||||||
* cogl_clip_stack_push_rectangle (...);
|
* cogl_clip_stack_push_rectangle (...);
|
||||||
* cogl_clip_stack_push_rectangle (...);
|
* cogl_clip_stack_push_rectangle (...);
|
||||||
* CoglHandle stack_b = _cogl_clip_stack_copy (stack_a);
|
* CoglClipStack *stack_b = _cogl_clip_stack_copy (stack_a);
|
||||||
* cogl_clip_stack_push_from_path ();
|
* cogl_clip_stack_push_from_path ();
|
||||||
* cogl_set_clip_stack (stack_b);
|
* cogl_set_clip_stack (stack_b);
|
||||||
* cogl_clip_stack_push_window_rectangle (...);
|
* cogl_clip_stack_push_window_rectangle (...);
|
||||||
@ -95,7 +94,7 @@ typedef enum
|
|||||||
|
|
||||||
struct _CoglClipStack
|
struct _CoglClipStack
|
||||||
{
|
{
|
||||||
CoglHandleObject _parent;
|
CoglObject _parent;
|
||||||
|
|
||||||
CoglClipStackEntry *stack_top;
|
CoglClipStackEntry *stack_top;
|
||||||
};
|
};
|
||||||
@ -144,12 +143,12 @@ struct _CoglClipStackEntryPath
|
|||||||
/* The matrix that was current when the clip was set */
|
/* The matrix that was current when the clip was set */
|
||||||
CoglMatrix matrix;
|
CoglMatrix matrix;
|
||||||
|
|
||||||
CoglHandle path;
|
CoglPath *path;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _cogl_clip_stack_free (CoglClipStack *stack);
|
static void _cogl_clip_stack_free (CoglClipStack *stack);
|
||||||
|
|
||||||
COGL_HANDLE_DEFINE (ClipStack, clip_stack);
|
COGL_OBJECT_DEFINE (ClipStack, clip_stack);
|
||||||
|
|
||||||
#define COGL_CLIP_STACK(stack) ((CoglClipStack *) (stack))
|
#define COGL_CLIP_STACK(stack) ((CoglClipStack *) (stack))
|
||||||
|
|
||||||
@ -184,7 +183,7 @@ set_clip_plane (GLint plane_num,
|
|||||||
GLdouble plane[4];
|
GLdouble plane[4];
|
||||||
#endif
|
#endif
|
||||||
GLfloat angle;
|
GLfloat angle;
|
||||||
CoglHandle framebuffer = _cogl_get_framebuffer ();
|
CoglFramebuffer *framebuffer = _cogl_get_framebuffer ();
|
||||||
CoglMatrixStack *modelview_stack =
|
CoglMatrixStack *modelview_stack =
|
||||||
_cogl_framebuffer_get_modelview_stack (framebuffer);
|
_cogl_framebuffer_get_modelview_stack (framebuffer);
|
||||||
CoglMatrixStack *projection_stack =
|
CoglMatrixStack *projection_stack =
|
||||||
@ -236,7 +235,7 @@ set_clip_planes (float x_1,
|
|||||||
float x_2,
|
float x_2,
|
||||||
float y_2)
|
float y_2)
|
||||||
{
|
{
|
||||||
CoglHandle framebuffer = _cogl_get_framebuffer ();
|
CoglFramebuffer *framebuffer = _cogl_get_framebuffer ();
|
||||||
CoglMatrixStack *modelview_stack =
|
CoglMatrixStack *modelview_stack =
|
||||||
_cogl_framebuffer_get_modelview_stack (framebuffer);
|
_cogl_framebuffer_get_modelview_stack (framebuffer);
|
||||||
CoglMatrix modelview_matrix;
|
CoglMatrix modelview_matrix;
|
||||||
@ -293,7 +292,7 @@ add_stencil_clip_rectangle (float x_1,
|
|||||||
gboolean first)
|
gboolean first)
|
||||||
{
|
{
|
||||||
CoglHandle current_source;
|
CoglHandle current_source;
|
||||||
CoglHandle framebuffer = _cogl_get_framebuffer ();
|
CoglFramebuffer *framebuffer = _cogl_get_framebuffer ();
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
@ -304,7 +303,7 @@ add_stencil_clip_rectangle (float x_1,
|
|||||||
_cogl_framebuffer_flush_state (framebuffer, 0);
|
_cogl_framebuffer_flush_state (framebuffer, 0);
|
||||||
|
|
||||||
/* temporarily swap in our special stenciling material */
|
/* temporarily swap in our special stenciling material */
|
||||||
current_source = cogl_handle_ref (ctx->source_material);
|
current_source = cogl_object_ref (ctx->source_material);
|
||||||
cogl_set_source (ctx->stencil_material);
|
cogl_set_source (ctx->stencil_material);
|
||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
@ -365,7 +364,7 @@ add_stencil_clip_rectangle (float x_1,
|
|||||||
|
|
||||||
/* restore the original source material */
|
/* restore the original source material */
|
||||||
cogl_set_source (current_source);
|
cogl_set_source (current_source);
|
||||||
cogl_handle_unref (current_source);
|
cogl_object_unref (current_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -414,13 +413,12 @@ _cogl_clip_stack_push_entry (CoglClipStack *clip_stack,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_window_rectangle (CoglHandle handle,
|
_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)
|
||||||
{
|
{
|
||||||
CoglClipStack *stack = COGL_CLIP_STACK (handle);
|
|
||||||
CoglClipStackEntryWindowRect *entry;
|
CoglClipStackEntryWindowRect *entry;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
@ -436,14 +434,13 @@ _cogl_clip_stack_push_window_rectangle (CoglHandle handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_rectangle (CoglHandle handle,
|
_cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
||||||
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 */
|
||||||
@ -460,11 +457,10 @@ _cogl_clip_stack_push_rectangle (CoglHandle handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_from_path (CoglHandle handle,
|
_cogl_clip_stack_push_from_path (CoglClipStack *stack,
|
||||||
CoglHandle path,
|
CoglPath *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,
|
||||||
@ -496,7 +492,7 @@ _cogl_clip_stack_entry_unref (CoglClipStackEntry *entry)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case COGL_CLIP_STACK_PATH:
|
case COGL_CLIP_STACK_PATH:
|
||||||
cogl_handle_unref (((CoglClipStackEntryPath *) entry)->path);
|
cogl_object_unref (((CoglClipStackEntryPath *) entry)->path);
|
||||||
g_slice_free1 (sizeof (CoglClipStackEntryPath), entry);
|
g_slice_free1 (sizeof (CoglClipStackEntryPath), entry);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -509,9 +505,8 @@ _cogl_clip_stack_entry_unref (CoglClipStackEntry *entry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_pop (CoglHandle handle)
|
_cogl_clip_stack_pop (CoglClipStack *stack)
|
||||||
{
|
{
|
||||||
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);
|
||||||
@ -532,10 +527,9 @@ _cogl_clip_stack_pop (CoglHandle handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_flush (CoglHandle handle,
|
_cogl_clip_stack_flush (CoglClipStack *stack,
|
||||||
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;
|
||||||
@ -639,7 +633,7 @@ _cogl_clip_stack_flush (CoglHandle handle,
|
|||||||
scissor_x0 = scissor_y0 = scissor_x1 = scissor_y1 = scissor_y_start = 0;
|
scissor_x0 = scissor_y0 = scissor_x1 = scissor_y1 = scissor_y_start = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CoglHandle framebuffer = _cogl_get_framebuffer ();
|
CoglFramebuffer *framebuffer = _cogl_get_framebuffer ();
|
||||||
|
|
||||||
/* We store the entry coordinates in Cogl coordinate space
|
/* We store the entry coordinates in Cogl coordinate space
|
||||||
* but OpenGL requires the window origin to be the bottom
|
* but OpenGL requires the window origin to be the bottom
|
||||||
@ -669,7 +663,7 @@ _cogl_clip_stack_flush (CoglHandle handle,
|
|||||||
*stencil_used_p = using_stencil_buffer;
|
*stencil_used_p = using_stencil_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglClipStack *
|
||||||
_cogl_clip_stack_new (void)
|
_cogl_clip_stack_new (void)
|
||||||
{
|
{
|
||||||
CoglClipStack *stack;
|
CoglClipStack *stack;
|
||||||
@ -677,7 +671,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 _cogl_clip_stack_handle_new (stack);
|
return _cogl_clip_stack_object_new (stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -691,19 +685,15 @@ _cogl_clip_stack_free (CoglClipStack *stack)
|
|||||||
g_slice_free (CoglClipStack, stack);
|
g_slice_free (CoglClipStack, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglClipStack *
|
||||||
_cogl_clip_stack_copy (CoglHandle handle)
|
_cogl_clip_stack_copy (CoglClipStack *old_stack)
|
||||||
{
|
{
|
||||||
CoglHandle new_handle;
|
CoglClipStack *new_stack;
|
||||||
CoglClipStack *new_stack, *old_stack;
|
|
||||||
|
|
||||||
if (!cogl_is_clip_stack (handle))
|
if (!cogl_is_clip_stack (old_stack))
|
||||||
return COGL_INVALID_HANDLE;
|
return NULL;
|
||||||
|
|
||||||
old_stack = COGL_CLIP_STACK (handle);
|
new_stack = _cogl_clip_stack_new ();
|
||||||
|
|
||||||
new_handle = _cogl_clip_stack_new ();
|
|
||||||
new_stack = COGL_CLIP_STACK (new_handle);
|
|
||||||
|
|
||||||
/* We can copy the stack by just referencing the other stack's
|
/* We can copy the stack by just referencing the other stack's
|
||||||
data. There's no need to implement copy-on-write because the
|
data. There's no need to implement copy-on-write because the
|
||||||
@ -714,5 +704,5 @@ _cogl_clip_stack_copy (CoglHandle handle)
|
|||||||
if (new_stack->stack_top)
|
if (new_stack->stack_top)
|
||||||
new_stack->stack_top->ref_count++;
|
new_stack->stack_top->ref_count++;
|
||||||
|
|
||||||
return new_handle;
|
return new_stack;
|
||||||
}
|
}
|
||||||
|
@ -24,18 +24,20 @@
|
|||||||
#ifndef __COGL_CLIP_STACK_H
|
#ifndef __COGL_CLIP_STACK_H
|
||||||
#define __COGL_CLIP_STACK_H
|
#define __COGL_CLIP_STACK_H
|
||||||
|
|
||||||
CoglHandle
|
typedef struct _CoglClipStack CoglClipStack;
|
||||||
|
|
||||||
|
CoglClipStack *
|
||||||
_cogl_clip_stack_new (void);
|
_cogl_clip_stack_new (void);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_window_rectangle (CoglHandle handle,
|
_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 (CoglHandle handle,
|
_cogl_clip_stack_push_rectangle (CoglClipStack *stack,
|
||||||
float x_1,
|
float x_1,
|
||||||
float y_1,
|
float y_1,
|
||||||
float x_2,
|
float x_2,
|
||||||
@ -43,14 +45,14 @@ _cogl_clip_stack_push_rectangle (CoglHandle handle,
|
|||||||
const CoglMatrix *modelview_matrix);
|
const CoglMatrix *modelview_matrix);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_push_from_path (CoglHandle handle,
|
_cogl_clip_stack_push_from_path (CoglClipStack *stack,
|
||||||
CoglHandle path,
|
CoglPath *path,
|
||||||
const CoglMatrix *modelview_matrix);
|
const CoglMatrix *modelview_matrix);
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_pop (CoglHandle handle);
|
_cogl_clip_stack_pop (CoglClipStack *stack);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_clip_stack_flush (CoglHandle handle,
|
_cogl_clip_stack_flush (CoglClipStack *stack,
|
||||||
gboolean *stencil_used_p);
|
gboolean *stencil_used_p);
|
||||||
|
|
||||||
|
|
||||||
@ -60,16 +62,16 @@ _cogl_clip_stack_flush (CoglHandle handle,
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* _cogl_clip_stack_copy:
|
* _cogl_clip_stack_copy:
|
||||||
* @handle: A handle to a clip stack
|
* @stack: A #CoglClipStack
|
||||||
*
|
*
|
||||||
* Creates a copy of the given clip stack and returns a new handle to
|
* Creates a copy of the given clip stack and returns a new pointer to
|
||||||
* it. The data from the original stack is shared with the new stack
|
* it. The data from the original stack is shared with the new stack
|
||||||
* so making copies is relatively cheap. Modifying the original stack
|
* so making copies is relatively cheap. Modifying the original stack
|
||||||
* does not affect the new stack.
|
* does not affect the new stack.
|
||||||
*
|
*
|
||||||
* Return value: a new clip stack with the same data as @handle
|
* Return value: a new clip stack with the same data as @stack
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglClipStack *
|
||||||
_cogl_clip_stack_copy (CoglHandle handle);
|
_cogl_clip_stack_copy (CoglClipStack *stack);
|
||||||
|
|
||||||
#endif /* __COGL_CLIP_STACK_H */
|
#endif /* __COGL_CLIP_STACK_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user