[cogl] Remove the framebuffer's stack of clip stacks



commit 8655027fdcf03b02fcbbb02d179a0a88ed79c5b3
Author: Neil Roberts <neil linux intel com>
Date:   Fri Nov 29 14:17:55 2013 +0000

    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
    
    Reviewed-by: Robert Bragg <robert linux intel com>

 cogl-path/cogl-path.c                |    5 +-
 cogl/Makefile.am                     |    6 +--
 cogl/cogl-clip-state-private.h       |   56 --------------------
 cogl/cogl-clip-state.c               |   95 ----------------------------------
 cogl/cogl-clip-state.h               |   37 -------------
 cogl/cogl-framebuffer-private.h      |    7 +--
 cogl/cogl-framebuffer.c              |   68 +++++-------------------
 cogl/driver/gl/cogl-framebuffer-gl.c |    3 +-
 8 files changed, 20 insertions(+), 257 deletions(-)
---
diff --git a/cogl-path/cogl-path.c b/cogl-path/cogl-path.c
index aef43c0..a02dac4 100644
--- a/cogl-path/cogl-path.c
+++ b/cogl-path/cogl-path.c
@@ -1450,7 +1450,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 =
@@ -1464,8 +1463,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,
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index 90b832c..c56599a 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -63,7 +63,6 @@ cogl_public_h = \
        $(srcdir)/cogl-attribute.h              \
        $(srcdir)/cogl-bitmap.h                 \
        $(srcdir)/cogl-buffer.h                 \
-       $(srcdir)/cogl-clip-state.h             \
        $(srcdir)/cogl-clutter.h                \
        $(srcdir)/cogl-color.h                  \
        $(srcdir)/cogl-context.h                \
@@ -232,9 +231,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)/cogl-feature-private.h                \
        $(srcdir)/cogl-feature-private.c                \
        $(srcdir)/cogl-color-private.h                  \
@@ -506,7 +502,7 @@ libcogl2_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_primitive_draw|_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|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_primitive_draw|_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|test_|unit_test_).*"
 
 libcogl2_la_SOURCES = $(cogl_sources_c)
 nodist_libcogl2_la_SOURCES = $(BUILT_SOURCES)
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 94bc6d2..507c62d 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -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
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 2be598a..90cc382 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -117,8 +117,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);
 
@@ -165,7 +164,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;
@@ -414,27 +413,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
@@ -744,10 +735,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;
@@ -1641,10 +1629,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)
@@ -1659,7 +1645,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 =
@@ -1673,8 +1658,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,
@@ -1693,7 +1678,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 =
@@ -1707,8 +1691,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,
@@ -1724,31 +1708,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 |=
diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index b88ed34..ff68ed9 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]