diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c
index ea457b958..fffd9ede6 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 a220de9cf..233f1c521 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 fbd3dd6d7..8487578b1 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 b83d27969..554cc50bf 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 ade857007..43fa12d6d 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 a97d9d7db..4449ad68f 100644
--- a/cogl/cogl-offscreen.h
+++ b/cogl/cogl-offscreen.h
@@ -47,6 +47,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.
+ *
+ * This api only works with low-level #CoglTexture types such as
+ * #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not
+ * with meta-texture types such as #CoglTexture2DSliced.
+ *
+ * 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 a616891c3..bb074dcce 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 0766c3170..8d1bdbea8 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 6b2dfeccf..385a97a7f 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
-cogl_offscreen_new_to_texture
+cogl_offscreen_new_with_texture
diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt
index 60c0048a4..bc19aa91c 100644
--- a/doc/reference/cogl/cogl-sections.txt
+++ b/doc/reference/cogl/cogl-sections.txt
@@ -267,6 +267,7 @@ cogl_program_set_uniform_matrix
cogl-offscreen
Offscreen Buffers
+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 f696dcae1..4f4fbfa93 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 b498c42cc..70b1a3d37 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 e085beb36..174920137 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 8dc3e5736..e530e408c 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 e4ae4bd99..5df6527ae 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 ac7ab5290..f1a85b281 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 d5040e988..6b171c0f1 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 e72ca607f..cd1ae4ab5 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 f543fb09f..131b08b23 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 c437ec7c0..a1937c42a 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);