[cogl] replace public cogl_flush with _cogl_framebuffer_flush



commit 1206a05358dfedd96a865ec084229c69dd4f36d2
Author: Robert Bragg <robert linux intel com>
Date:   Fri Nov 9 00:24:08 2012 +0000

    replace public cogl_flush with _cogl_framebuffer_flush
    
    This removes the cogl_flush() api which depends on a global Cogl context
    and provides a more specific _cogl_framebuffer_flush() instead. This
    new function isn't public since we don't currently see a use for this
    api for applications. (The previously documented use for cogl_flush() to
    allow applications to intermix direct GL and cogl usage was missleading
    and wouldn't have worked for intermixing drawing commands. Intermixing
    GL to create objects such as textures doesn't require any flush api)
    
    Since there are a few places internally where we do actually need to
    flush *all* framebuffer journals we keep an equivalent to cogl_flush()
    renamed to _cogl_flush() which now takes a CoglContext pointer.
    
    cogl1-context.h has now been removed since there was nothing left in it.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/Makefile.am                       |    1 -
 cogl/cogl-atlas-texture.c              |    8 ++-
 cogl/cogl-blit.c                       |    1 -
 cogl/cogl-clip-stack.c                 |    1 -
 cogl/cogl-clip-state.c                 |    1 -
 cogl/cogl-context.c                    |    1 -
 cogl/cogl-debug.c                      |    1 -
 cogl/cogl-framebuffer-private.h        |   35 ++++++++++++++++
 cogl/cogl-framebuffer.c                |   10 ++++-
 cogl/cogl-journal.c                    |    1 -
 cogl/cogl-onscreen.c                   |    8 +--
 cogl/cogl-path.c                       |    1 -
 cogl/cogl-pipeline.c                   |   10 ++--
 cogl/cogl-primitives.c                 |    1 -
 cogl/cogl-private.h                    |    3 +
 cogl/cogl-texture.c                    |    1 -
 cogl/cogl.c                            |    5 +--
 cogl/cogl.h                            |    1 -
 cogl/cogl1-context.h                   |   71 --------------------------------
 doc/reference/cogl2/cogl2-sections.txt |    3 -
 tests/conform/test-gles2-context.c     |    2 +-
 tests/conform/test-sub-texture.c       |    1 -
 22 files changed, 61 insertions(+), 106 deletions(-)
---
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index a026e91..a9f128b 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -106,7 +106,6 @@ cogl_public_h = \
 	$(srcdir)/cogl-vector.h 		\
 	$(srcdir)/cogl-version.h		\
 	$(srcdir)/cogl.h			\
-	$(srcdir)/cogl1-context.h 		\
 	$(NULL)
 
 # experimental api headers
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index f3f0910..db7b927 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -42,10 +42,10 @@
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-atlas.h"
-#include "cogl1-context.h"
 #include "cogl-sub-texture.h"
 #include "cogl-error-private.h"
 #include "cogl-texture-gl-private.h"
+#include "cogl-private.h"
 
 #include <stdlib.h>
 
@@ -110,6 +110,8 @@ _cogl_atlas_texture_pre_reorganize_cb (void *data)
 {
   CoglAtlas *atlas = data;
 
+  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
   /* We don't know if any journal entries currently depend on OpenGL
    * texture coordinates that would be invalidated by reorganizing
    * this atlas so we flush all journals before migrating.
@@ -117,7 +119,7 @@ _cogl_atlas_texture_pre_reorganize_cb (void *data)
    * We are assuming that texture atlas migration never happens
    * during a flush so we don't have to consider recursion here.
    */
-  cogl_flush ();
+  _cogl_flush (ctx);
 
   if (atlas->map)
     _cogl_rectangle_map_foreach (atlas->map,
@@ -379,7 +381,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex)
    * We are assuming that texture atlas migration never happens
    * during a flush so we don't have to consider recursion here.
    */
-  cogl_flush ();
+  _cogl_flush (ctx);
 
   standalone_tex =
     _cogl_atlas_copy_rectangle (atlas_tex->atlas,
diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c
index d74356d..3e738a1 100644
--- a/cogl/cogl-blit.c
+++ b/cogl/cogl-blit.c
@@ -37,7 +37,6 @@
 #include "cogl-texture-private.h"
 #include "cogl-texture-2d-private.h"
 #include "cogl-private.h"
-#include "cogl1-context.h"
 
 static const CoglBlitMode *_cogl_blit_default_mode = NULL;
 
diff --git a/cogl/cogl-clip-stack.c b/cogl/cogl-clip-stack.c
index a25a9db..da881eb 100644
--- a/cogl/cogl-clip-stack.c
+++ b/cogl/cogl-clip-stack.c
@@ -44,7 +44,6 @@
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-attribute-private.h"
 #include "cogl-primitive-private.h"
-#include "cogl1-context.h"
 #include "cogl-offscreen.h"
 #include "cogl-matrix-stack.h"
 
diff --git a/cogl/cogl-clip-state.c b/cogl/cogl-clip-state.c
index 8325e96..464bc61 100644
--- a/cogl/cogl-clip-state.c
+++ b/cogl/cogl-clip-state.c
@@ -39,7 +39,6 @@
 #include "cogl-util.h"
 #include "cogl-matrix-private.h"
 #include "cogl-clip-state.h"
-#include "cogl1-context.h"
 
 void
 _cogl_clip_state_init (CoglClipState *clip_state)
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index ceb587a..3fc199c 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -46,7 +46,6 @@
 #include "cogl-onscreen-private.h"
 #include "cogl-path.h"
 #include "cogl-attribute-private.h"
-#include "cogl1-context.h"
 #include "cogl-gpu-info-private.h"
 #include "cogl-config-private.h"
 #include "cogl-error-private.h"
diff --git a/cogl/cogl-debug.c b/cogl/cogl-debug.c
index 1a7e7e6..01af450 100644
--- a/cogl/cogl-debug.c
+++ b/cogl/cogl-debug.c
@@ -30,7 +30,6 @@
 
 #include "cogl-private.h"
 #include "cogl-debug.h"
-#include "cogl1-context.h"
 
 /* XXX: If you add a debug option, please also add an option
  * definition to cogl-debug-options.h. This will enable us - for
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 81fbeef..71fa89e 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -448,5 +448,40 @@ _cogl_framebuffer_get_projection_entry (CoglFramebuffer *framebuffer)
   return projection_stack->last_entry;
 }
 
+/*
+ * _cogl_framebuffer_flush:
+ * @framebuffer: A #CoglFramebuffer
+ *
+ * This function should only need to be called in exceptional circumstances.
+ *
+ * As an optimization Cogl drawing functions may batch up primitives
+ * internally, so if you are trying to use native drawing apis
+ * directly to a Cogl onscreen framebuffer or raw OpenGL outside of
+ * Cogl you stand a better chance of being successful if you ask Cogl
+ * to flush any batched drawing before issuing your own drawing
+ * commands.
+ *
+ * This api only ensure that the underlying driver is issued all the
+ * commands necessary to draw the batched primitives. It provides no
+ * guarantees about when the driver will complete the rendering.
+ *
+ * This provides no guarantees about native graphics state or OpenGL
+ * state upon returning and to avoid confusing Cogl you should aim to
+ * save and restore any changes you make before resuming use of Cogl.
+ *
+ * Note: If you make OpenGL state changes with the intention of
+ * affecting Cogl drawing primitives you stand a high chance of
+ * conflicting with Cogl internals which can change so this is not
+ * supported.
+ *
+ * XXX: We considered making this api public, but actually for the
+ * direct use of OpenGL usecase this api isn't really enough since
+ * it would leave GL in a completely undefined state which would
+ * basically make it inpractical for applications to use. To really
+ * support mixing raw GL with Cogl we'd probabably need to guarantee
+ * that we reset all GL state to defaults.
+ */
+void
+_cogl_framebuffer_flush (CoglFramebuffer *framebuffer);
 
 #endif /* __COGL_FRAMEBUFFER_PRIVATE_H */
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 769c903..f9b9887 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -45,7 +45,6 @@
 #include "cogl-matrix-private.h"
 #include "cogl-primitive-private.h"
 #include "cogl-offscreen.h"
-#include "cogl1-context.h"
 #include "cogl-private.h"
 #include "cogl-primitives-private.h"
 #include "cogl-path-private.h"
@@ -552,6 +551,12 @@ _cogl_framebuffer_flush_journal (CoglFramebuffer *framebuffer)
 }
 
 void
+_cogl_framebuffer_flush (CoglFramebuffer *framebuffer)
+{
+  _cogl_framebuffer_flush_journal (framebuffer);
+}
+
+void
 _cogl_framebuffer_flush_dependency_journals (CoglFramebuffer *framebuffer)
 {
   GList *l;
@@ -918,7 +923,8 @@ cogl_framebuffer_set_dither_enabled (CoglFramebuffer *framebuffer,
   if (framebuffer->dither_enabled == dither_enabled)
     return;
 
-  cogl_flush (); /* Currently dithering changes aren't tracked in the journal */
+  _cogl_framebuffer_flush_journal (framebuffer);
+
   framebuffer->dither_enabled = dither_enabled;
 
   if (framebuffer->context->current_draw_buffer == framebuffer)
diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c
index f20ec21..51d859e 100644
--- a/cogl/cogl-journal.c
+++ b/cogl/cogl-journal.c
@@ -38,7 +38,6 @@
 #include "cogl-attribute-private.h"
 #include "cogl-point-in-poly-private.h"
 #include "cogl-private.h"
-#include "cogl1-context.h"
 
 #include <string.h>
 #include <gmodule.h>
diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c
index 99a0ea0..9ae985c 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -31,7 +31,6 @@
 #include "cogl-onscreen-template-private.h"
 #include "cogl-context-private.h"
 #include "cogl-object-private.h"
-#include "cogl1-context.h"
 
 static void _cogl_onscreen_free (CoglOnscreen *onscreen);
 
@@ -118,8 +117,8 @@ cogl_onscreen_swap_buffers (CoglOnscreen *onscreen)
 
   _COGL_RETURN_IF_FAIL  (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
 
-  /* FIXME: we shouldn't need to flush *all* journals here! */
-  cogl_flush ();
+  _cogl_framebuffer_flush_journal (framebuffer);
+
   winsys = _cogl_framebuffer_get_winsys (framebuffer);
   winsys->onscreen_swap_buffers (COGL_ONSCREEN (framebuffer));
   cogl_framebuffer_discard_buffers (framebuffer,
@@ -138,8 +137,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
 
   _COGL_RETURN_IF_FAIL  (framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN);
 
-  /* FIXME: we shouldn't need to flush *all* journals here! */
-  cogl_flush ();
+  _cogl_framebuffer_flush_journal (framebuffer);
 
   winsys = _cogl_framebuffer_get_winsys (framebuffer);
 
diff --git a/cogl/cogl-path.c b/cogl/cogl-path.c
index af82950..f02d5b3 100644
--- a/cogl/cogl-path.c
+++ b/cogl/cogl-path.c
@@ -43,7 +43,6 @@
 #include "cogl-primitives-private.h"
 #include "cogl-private.h"
 #include "cogl-attribute-private.h"
-#include "cogl1-context.h"
 #include "tesselator/tesselator.h"
 
 #include <string.h>
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 35d0094..3bd62a7 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -45,7 +45,7 @@
 #include "cogl-util.h"
 #include "cogl-profile.h"
 #include "cogl-depth-state-private.h"
-#include "cogl1-context.h"
+#include "cogl-private.h"
 
 #include <glib.h>
 #include <glib/gprintf.h>
@@ -1101,10 +1101,10 @@ _cogl_pipeline_pre_change_notify (CoglPipeline     *pipeline,
 
       if (!skip_journal_flush)
         {
-          /* XXX: note we use cogl_flush() not _cogl_flush_journal() so
-           * we will flush *all* known journals that might reference the
-           * current pipeline. */
-          cogl_flush ();
+          /* XXX: note we need to use _cogl_flush() so we will flush
+           * *all* journals that might reference the current pipeline.
+           */
+          _cogl_flush (ctx);
         }
     }
 
diff --git a/cogl/cogl-primitives.c b/cogl/cogl-primitives.c
index 89a7106..c72d5d2 100644
--- a/cogl/cogl-primitives.c
+++ b/cogl/cogl-primitives.c
@@ -37,7 +37,6 @@
 #include "cogl-private.h"
 #include "cogl-meta-texture.h"
 #include "cogl-framebuffer-private.h"
-#include "cogl1-context.h"
 #include "cogl-primitives-private.h"
 
 #include <string.h>
diff --git a/cogl/cogl-private.h b/cogl/cogl-private.h
index 056d606..2e8eb92 100644
--- a/cogl/cogl-private.h
+++ b/cogl/cogl-private.h
@@ -34,6 +34,9 @@ CoglBool
 _cogl_check_extension (const char *name, char * const *ext);
 
 void
+_cogl_flush (CoglContext *ctx);
+
+void
 _cogl_clear (const CoglColor *color, unsigned long buffers);
 
 void
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index 6958160..794c53a 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -51,7 +51,6 @@
 #include "cogl-object-private.h"
 #include "cogl-object-private.h"
 #include "cogl-framebuffer-private.h"
-#include "cogl1-context.h"
 #include "cogl-sub-texture.h"
 #include "cogl-primitive-texture.h"
 #include "cogl-error-private.h"
diff --git a/cogl/cogl.c b/cogl/cogl.c
index 62d511e..256c337 100644
--- a/cogl/cogl.c
+++ b/cogl/cogl.c
@@ -48,7 +48,6 @@
 #include "cogl-renderer-private.h"
 #include "cogl-config-private.h"
 #include "cogl-private.h"
-#include "cogl1-context.h"
 #include "cogl-offscreen.h"
 
 #ifdef COGL_GL_DEBUG
@@ -134,12 +133,10 @@ cogl_foreach_feature (CoglContext *ctx,
 }
 
 void
-cogl_flush (void)
+_cogl_flush (CoglContext *ctx)
 {
   GList *l;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   for (l = ctx->framebuffers; l; l = l->next)
     _cogl_framebuffer_flush_journal (l->data);
 }
diff --git a/cogl/cogl.h b/cogl/cogl.h
index a5001eb..8557570 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -35,7 +35,6 @@
 #include <cogl/cogl-error.h>
 
 #include <cogl/cogl-object.h>
-#include <cogl/cogl1-context.h>
 #include <cogl/cogl-bitmap.h>
 #include <cogl/cogl-color.h>
 #include <cogl/cogl-matrix.h>
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index e816a15..0ae9628 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -100,9 +100,6 @@ COGL_TYPE_BUFFER_BIT
 <SUBSECTION>
 CoglReadPixelsFlags
 
-<SUBSECTION>
-cogl_flush
-
 <SUBSECTION Standard>
 COGL_TYPE_ATTRIBUTE_TYPE
 COGL_TYPE_BLEND_STRING_ERROR
diff --git a/tests/conform/test-gles2-context.c b/tests/conform/test-gles2-context.c
index 9a3c8b6..fe6a893 100644
--- a/tests/conform/test-gles2-context.c
+++ b/tests/conform/test-gles2-context.c
@@ -87,7 +87,7 @@ test_push_pop_single_context (void)
    * of textures and so we explicitly flush the drawn rectangle to the
    * framebuffer now otherwise it may be batched until after the
    * offscreen texture has been modified again. */
-  cogl_flush ();
+  cogl_framebuffer_finish (test_fb);
 
   /* Clear the offscreen framebuffer to blue using GLES2 before
    * reading back from the onscreen framebuffer in case we mistakenly
diff --git a/tests/conform/test-sub-texture.c b/tests/conform/test-sub-texture.c
index 0291afb..5858556 100644
--- a/tests/conform/test-sub-texture.c
+++ b/tests/conform/test-sub-texture.c
@@ -215,7 +215,6 @@ validate_result (TestState *state)
 
   /* Sub sub texture */
   p = texture_data = g_malloc (10 * 10 * 4);
-  cogl_flush ();
   cogl_framebuffer_read_pixels (test_fb,
                                 0, SOURCE_SIZE * 2, 10, 10,
                                 COGL_PIXEL_FORMAT_RGBA_8888,



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