summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2013-08-16 22:43:19 +0100
committerRobert Bragg <robert@linux.intel.com>2013-08-19 22:44:44 +0100
commit1317a25a91f7826239c49828b5eb5c247de8d301 (patch)
treea90ad3d940f6f5a9000e752be9ecf8bfee3a8a0f
parent64aa6092ce3413537f5e34807031e25eaaab5a21 (diff)
downloadcogl-1317a25a91f7826239c49828b5eb5c247de8d301.tar.gz
offscreen: rename _new_to_texture to _new_with_texture
This renames cogl_offscreen_new_to_texture to cogl_offscreen_new_with_texture. The intention is to then cherry-pick this back to the cogl-1.16 branch so we can maintain a parallel cogl_offscreen_new_to_texture() function which keeps the synchronous allocation semantics that some clutter applications are currently relying on. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit ecc6d2f64481626992b2fe6cdfa7b999270b28f5) Note: Since we can't break the 1.x api on this branch this keeps a thin shim around cogl_offscreen_new_with_texture to implement cogl_offscreen_new_to_texture with its synchronous allocation semantics.
-rw-r--r--cogl/cogl-blit.c8
-rw-r--r--cogl/cogl-framebuffer-private.h12
-rw-r--r--cogl/cogl-framebuffer.c25
-rw-r--r--cogl/cogl-framebuffer.h4
-rw-r--r--cogl/cogl-gles2-context.c2
-rw-r--r--cogl/cogl-offscreen.h39
-rw-r--r--cogl/cogl-texture.c2
-rw-r--r--cogl/cogl.symbols2
-rw-r--r--doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt2
-rw-r--r--doc/reference/cogl/cogl-sections.txt1
-rw-r--r--examples/cogl-gles2-context.c2
-rw-r--r--examples/cogl-msaa.c2
-rw-r--r--test-fixtures/test-utils.c2
-rw-r--r--tests/conform/test-backface-culling.c2
-rw-r--r--tests/conform/test-color-mask.c2
-rw-r--r--tests/conform/test-framebuffer-get-bits.c4
-rw-r--r--tests/conform/test-gles2-context.c4
-rw-r--r--tests/conform/test-offscreen.c4
-rw-r--r--tests/conform/test-readpixels.c2
-rw-r--r--tests/conform/test-viewport.c2
20 files changed, 85 insertions, 38 deletions
diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c
index ea457b95..fffd9ede 100644
--- a/cogl/cogl-blit.c
+++ b/cogl/cogl-blit.c
@@ -51,7 +51,7 @@ _cogl_blit_texture_render_begin (CoglBlitData *data)
unsigned int dst_width, dst_height;
CoglError *ignore_error = NULL;
- offscreen = _cogl_offscreen_new_to_texture_full
+ offscreen = _cogl_offscreen_new_with_texture_full
(data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */);
fb = COGL_FRAMEBUFFER (offscreen);
@@ -156,7 +156,7 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data)
!(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT))
return FALSE;
- dst_offscreen = _cogl_offscreen_new_to_texture_full
+ dst_offscreen = _cogl_offscreen_new_with_texture_full
(data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */);
dst_fb = COGL_FRAMEBUFFER (dst_offscreen);
@@ -166,7 +166,7 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data)
goto error;
}
- src_offscreen= _cogl_offscreen_new_to_texture_full
+ src_offscreen= _cogl_offscreen_new_with_texture_full
(data->src_tex,
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,
0 /* level */);
@@ -227,7 +227,7 @@ _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data)
if (!cogl_is_texture_2d (data->dst_tex))
return FALSE;
- offscreen = _cogl_offscreen_new_to_texture_full
+ offscreen = _cogl_offscreen_new_with_texture_full
(data->src_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */);
fb = COGL_FRAMEBUFFER (offscreen);
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index a220de9c..233f1c52 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -56,7 +56,7 @@ typedef struct
CoglBool depth_texture_enabled;
} CoglFramebufferConfig;
-/* Flags to pass to _cogl_offscreen_new_to_texture_full */
+/* Flags to pass to _cogl_offscreen_new_with_texture_full */
typedef enum
{
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL = 1
@@ -209,7 +209,7 @@ struct _CoglOffscreen
CoglOffscreenAllocateFlags allocation_flags;
- /* FIXME: _cogl_offscreen_new_to_texture_full should be made to use
+ /* FIXME: _cogl_offscreen_new_with_texture_full should be made to use
* fb->config to configure if we want a depth or stencil buffer so
* we can get rid of these flags */
CoglOffscreenFlags create_flags;
@@ -302,7 +302,7 @@ void
_cogl_free_framebuffer_stack (GSList *stack);
/*
- * _cogl_offscreen_new_to_texture_full:
+ * _cogl_offscreen_new_with_texture_full:
* @texture: A #CoglTexture pointer
* @create_flags: Flags specifying how to create the FBO
* @level: The mipmap level within the texture to target
@@ -315,9 +315,9 @@ _cogl_free_framebuffer_stack (GSList *stack);
* Return value: the new CoglOffscreen object.
*/
CoglOffscreen *
-_cogl_offscreen_new_to_texture_full (CoglTexture *texture,
- CoglOffscreenFlags create_flags,
- int level);
+_cogl_offscreen_new_with_texture_full (CoglTexture *texture,
+ CoglOffscreenFlags create_flags,
+ int level);
/*
* _cogl_push_framebuffers:
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index fbd3dd6d..8487578b 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -607,9 +607,9 @@ _cogl_framebuffer_flush_dependency_journals (CoglFramebuffer *framebuffer)
}
CoglOffscreen *
-_cogl_offscreen_new_to_texture_full (CoglTexture *texture,
- CoglOffscreenFlags create_flags,
- int level)
+_cogl_offscreen_new_with_texture_full (CoglTexture *texture,
+ CoglOffscreenFlags create_flags,
+ int level)
{
CoglContext *ctx = texture->context;
CoglOffscreen *offscreen;
@@ -617,7 +617,6 @@ _cogl_offscreen_new_to_texture_full (CoglTexture *texture,
int level_width;
int level_height;
CoglOffscreen *ret;
- CoglError *error = NULL;
_COGL_RETURN_VAL_IF_FAIL (cogl_is_texture (texture), NULL);
_COGL_RETURN_VAL_IF_FAIL (level < _cogl_texture_get_n_levels (texture),
@@ -649,9 +648,19 @@ _cogl_offscreen_new_to_texture_full (CoglTexture *texture,
_cogl_texture_associate_framebuffer (texture, fb);
- if (!cogl_framebuffer_allocate (ret, &error))
+ return ret;
+}
+
+/* XXX: deprecated api */
+CoglOffscreen *
+cogl_offscreen_new_to_texture (CoglTexture *texture)
+{
+ CoglOffscreen *ret = _cogl_offscreen_new_with_texture_full (texture, 0, 0);
+ CoglError *error = NULL;
+
+ if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (ret), &error))
{
- cogl_object_unref (offscreen);
+ cogl_object_unref (ret);
cogl_error_free (error);
ret = NULL;
}
@@ -660,9 +669,9 @@ _cogl_offscreen_new_to_texture_full (CoglTexture *texture,
}
CoglOffscreen *
-cogl_offscreen_new_to_texture (CoglTexture *texture)
+cogl_offscreen_new_with_texture (CoglTexture *texture)
{
- return _cogl_offscreen_new_to_texture_full (texture, 0, 0);
+ return _cogl_offscreen_new_with_texture_full (texture, 0, 0);
}
static void
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index b83d2796..554cc50b 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -70,7 +70,7 @@ COGL_BEGIN_DECLS
*
* If you want to create a new framebuffer then you should start by
* looking at the #CoglOnscreen and #CoglOffscreen constructor
- * functions, such as cogl_offscreen_new_to_texture() or
+ * functions, such as cogl_offscreen_new_with_texture() or
* cogl_onscreen_new(). The #CoglFramebuffer interface deals with
* all aspects that are common between those two types of framebuffer.
*
@@ -795,7 +795,7 @@ cogl_framebuffer_set_color_mask (CoglFramebuffer *framebuffer,
*
* Queries the common #CoglPixelFormat of all color buffers attached
* to this framebuffer. For an offscreen framebuffer created with
- * cogl_offscreen_new_to_texture() this will correspond to the format
+ * cogl_offscreen_new_with_texture() this will correspond to the format
* of the texture.
*
* Since: 1.8
diff --git a/cogl/cogl-gles2-context.c b/cogl/cogl-gles2-context.c
index ade85700..43fa12d6 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -330,7 +330,7 @@ copy_flipped_texture (CoglGLES2Context *gles2_ctx,
CoglPipeline *pipeline = cogl_pipeline_new (ctx);
const CoglOffscreenFlags flags = COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL;
CoglOffscreen *offscreen =
- _cogl_offscreen_new_to_texture_full (COGL_TEXTURE (dst_texture),
+ _cogl_offscreen_new_with_texture_full (COGL_TEXTURE (dst_texture),
flags, level);
int src_width = cogl_texture_get_width (src_texture);
int src_height = cogl_texture_get_height (src_texture);
diff --git a/cogl/cogl-offscreen.h b/cogl/cogl-offscreen.h
index a97d9d7d..4449ad68 100644
--- a/cogl/cogl-offscreen.h
+++ b/cogl/cogl-offscreen.h
@@ -48,6 +48,41 @@ typedef struct _CoglOffscreen CoglOffscreen;
/* Offscreen api */
/**
+ * cogl_offscreen_new_with_texture:
+ * @texture: A #CoglTexture pointer
+ *
+ * This creates an offscreen framebuffer object using the given
+ * @texture as the primary color buffer. It doesn't just initialize
+ * the contents of the offscreen buffer with the @texture; they are
+ * tightly bound so that drawing to the offscreen buffer effectively
+ * updates the contents of the given texture. You don't need to
+ * destroy the offscreen buffer before you can use the @texture again.
+ *
+ * <note>This api only works with low-level #CoglTexture types such as
+ * #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not
+ * with meta-texture types such as #CoglTexture2DSliced.</note>
+ *
+ * The storage for the framebuffer is actually allocated lazily
+ * so this function will never return %NULL to indicate a runtime
+ * error. This means it is still possible to configure the framebuffer
+ * before it is really allocated.
+ *
+ * Simple applications without full error handling can simply rely on
+ * Cogl to lazily allocate the storage of framebuffers but you should
+ * be aware that if Cogl encounters an error (such as running out of
+ * GPU memory) then your application will simply abort with an error
+ * message. If you need to be able to catch such exceptions at runtime
+ * then you can explicitly allocate your framebuffer when you have
+ * finished configuring it by calling cogl_framebuffer_allocate() and
+ * passing in a #CoglError argument to catch any exceptions.
+ *
+ * Return value: (transfer full): a newly instantiated #CoglOffscreen
+ * framebuffer.
+ */
+CoglOffscreen *
+cogl_offscreen_new_with_texture (CoglTexture *texture);
+
+/**
* cogl_offscreen_new_to_texture:
* @texture: A #CoglTexture pointer
*
@@ -65,9 +100,11 @@ typedef struct _CoglOffscreen CoglOffscreen;
* Return value: (transfer full): a newly instantiated #CoglOffscreen
* framebuffer or %NULL if it wasn't possible to create the
* buffer.
+ * Deprecated: 1.16: Use cogl_offscreen_new_with_texture instead.
*/
CoglOffscreen *
-cogl_offscreen_new_to_texture (CoglTexture *texture);
+cogl_offscreen_new_to_texture (CoglTexture *texture)
+ COGL_DEPRECATED_IN_1_16_FOR (cogl_offscreen_new_with_texture);
/**
* cogl_is_offscreen:
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index a616891c..bb074dcc 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -854,7 +854,7 @@ get_texture_bits_via_offscreen (CoglTexture *texture,
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
return FALSE;
- offscreen = _cogl_offscreen_new_to_texture_full
+ offscreen = _cogl_offscreen_new_with_texture_full
(texture,
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,
0);
diff --git a/cogl/cogl.symbols b/cogl/cogl.symbols
index 0766c317..8d1bdbea 100644
--- a/cogl/cogl.symbols
+++ b/cogl/cogl.symbols
@@ -513,7 +513,7 @@ cogl_object_ref
cogl_object_set_user_data
cogl_object_unref
-cogl_offscreen_new_to_texture
+cogl_offscreen_new_with_texture
cogl_onscreen_add_frame_callback
cogl_onscreen_add_resize_handler
diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index 6b2dfecc..385a97a7 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
@@ -650,7 +650,7 @@ CoglOffscreen
cogl_is_offscreen
<SUBSECTION>
-cogl_offscreen_new_to_texture
+cogl_offscreen_new_with_texture
</SECTION>
<SECTION>
diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt
index 60c0048a..bc19aa91 100644
--- a/doc/reference/cogl/cogl-sections.txt
+++ b/doc/reference/cogl/cogl-sections.txt
@@ -267,6 +267,7 @@ cogl_program_set_uniform_matrix
<SECTION>
<FILE>cogl-offscreen</FILE>
<TITLE>Offscreen Buffers</TITLE>
+cogl_offscreen_new_with_texture
cogl_offscreen_new_to_texture
cogl_is_offscreen
cogl_set_framebuffer
diff --git a/examples/cogl-gles2-context.c b/examples/cogl-gles2-context.c
index f696dcae..4f4fbfa9 100644
--- a/examples/cogl-gles2-context.c
+++ b/examples/cogl-gles2-context.c
@@ -100,7 +100,7 @@ main (int argc, char **argv)
OFFSCREEN_WIDTH,
OFFSCREEN_HEIGHT,
COGL_PIXEL_FORMAT_ANY));
- data.offscreen = cogl_offscreen_new_to_texture (data.offscreen_texture);
+ data.offscreen = cogl_offscreen_new_with_texture (data.offscreen_texture);
data.gles2_ctx = cogl_gles2_context_new (data.ctx, &error);
if (!data.gles2_ctx) {
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index b498c42c..70b1a3d3 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -65,7 +65,7 @@ main (int argc, char **argv)
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
320, 480,
COGL_PIXEL_FORMAT_ANY));
- offscreen = cogl_offscreen_new_to_texture (tex);
+ offscreen = cogl_offscreen_new_with_texture (tex);
offscreen_fb = COGL_FRAMEBUFFER (offscreen);
cogl_framebuffer_set_samples_per_pixel (offscreen_fb, 4);
if (!cogl_framebuffer_allocate (offscreen_fb, &error))
diff --git a/test-fixtures/test-utils.c b/test-fixtures/test-utils.c
index e085beb3..17492013 100644
--- a/test-fixtures/test-utils.c
+++ b/test-fixtures/test-utils.c
@@ -179,7 +179,7 @@ test_utils_init (TestFlags requirement_flags,
CoglTexture2D *tex = cogl_texture_2d_new_with_size (test_ctx,
FB_WIDTH, FB_HEIGHT,
COGL_PIXEL_FORMAT_ANY);
- offscreen = cogl_offscreen_new_to_texture (COGL_TEXTURE (tex));
+ offscreen = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex));
test_fb = COGL_FRAMEBUFFER (offscreen);
}
diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c
index 8dc3e573..e530e408 100644
--- a/tests/conform/test-backface-culling.c
+++ b/tests/conform/test-backface-culling.c
@@ -298,7 +298,7 @@ test_backface_culling (void)
TEST_UTILS_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY); /* internal
format */
- state.offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_to_texture (tex));
+ state.offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (tex));
state.offscreen_tex = tex;
paint (&state);
diff --git a/tests/conform/test-color-mask.c b/tests/conform/test-color-mask.c
index e4ae4bd9..5df6527a 100644
--- a/tests/conform/test-color-mask.c
+++ b/tests/conform/test-color-mask.c
@@ -87,7 +87,7 @@ test_color_mask (void)
state.fbo[i] = COGL_FRAMEBUFFER (
- cogl_offscreen_new_to_texture (state.tex[i]));
+ cogl_offscreen_new_with_texture (state.tex[i]));
/* Clear the texture color bits */
cogl_framebuffer_clear4f (state.fbo[i],
diff --git a/tests/conform/test-framebuffer-get-bits.c b/tests/conform/test-framebuffer-get-bits.c
index ac7ab529..f1a85b28 100644
--- a/tests/conform/test-framebuffer-get-bits.c
+++ b/tests/conform/test-framebuffer-get-bits.c
@@ -10,14 +10,14 @@ test_framebuffer_get_bits (void)
16, 16, /* width/height */
COGL_PIXEL_FORMAT_A_8);
CoglOffscreen *offscreen_a =
- cogl_offscreen_new_to_texture (COGL_TEXTURE (tex_a));
+ cogl_offscreen_new_with_texture (COGL_TEXTURE (tex_a));
CoglFramebuffer *fb_a = COGL_FRAMEBUFFER (offscreen_a);
CoglTexture2D *tex_rgba =
cogl_texture_2d_new_with_size (test_ctx,
16, 16, /* width/height */
COGL_PIXEL_FORMAT_RGBA_8888);
CoglOffscreen *offscreen_rgba =
- cogl_offscreen_new_to_texture (COGL_TEXTURE (tex_rgba));
+ cogl_offscreen_new_with_texture (COGL_TEXTURE (tex_rgba));
CoglFramebuffer *fb_rgba = COGL_FRAMEBUFFER (offscreen_rgba);
cogl_framebuffer_allocate (fb_a, NULL);
diff --git a/tests/conform/test-gles2-context.c b/tests/conform/test-gles2-context.c
index d5040e98..6b171c0f 100644
--- a/tests/conform/test-gles2-context.c
+++ b/tests/conform/test-gles2-context.c
@@ -28,7 +28,7 @@ test_push_pop_single_context (void)
cogl_framebuffer_get_width (test_fb),
cogl_framebuffer_get_height (test_fb),
COGL_PIXEL_FORMAT_ANY));
- offscreen = cogl_offscreen_new_to_texture (offscreen_texture);
+ offscreen = cogl_offscreen_new_with_texture (offscreen_texture);
pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, offscreen_texture);
@@ -152,7 +152,7 @@ create_gles2_context (CoglTexture **offscreen_texture,
cogl_framebuffer_get_width (test_fb),
cogl_framebuffer_get_height (test_fb),
COGL_PIXEL_FORMAT_ANY));
- *offscreen = cogl_offscreen_new_to_texture (*offscreen_texture);
+ *offscreen = cogl_offscreen_new_with_texture (*offscreen_texture);
*pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (*pipeline, 0, *offscreen_texture);
diff --git a/tests/conform/test-offscreen.c b/tests/conform/test-offscreen.c
index e72ca607..cd1ae4ab 100644
--- a/tests/conform/test-offscreen.c
+++ b/tests/conform/test-offscreen.c
@@ -50,7 +50,7 @@ test_paint (TestState *state)
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
tex = COGL_TEXTURE (tex_2d);
- offscreen = cogl_offscreen_new_to_texture (tex);
+ offscreen = cogl_offscreen_new_with_texture (tex);
/* Set a scale and translate transform on the window framebuffer
* before switching to the offscreen framebuffer so we can verify it
@@ -131,7 +131,7 @@ test_flush (TestState *state)
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
tex = COGL_TEXTURE (tex_2d);
- offscreen = cogl_offscreen_new_to_texture (tex);
+ offscreen = cogl_offscreen_new_with_texture (tex);
cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
diff --git a/tests/conform/test-readpixels.c b/tests/conform/test-readpixels.c
index f543fb09..131b08b2 100644
--- a/tests/conform/test-readpixels.c
+++ b/tests/conform/test-readpixels.c
@@ -51,7 +51,7 @@ on_paint (ClutterActor *actor, void *state)
FRAMEBUFFER_WIDTH * 4, /* rowstride */
data);
g_free (data);
- offscreen = cogl_offscreen_new_to_texture (tex);
+ offscreen = cogl_offscreen_new_with_texture (tex);
cogl_push_framebuffer (offscreen);
diff --git a/tests/conform/test-viewport.c b/tests/conform/test-viewport.c
index c437ec7c..a1937c42 100644
--- a/tests/conform/test-viewport.c
+++ b/tests/conform/test-viewport.c
@@ -217,7 +217,7 @@ on_paint (ClutterActor *actor, void *state)
FRAMEBUFFER_WIDTH * 4, /* rowstride */
data);
g_free (data);
- offscreen = cogl_offscreen_new_to_texture (tex);
+ offscreen = cogl_offscreen_new_with_texture (tex);
cogl_push_framebuffer (offscreen);