summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2012-11-09 00:24:08 +0000
committerRobert Bragg <robert@linux.intel.com>2012-11-27 18:22:42 +0000
commit1206a05358dfedd96a865ec084229c69dd4f36d2 (patch)
tree0a15087301c9aab960d379ea4554e81d315577ba
parentd66afbd0758539330490945c699a05c0749c76aa (diff)
downloadcogl-1206a05358dfedd96a865ec084229c69dd4f36d2.tar.gz
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>
-rw-r--r--cogl/Makefile.am1
-rw-r--r--cogl/cogl-atlas-texture.c8
-rw-r--r--cogl/cogl-blit.c1
-rw-r--r--cogl/cogl-clip-stack.c1
-rw-r--r--cogl/cogl-clip-state.c1
-rw-r--r--cogl/cogl-context.c1
-rw-r--r--cogl/cogl-debug.c1
-rw-r--r--cogl/cogl-framebuffer-private.h35
-rw-r--r--cogl/cogl-framebuffer.c10
-rw-r--r--cogl/cogl-journal.c1
-rw-r--r--cogl/cogl-onscreen.c8
-rw-r--r--cogl/cogl-path.c1
-rw-r--r--cogl/cogl-pipeline.c10
-rw-r--r--cogl/cogl-primitives.c1
-rw-r--r--cogl/cogl-private.h3
-rw-r--r--cogl/cogl-texture.c1
-rw-r--r--cogl/cogl.c5
-rw-r--r--cogl/cogl.h1
-rw-r--r--cogl/cogl1-context.h71
-rw-r--r--doc/reference/cogl2/cogl2-sections.txt3
-rw-r--r--tests/conform/test-gles2-context.c2
-rw-r--r--tests/conform/test-sub-texture.c1
22 files changed, 61 insertions, 106 deletions
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index a026e91d..a9f128bc 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 f3f0910d..db7b9277 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 d74356d1..3e738a14 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 a25a9db8..da881ebd 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 8325e96b..464bc61d 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 ceb587a2..3fc199ce 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 1a7e7e61..01af450f 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 81fbeef1..71fa89eb 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 769c903a..f9b98870 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 f20ec219..51d859e1 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 99a0ea03..9ae985c6 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 af829502..f02d5b3e 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 35d00940..3bd62a71 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 89a7106a..c72d5d2d 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 056d6065..2e8eb92c 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 69581601..794c53a3 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 62d511ef..256c3372 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 a5001eb1..8557570f 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/cogl/cogl1-context.h b/cogl/cogl1-context.h
deleted file mode 100644
index 239c9fbc..00000000
--- a/cogl/cogl1-context.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Cogl
- *
- * An object oriented GL/GLES Abstraction/Utility Layer
- *
- * Copyright (C) 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/>.
- *
- * Authors:
- * Robert Bragg <robert@linux.intel.com>
- *
- */
-
-#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
-#error "Only <cogl/cogl.h> can be included directly."
-#endif
-
-#ifndef __COGL_1_CONTEXT_H__
-#define __COGL_1_CONTEXT_H__
-
-#include <cogl/cogl-types.h>
-#include <cogl/cogl-texture.h>
-#include <cogl/cogl-framebuffer.h>
-
-COGL_BEGIN_DECLS
-
-/**
- * cogl_flush:
- *
- * 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 raw GL outside of Cogl you stand a
- * better chance of being successful if you ask Cogl to flush any batched
- * geometry before making your state changes.
- *
- * It 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 the GL state upon returning and to avoid
- * confusing Cogl you should aim to restore any changes you make before
- * resuming use of Cogl.
- *
- * If you are making state changes with the intention of affecting Cogl drawing
- * primitives you are 100% on your own since you stand a good chance of
- * conflicting with Cogl internals. For example clutter-gst which currently
- * uses direct GL calls to bind ARBfp programs will very likely break when Cogl
- * starts to use ARBfb programs itself for the material API.
- *
- * Since: 1.0
- */
-void
-cogl_flush (void);
-
-COGL_END_DECLS
-
-#endif /* __COGL_1_CONTEXT_H__ */
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index e816a15d..0ae96288 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 9a3c8b67..fe6a893b 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 0291afbe..58585562 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,