Remove the framebuffer's stack of clip stacks

There used to be a function called cogl_clip_stack_save in the public
API which was used when temporarily switching to an offscreen buffer
to save the clip state. This is no longer necessary because each
framebuffer has its own clip stack anyway so the function was removed
in master. However the code to maintain the stack of stacks was
retained. This patch removes it in an effort to simplify the code.

On the 1.18 branch this function is deprecated and the documentation
says that it does nothing. However that is incorrect because it does
actually the push clip stack. I think it would be safe to backport
this patch to the 1.18 branch and actually make it do nothing like it
is documented to do.

https://bugzilla.gnome.org/show_bug.cgi?id=719546
(cherry picked from commit 8655027fdcf03b02fcbbb02d179a0a88ed79c5b3)

This patch has some extra changes while backporting to the 1.18
branch. Here the cogl-clip-state file still contained some deprecated
functions. Instead of deleting the file completely it has been moved
to the deprecated folder. The declarations for this functions have
been moved from cogl1-context.h to a new deprecated/cogl-clip-state.h
header.

Conflicts:
	cogl/Makefile.am
	cogl/cogl-clip-state.c

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts 2013-11-29 14:17:55 +00:00
parent 1c379f4576
commit ae9cd7ca01
11 changed files with 288 additions and 446 deletions

View File

@ -1471,7 +1471,6 @@ void
cogl_framebuffer_push_path_clip (CoglFramebuffer *framebuffer,
CoglPath *path)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
CoglMatrixEntry *modelview_entry =
_cogl_framebuffer_get_modelview_entry (framebuffer);
CoglMatrixEntry *projection_entry =
@ -1485,8 +1484,8 @@ cogl_framebuffer_push_path_clip (CoglFramebuffer *framebuffer,
framebuffer->viewport_height
};
clip_state->stacks->data =
_cogl_clip_stack_push_from_path (clip_state->stacks->data,
framebuffer->clip_stack =
_cogl_clip_stack_push_from_path (framebuffer->clip_stack,
path,
modelview_entry,
projection_entry,

View File

@ -69,6 +69,7 @@ EXTRA_DIST += cogl-1.0.pc.in cogl-$(COGL_API_VERSION)-experimental.pc.in
DISTCLEANFILES += $(pc_files)
cogl_deprecated_h = \
$(srcdir)/deprecated/cogl-clip-state.h \
$(srcdir)/deprecated/cogl-fixed.h \
$(srcdir)/deprecated/cogl-material-compat.h \
$(srcdir)/deprecated/cogl-vertex-buffer.h \
@ -111,7 +112,6 @@ cogl_experimental_h = \
$(srcdir)/cogl-indices.h \
$(srcdir)/cogl-attribute.h \
$(srcdir)/cogl-primitive.h \
$(srcdir)/cogl-clip-state.h \
$(srcdir)/cogl-framebuffer.h \
$(srcdir)/cogl-onscreen.h \
$(srcdir)/cogl-frame-info.h \
@ -261,9 +261,6 @@ cogl_sources_c = \
$(srcdir)/cogl-bitmap-pixbuf.c \
$(srcdir)/cogl-clip-stack.h \
$(srcdir)/cogl-clip-stack.c \
$(srcdir)/cogl-clip-state-private.h \
$(srcdir)/cogl-clip-state.h \
$(srcdir)/cogl-clip-state.c \
$(srcdir)/cogl2-compatibility.c \
$(srcdir)/cogl-feature-private.h \
$(srcdir)/cogl-feature-private.c \
@ -394,6 +391,7 @@ cogl_sources_c = \
$(srcdir)/cogl-closure-list.c \
$(srcdir)/cogl-fence.c \
$(srcdir)/cogl-fence-private.h \
$(srcdir)/deprecated/cogl-clip-state.c \
$(srcdir)/deprecated/cogl-fixed.c \
$(srcdir)/deprecated/cogl-vertex-buffer-private.h \
$(srcdir)/deprecated/cogl-vertex-buffer.c \
@ -543,7 +541,7 @@ libcogl_la_LDFLAGS = \
-no-undefined \
-version-info @COGL_LT_CURRENT@:@COGL_LT_REVISION@:@COGL_LT_AGE@ \
-export-dynamic \
-export-symbols-regex "^(cogl|_cogl_debug_flags|_cogl_atlas_new|_cogl_atlas_add_reorganize_callback|_cogl_atlas_reserve_space|_cogl_callback|_cogl_util_get_eye_planes_for_screen_poly|_cogl_atlas_texture_remove_reorganize_callback|_cogl_atlas_texture_add_reorganize_callback|_cogl_texture_foreach_sub_texture_in_region|_cogl_profile_trace_message|_cogl_context_get_default|_cogl_framebuffer_get_stencil_bits|_cogl_clip_stack_push_rectangle|_cogl_framebuffer_get_modelview_stack|_cogl_object_default_unref|_cogl_pipeline_foreach_layer_internal|_cogl_clip_stack_push_primitive|_cogl_buffer_unmap_for_fill_or_fallback|_cogl_framebuffer_draw_primitive|_cogl_debug_instances|_cogl_framebuffer_get_projection_stack|_cogl_pipeline_layer_get_texture|_cogl_buffer_map_for_fill_or_fallback|_cogl_framebuffer_get_clip_state|_cogl_texture_can_hardware_repeat|_cogl_pipeline_prune_to_n_layers|_cogl_primitive_draw|test_|unit_test_).*"
-export-symbols-regex "^(cogl|_cogl_debug_flags|_cogl_atlas_new|_cogl_atlas_add_reorganize_callback|_cogl_atlas_reserve_space|_cogl_callback|_cogl_util_get_eye_planes_for_screen_poly|_cogl_atlas_texture_remove_reorganize_callback|_cogl_atlas_texture_add_reorganize_callback|_cogl_texture_foreach_sub_texture_in_region|_cogl_profile_trace_message|_cogl_context_get_default|_cogl_framebuffer_get_stencil_bits|_cogl_clip_stack_push_rectangle|_cogl_framebuffer_get_modelview_stack|_cogl_object_default_unref|_cogl_pipeline_foreach_layer_internal|_cogl_clip_stack_push_primitive|_cogl_buffer_unmap_for_fill_or_fallback|_cogl_framebuffer_draw_primitive|_cogl_debug_instances|_cogl_framebuffer_get_projection_stack|_cogl_pipeline_layer_get_texture|_cogl_buffer_map_for_fill_or_fallback|_cogl_texture_can_hardware_repeat|_cogl_pipeline_prune_to_n_layers|_cogl_primitive_draw|test_|unit_test_).*"
libcogl_la_SOURCES = $(cogl_sources_c)
nodist_libcogl_la_SOURCES = $(BUILT_SOURCES)

View File

@ -1,56 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009,2010 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#ifndef __COGL_CLIP_STATE_PRIVATE_H
#define __COGL_CLIP_STATE_PRIVATE_H
#include "cogl-clip-stack.h"
typedef struct _CoglClipState CoglClipState;
struct _CoglClipState
{
/* Stack of CoglClipStacks */
GSList *stacks;
};
void
_cogl_clip_state_init (CoglClipState *state);
void
_cogl_clip_state_destroy (CoglClipState *state);
CoglClipStack *
_cogl_clip_state_get_stack (CoglClipState *clip_state);
void
_cogl_clip_state_set_stack (CoglClipState *clip_state,
CoglClipStack *clip_stack);
void
_cogl_clip_state_save_clip_stack (CoglClipState *clip_state);
void
_cogl_clip_state_restore_clip_stack (CoglClipState *clip_state);
#endif /* __COGL_CLIP_STATE_PRIVATE_H */

View File

@ -1,37 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009,2010 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL_CLIP_STATE_H
#define __COGL_CLIP_STATE_H
#include <cogl/cogl-types.h>
COGL_BEGIN_DECLS
COGL_END_DECLS
#endif /* __COGL_CLIP_STATE_H */

View File

@ -26,12 +26,12 @@
#include "cogl-object-private.h"
#include "cogl-matrix-stack-private.h"
#include "cogl-clip-state-private.h"
#include "cogl-journal-private.h"
#include "cogl-winsys-private.h"
#include "cogl-attribute-private.h"
#include "cogl-offscreen.h"
#include "cogl-gl-header.h"
#include "cogl-clip-stack.h"
#ifdef COGL_HAS_XLIB_SUPPORT
#include <X11/Xlib.h>
@ -142,7 +142,7 @@ struct _CoglFramebuffer
int viewport_age;
int viewport_age_for_scissor_workaround;
CoglClipState clip_state;
CoglClipStack *clip_stack;
CoglBool dither_enabled;
CoglBool depth_writing_enabled;
@ -242,9 +242,6 @@ _cogl_framebuffer_clear_without_flush4f (CoglFramebuffer *framebuffer,
void
_cogl_framebuffer_mark_mid_scene (CoglFramebuffer *framebuffer);
CoglClipState *
_cogl_framebuffer_get_clip_state (CoglFramebuffer *framebuffer);
/*
* _cogl_framebuffer_get_clip_stack:
* @framebuffer: A #CoglFramebuffer

View File

@ -125,8 +125,7 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
framebuffer->samples_per_pixel = 0;
/* Initialise the clip stack */
_cogl_clip_state_init (&framebuffer->clip_state);
framebuffer->clip_stack = NULL;
framebuffer->journal = _cogl_journal_new (framebuffer);
@ -173,7 +172,7 @@ _cogl_framebuffer_free (CoglFramebuffer *framebuffer)
_cogl_fence_cancel_fences_for_framebuffer (framebuffer);
_cogl_clip_state_destroy (&framebuffer->clip_state);
_cogl_clip_stack_unref (framebuffer->clip_stack);
cogl_object_unref (framebuffer->modelview_stack);
framebuffer->modelview_stack = NULL;
@ -459,27 +458,19 @@ cogl_framebuffer_get_height (CoglFramebuffer *framebuffer)
return framebuffer->height;
}
CoglClipState *
_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);
return framebuffer->clip_stack;
}
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);
_cogl_clip_stack_ref (stack);
_cogl_clip_stack_unref (framebuffer->clip_stack);
framebuffer->clip_stack = stack;
}
void
@ -1046,10 +1037,7 @@ static unsigned long
_cogl_framebuffer_compare_clip_state (CoglFramebuffer *a,
CoglFramebuffer *b)
{
if (((a->clip_state.stacks == NULL || b->clip_state.stacks == NULL) &&
a->clip_state.stacks != b->clip_state.stacks)
||
a->clip_state.stacks->data != b->clip_state.stacks->data)
if (a->clip_stack != b->clip_stack)
return COGL_FRAMEBUFFER_STATE_CLIP;
else
return 0;
@ -1959,10 +1947,8 @@ cogl_framebuffer_push_scissor_clip (CoglFramebuffer *framebuffer,
int width,
int height)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
clip_state->stacks->data =
_cogl_clip_stack_push_window_rectangle (clip_state->stacks->data,
framebuffer->clip_stack =
_cogl_clip_stack_push_window_rectangle (framebuffer->clip_stack,
x, y, width, height);
if (framebuffer->context->current_draw_buffer == framebuffer)
@ -1977,7 +1963,6 @@ cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer,
float x_2,
float y_2)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
CoglMatrixEntry *modelview_entry =
_cogl_framebuffer_get_modelview_entry (framebuffer);
CoglMatrixEntry *projection_entry =
@ -1991,8 +1976,8 @@ cogl_framebuffer_push_rectangle_clip (CoglFramebuffer *framebuffer,
framebuffer->viewport_height
};
clip_state->stacks->data =
_cogl_clip_stack_push_rectangle (clip_state->stacks->data,
framebuffer->clip_stack =
_cogl_clip_stack_push_rectangle (framebuffer->clip_stack,
x_1, y_1, x_2, y_2,
modelview_entry,
projection_entry,
@ -2011,7 +1996,6 @@ cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer,
float bounds_x2,
float bounds_y2)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
CoglMatrixEntry *modelview_entry =
_cogl_framebuffer_get_modelview_entry (framebuffer);
CoglMatrixEntry *projection_entry =
@ -2025,8 +2009,8 @@ cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer,
framebuffer->viewport_height
};
clip_state->stacks->data =
_cogl_clip_stack_push_primitive (clip_state->stacks->data,
framebuffer->clip_stack =
_cogl_clip_stack_push_primitive (framebuffer->clip_stack,
primitive,
bounds_x1, bounds_y1,
bounds_x2, bounds_y2,
@ -2042,31 +2026,7 @@ cogl_framebuffer_push_primitive_clip (CoglFramebuffer *framebuffer,
void
cogl_framebuffer_pop_clip (CoglFramebuffer *framebuffer)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
clip_state->stacks->data = _cogl_clip_stack_pop (clip_state->stacks->data);
if (framebuffer->context->current_draw_buffer == framebuffer)
framebuffer->context->current_draw_buffer_changes |=
COGL_FRAMEBUFFER_STATE_CLIP;
}
void
_cogl_framebuffer_save_clip_stack (CoglFramebuffer *framebuffer)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
_cogl_clip_state_save_clip_stack (clip_state);
if (framebuffer->context->current_draw_buffer == framebuffer)
framebuffer->context->current_draw_buffer_changes |=
COGL_FRAMEBUFFER_STATE_CLIP;
}
void
_cogl_framebuffer_restore_clip_stack (CoglFramebuffer *framebuffer)
{
CoglClipState *clip_state = _cogl_framebuffer_get_clip_state (framebuffer);
_cogl_clip_state_restore_clip_stack (clip_state);
framebuffer->clip_stack = _cogl_clip_stack_pop (framebuffer->clip_stack);
if (framebuffer->context->current_draw_buffer == framebuffer)
framebuffer->context->current_draw_buffer_changes |=

View File

@ -73,8 +73,8 @@
* 1.x only api...
*/
#ifndef COGL_ENABLE_EXPERIMENTAL_2_0_API
#include <cogl/cogl-clip-state.h>
#include <cogl/cogl-enum-types.h>
#include <cogl/deprecated/cogl-clip-state.h>
#include <cogl/deprecated/cogl-vertex-buffer.h>
#include <cogl/deprecated/cogl-fixed.h>
#include <cogl/deprecated/cogl-material-compat.h>

View File

@ -731,228 +731,6 @@ COGL_DEPRECATED_IN_1_16
void
cogl_set_source_texture (CoglTexture *texture);
/**
* SECTION:cogl-clipping
* @short_description: Fuctions for manipulating a stack of clipping regions
*
* To support clipping your geometry to rectangles or paths Cogl exposes a
* stack based API whereby each clip region you push onto the stack is
* intersected with the previous region.
*/
/**
* cogl_clip_push_window_rect:
* @x_offset: left edge of the clip rectangle in window coordinates
* @y_offset: top edge of the clip rectangle in window coordinates
* @width: width of the clip rectangle
* @height: height of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are not transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*
* Deprecated: 1.16: Use cogl_framebuffer_push_scissor_clip() instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_scissor_clip)
void
cogl_clip_push_window_rect (float x_offset,
float y_offset,
float width,
float height);
/**
* cogl_clip_push_window_rectangle:
* @x_offset: left edge of the clip rectangle in window coordinates
* @y_offset: top edge of the clip rectangle in window coordinates
* @width: width of the clip rectangle
* @height: height of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are not transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*
* Since: 1.2
* Deprecated: 1.16: Use cogl_framebuffer_push_scissor_clip() instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_scissor_clip)
void
cogl_clip_push_window_rectangle (int x_offset,
int y_offset,
int width,
int height);
/**
* cogl_clip_push:
* @x_offset: left edge of the clip rectangle
* @y_offset: top edge of the clip rectangle
* @width: width of the clip rectangle
* @height: height of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*
* Deprecated: 1.16: The x, y, width, height arguments are inconsistent
* with other API that specify rectangles in model space, and when used
* with a coordinate space that puts the origin at the center and y+
* extending up, it's awkward to use. Please use
* cogl_framebuffer_push_rectangle_clip()
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_rectangle_clip)
void
cogl_clip_push (float x_offset,
float y_offset,
float width,
float height);
/**
* cogl_clip_push_rectangle:
* @x0: x coordinate for top left corner of the clip rectangle
* @y0: y coordinate for top left corner of the clip rectangle
* @x1: x coordinate for bottom right corner of the clip rectangle
* @y1: y coordinate for bottom right corner of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*
* Since: 1.2
* Deprecated: 1.16: Use cogl_framebuffer_push_rectangle_clip()
* instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_rectangle_clip)
void
cogl_clip_push_rectangle (float x0,
float y0,
float x1,
float y1);
/**
* cogl_clip_push_primitive:
* @primitive: A #CoglPrimitive describing a flat 2D shape
* @bounds_x1: x coordinate for the top-left corner of the primitives
* bounds
* @bounds_y1: y coordinate for the top-left corner of the primitives
* bounds
* @bounds_x2: x coordinate for the bottom-right corner of the primitives
* bounds
* @bounds_y2: y coordinate for the bottom-right corner of the
* primitives bounds.
*
* Sets a new clipping area using a 2D shaped described with a
* #CoglPrimitive. The shape must not contain self overlapping
* geometry and must lie on a single 2D plane. A bounding box of the
* 2D shape in local coordinates (the same coordinates used to
* describe the shape) must be given. It is acceptable for the bounds
* to be larger than the true bounds but behaviour is undefined if the
* bounds are smaller than the true bounds.
*
* The primitive is transformed by the current model-view matrix and
* the silhouette is intersected with the previous clipping area. To
* restore the previous clipping area, call
* cogl_clip_pop().
*
* Since: 1.10
* Stability: unstable
* Deprecated: 1.16: Use cogl_framebuffer_push_primitive_clip()
* instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_primitive_clip)
void
cogl_clip_push_primitive (CoglPrimitive *primitive,
float bounds_x1,
float bounds_y1,
float bounds_x2,
float bounds_y2);
/**
* cogl_clip_pop:
*
* Reverts the clipping region to the state before the last call to
* cogl_clip_push().
*
* Deprecated: 1.16: Use cogl_framebuffer_pop_clip() instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_pop_clip)
void
cogl_clip_pop (void);
/**
* cogl_clip_ensure:
*
* Ensures that the current clipping region has been set in GL. This
* will automatically be called before any Cogl primitives but it
* maybe be neccessary to call if you are using raw GL calls with
* clipping.
*
* Deprecated: 1.2: Calling this function has no effect
*
* Since: 1.0
*/
COGL_DEPRECATED
void
cogl_clip_ensure (void);
/**
* cogl_clip_stack_save:
*
* Save the entire state of the clipping stack and then clear all
* clipping. The previous state can be returned to with
* cogl_clip_stack_restore(). Each call to cogl_clip_push() after this
* must be matched by a call to cogl_clip_pop() before calling
* cogl_clip_stack_restore().
*
* Deprecated: 1.2: This was originally added to allow us to save the
* clip stack when switching to an offscreen framebuffer, but it's
* not necessary anymore given that framebuffers now own separate
* clip stacks which will be automatically switched between when a
* new buffer is set. Calling this function has no effect
*
* Since: 0.8.2
*/
COGL_DEPRECATED
void
cogl_clip_stack_save (void);
/**
* cogl_clip_stack_restore:
*
* Restore the state of the clipping stack that was previously saved
* by cogl_clip_stack_save().
*
* Deprecated: 1.2: This was originally added to allow us to restore
* the clip stack when switching back from an offscreen framebuffer,
* but it's not necessary anymore given that framebuffers now own
* separate clip stacks which will be automatically switched between
* when a new buffer is set. Calling this function has no effect
*
* Since: 0.8.2
*/
COGL_DEPRECATED
void
cogl_clip_stack_restore (void);
/**
* cogl_set_framebuffer:
* @buffer: A #CoglFramebuffer object, either onscreen or offscreen.

View File

@ -30,14 +30,13 @@
#include <glib.h>
#include "cogl-clip-state.h"
#include "cogl-clip-stack.h"
#include "cogl-clip-state-private.h"
#include "cogl-context-private.h"
#include "cogl-framebuffer-private.h"
#include "cogl-journal-private.h"
#include "cogl-util.h"
#include "cogl-matrix-private.h"
#include "cogl-clip-state.h"
#include "cogl1-context.h"
#include "cogl-path/cogl-path.h"
@ -108,13 +107,16 @@ cogl_clip_pop (void)
void
cogl_clip_stack_save (void)
{
_cogl_framebuffer_save_clip_stack (cogl_get_draw_framebuffer ());
/* This function was just used to temporarily switch the clip stack
* when using an offscreen buffer. This is no longer needed because
* each framebuffer maintains its own clip stack. The function is
* documented to do nothing since version 1.2 */
}
void
cogl_clip_stack_restore (void)
{
_cogl_framebuffer_restore_clip_stack (cogl_get_draw_framebuffer ());
/* Do nothing. See cogl_clip_stack_save() */
}
/* XXX: This should never have been made public API! */
@ -128,60 +130,3 @@ cogl_clip_ensure (void)
* nothing here.
*/
}
void
_cogl_clip_state_init (CoglClipState *clip_state)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
clip_state->stacks = NULL;
/* Add an intial stack */
_cogl_clip_state_save_clip_stack (clip_state);
}
void
_cogl_clip_state_destroy (CoglClipState *clip_state)
{
/* Destroy all of the stacks */
while (clip_state->stacks)
_cogl_clip_state_restore_clip_stack (clip_state);
}
CoglClipStack *
_cogl_clip_state_get_stack (CoglClipState *clip_state)
{
return clip_state->stacks->data;
}
void
_cogl_clip_state_set_stack (CoglClipState *clip_state,
CoglClipStack *stack)
{
/* Replace the top of the stack of stacks */
_cogl_clip_stack_ref (stack);
_cogl_clip_stack_unref (clip_state->stacks->data);
clip_state->stacks->data = stack;
}
void
_cogl_clip_state_save_clip_stack (CoglClipState *clip_state)
{
clip_state->stacks = g_slist_prepend (clip_state->stacks, NULL);
}
void
_cogl_clip_state_restore_clip_stack (CoglClipState *clip_state)
{
CoglClipStack *stack;
_COGL_RETURN_IF_FAIL (clip_state->stacks != NULL);
stack = clip_state->stacks->data;
_cogl_clip_stack_unref (stack);
/* Revert to an old stack */
clip_state->stacks = g_slist_delete_link (clip_state->stacks,
clip_state->stacks);
}

View File

@ -0,0 +1,259 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2010,2013 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL_CLIP_STATE_H__
#define __COGL_CLIP_STATE_H__
#include <cogl/cogl-types.h>
#include <cogl/cogl-macros.h>
#include <cogl/cogl-primitive.h>
COGL_BEGIN_DECLS
/**
* SECTION:cogl-clipping
* @short_description: Fuctions for manipulating a stack of clipping regions
*
* To support clipping your geometry to rectangles or paths Cogl exposes a
* stack based API whereby each clip region you push onto the stack is
* intersected with the previous region.
*/
/**
* cogl_clip_push_window_rectangle:
* @x_offset: left edge of the clip rectangle in window coordinates
* @y_offset: top edge of the clip rectangle in window coordinates
* @width: width of the clip rectangle
* @height: height of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are not transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*
* Since: 1.2
* Deprecated: 1.16: Use cogl_framebuffer_push_scissor_clip() instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_scissor_clip)
void
cogl_clip_push_window_rectangle (int x_offset,
int y_offset,
int width,
int height);
/**
* cogl_clip_push_window_rect:
* @x_offset: left edge of the clip rectangle in window coordinates
* @y_offset: top edge of the clip rectangle in window coordinates
* @width: width of the clip rectangle
* @height: height of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are not transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*
* Deprecated: 1.16: Use cogl_framebuffer_push_scissor_clip() instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_scissor_clip)
void
cogl_clip_push_window_rect (float x_offset,
float y_offset,
float width,
float height);
/**
* cogl_clip_push_rectangle:
* @x0: x coordinate for top left corner of the clip rectangle
* @y0: y coordinate for top left corner of the clip rectangle
* @x1: x coordinate for bottom right corner of the clip rectangle
* @y1: y coordinate for bottom right corner of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*
* Since: 1.2
* Deprecated: 1.16: Use cogl_framebuffer_push_rectangle_clip()
* instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_rectangle_clip)
void
cogl_clip_push_rectangle (float x0,
float y0,
float x1,
float y1);
/**
* cogl_clip_push:
* @x_offset: left edge of the clip rectangle
* @y_offset: top edge of the clip rectangle
* @width: width of the clip rectangle
* @height: height of the clip rectangle
*
* Specifies a rectangular clipping area for all subsequent drawing
* operations. Any drawing commands that extend outside the rectangle
* will be clipped so that only the portion inside the rectangle will
* be displayed. The rectangle dimensions are transformed by the
* current model-view matrix.
*
* The rectangle is intersected with the current clip region. To undo
* the effect of this function, call cogl_clip_pop().
*
* Deprecated: 1.16: The x, y, width, height arguments are inconsistent
* with other API that specify rectangles in model space, and when used
* with a coordinate space that puts the origin at the center and y+
* extending up, it's awkward to use. Please use
* cogl_framebuffer_push_rectangle_clip()
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_rectangle_clip)
void
cogl_clip_push (float x_offset,
float y_offset,
float width,
float height);
/**
* cogl_clip_push_primitive:
* @primitive: A #CoglPrimitive describing a flat 2D shape
* @bounds_x1: x coordinate for the top-left corner of the primitives
* bounds
* @bounds_y1: y coordinate for the top-left corner of the primitives
* bounds
* @bounds_x2: x coordinate for the bottom-right corner of the primitives
* bounds
* @bounds_y2: y coordinate for the bottom-right corner of the
* primitives bounds.
*
* Sets a new clipping area using a 2D shaped described with a
* #CoglPrimitive. The shape must not contain self overlapping
* geometry and must lie on a single 2D plane. A bounding box of the
* 2D shape in local coordinates (the same coordinates used to
* describe the shape) must be given. It is acceptable for the bounds
* to be larger than the true bounds but behaviour is undefined if the
* bounds are smaller than the true bounds.
*
* The primitive is transformed by the current model-view matrix and
* the silhouette is intersected with the previous clipping area. To
* restore the previous clipping area, call
* cogl_clip_pop().
*
* Since: 1.10
* Stability: unstable
* Deprecated: 1.16: Use cogl_framebuffer_push_primitive_clip()
* instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_push_primitive_clip)
void
cogl_clip_push_primitive (CoglPrimitive *primitive,
float bounds_x1,
float bounds_y1,
float bounds_x2,
float bounds_y2);
/**
* cogl_clip_pop:
*
* Reverts the clipping region to the state before the last call to
* cogl_clip_push().
*
* Deprecated: 1.16: Use cogl_framebuffer_pop_clip() instead
*/
COGL_DEPRECATED_IN_1_16_FOR (cogl_framebuffer_pop_clip)
void
cogl_clip_pop (void);
/**
* cogl_clip_ensure:
*
* Ensures that the current clipping region has been set in GL. This
* will automatically be called before any Cogl primitives but it
* maybe be neccessary to call if you are using raw GL calls with
* clipping.
*
* Deprecated: 1.2: Calling this function has no effect
*
* Since: 1.0
*/
COGL_DEPRECATED
void
cogl_clip_ensure (void);
/**
* cogl_clip_stack_save:
*
* Save the entire state of the clipping stack and then clear all
* clipping. The previous state can be returned to with
* cogl_clip_stack_restore(). Each call to cogl_clip_push() after this
* must be matched by a call to cogl_clip_pop() before calling
* cogl_clip_stack_restore().
*
* Deprecated: 1.2: This was originally added to allow us to save the
* clip stack when switching to an offscreen framebuffer, but it's
* not necessary anymore given that framebuffers now own separate
* clip stacks which will be automatically switched between when a
* new buffer is set. Calling this function has no effect
*
* Since: 0.8.2
*/
COGL_DEPRECATED
void
cogl_clip_stack_save (void);
/**
* cogl_clip_stack_restore:
*
* Restore the state of the clipping stack that was previously saved
* by cogl_clip_stack_save().
*
* Deprecated: 1.2: This was originally added to allow us to restore
* the clip stack when switching back from an offscreen framebuffer,
* but it's not necessary anymore given that framebuffers now own
* separate clip stacks which will be automatically switched between
* when a new buffer is set. Calling this function has no effect
*
* Since: 0.8.2
*/
COGL_DEPRECATED
void
cogl_clip_stack_restore (void);
COGL_END_DECLS
#endif /* __COGL_CLIP_STATE_H__ */

View File

@ -148,8 +148,7 @@ _cogl_framebuffer_gl_flush_viewport_state (CoglFramebuffer *framebuffer)
static void
_cogl_framebuffer_gl_flush_clip_state (CoglFramebuffer *framebuffer)
{
CoglClipStack *stack = _cogl_clip_state_get_stack (&framebuffer->clip_state);
_cogl_clip_stack_flush (stack, framebuffer);
_cogl_clip_stack_flush (framebuffer->clip_stack, framebuffer);
}
static void