[cogl] offscreen: Replace use of CoglHandle with CoglOffscreen
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] offscreen: Replace use of CoglHandle with CoglOffscreen
- Date: Tue, 21 Feb 2012 17:30:06 +0000 (UTC)
commit 13c36fff0d55fb20c3f71d7a1e95208d5b1d61f8
Author: Robert Bragg <robert linux intel com>
Date: Sat Feb 18 15:22:15 2012 +0000
offscreen: Replace use of CoglHandle with CoglOffscreen
This updates cogl_offscreen_new_to_texture to return a CoglOffscreen
pointer instead of a CoglHandle.
Reviewed-by: Neil Roberts <neil linux intel com>
cogl/cogl-framebuffer-private.h | 9 ++---
cogl/cogl-framebuffer.c | 4 +-
cogl/cogl-offscreen.h | 51 ++++++++++++++++++++-------------
cogl/cogl-texture.c | 7 +++-
tests/conform/test-backface-culling.c | 2 +-
tests/conform/test-color-mask.c | 3 +-
6 files changed, 45 insertions(+), 31 deletions(-)
---
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 137ba87..6685d31 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -30,6 +30,7 @@
#include "cogl-journal-private.h"
#include "cogl-winsys-private.h"
#include "cogl-attribute-private.h"
+#include "cogl-offscreen.h"
#ifdef COGL_HAS_XLIB_SUPPORT
#include <X11/Xlib.h>
@@ -154,7 +155,7 @@ struct _CoglFramebuffer
gboolean clear_clip_dirty;
};
-typedef struct _CoglOffscreen
+struct _CoglOffscreen
{
CoglFramebuffer _parent;
GLuint fbo_handle;
@@ -169,9 +170,7 @@ typedef struct _CoglOffscreen
* fb->config to configure if we want a depth or stencil buffer so
* we can get rid of these flags */
CoglOffscreenFlags create_flags;
-} CoglOffscreen;
-
-#define COGL_OFFSCREEN(X) ((CoglOffscreen *)(X))
+};
void
_cogl_framebuffer_init (CoglFramebuffer *framebuffer,
@@ -280,7 +279,7 @@ _cogl_free_framebuffer_stack (GSList *stack);
*
* Return value: the new CoglOffscreen object.
*/
-CoglHandle
+CoglOffscreen *
_cogl_offscreen_new_to_texture_full (CoglTexture *texture,
CoglOffscreenFlags create_flags,
unsigned int level);
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 8f72e97..5c7dbdb 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -704,7 +704,7 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
framebuffer->dirty_bitmasks = FALSE;
}
-CoglHandle
+CoglOffscreen *
_cogl_offscreen_new_to_texture_full (CoglTexture *texture,
CoglOffscreenFlags create_flags,
unsigned int level)
@@ -774,7 +774,7 @@ _cogl_offscreen_new_to_texture_full (CoglTexture *texture,
return ret;
}
-CoglHandle
+CoglOffscreen *
cogl_offscreen_new_to_texture (CoglTexture *texture)
{
return _cogl_offscreen_new_to_texture_full (texture, 0, 0);
diff --git a/cogl/cogl-offscreen.h b/cogl/cogl-offscreen.h
index cd77880..47298bd 100644
--- a/cogl/cogl-offscreen.h
+++ b/cogl/cogl-offscreen.h
@@ -3,7 +3,7 @@
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
- * Copyright (C) 2007,2008,2009 Intel Corporation.
+ * Copyright (C) 2007,2008,2009,2012 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -41,6 +41,10 @@ G_BEGIN_DECLS
* Cogl allows creating and operating on offscreen framebuffers.
*/
+typedef struct _CoglOffscreen CoglOffscreen;
+
+#define COGL_OFFSCREEN(X) ((CoglOffscreen *)X)
+
/* Offscreen api */
/**
@@ -54,50 +58,57 @@ G_BEGIN_DECLS
* given texture. You don't need to destroy the offscreen buffer before
* you can use the @texture again.
*
- * Note: This does not work with sliced Cogl textures.
+ * <note>This only works with low-level #CoglTexture types such as
+ * #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not
+ * with meta-texture types such as #CoglTexture2DSliced.</note>
*
- * Return value: (transfer full): a #CoglHandle for the new offscreen
- * buffer or %COGL_INVALID_HANDLE if it wasn't possible to create the
+ * Return value: (transfer full): a newly instantiated #CoglOffscreen
+ * framebuffer or %NULL if it wasn't possible to create the
* buffer.
*/
-CoglHandle cogl_offscreen_new_to_texture (CoglTexture *texture);
+CoglOffscreen *
+cogl_offscreen_new_to_texture (CoglTexture *texture);
/**
* cogl_is_offscreen:
- * @handle: A CoglHandle for an offscreen buffer
+ * @object: A pointer to a #CoglObject
*
- * Determines whether the given #CoglHandle references an offscreen buffer
- * object.
+ * Determines whether the given #CoglObject references an offscreen
+ * framebuffer object.
*
- * Returns: %TRUE if the handle references an offscreen buffer,
- * %FALSE otherwise
+ * Returns: %TRUE if @object is a #CoglOffscreen framebuffer,
+ * %FALSE otherwise
*/
-gboolean cogl_is_offscreen (CoglHandle handle);
+gboolean
+cogl_is_offscreen (void *object);
#ifndef COGL_DISABLE_DEPRECATED
/**
* cogl_offscreen_ref:
- * @handle: A CoglHandle for an offscreen buffer
+ * @offscreen: A pointer to a #CoglOffscreen framebuffer
*
- * Increments the reference count on the offscreen buffer.
+ * Increments the reference count on the @offscreen framebuffer.
*
- * Return value: (transfer none): For convenience it returns the given CoglHandle
+ * Return value: (transfer none): For convenience it returns the
+ * given @offscreen
*
- * Deprecated: 1.2: cogl_handle_ref() should be used in new code.
+ * Deprecated: 1.2: cogl_object_ref() should be used in new code.
*/
-CoglHandle cogl_offscreen_ref (CoglHandle handle) G_GNUC_DEPRECATED;
+void *
+cogl_offscreen_ref (void *offscreen) G_GNUC_DEPRECATED;
/**
* cogl_offscreen_unref:
- * @handle: A CoglHandle for an offscreen buffer
+ * @offscreen: A pointer to a #CoglOffscreen framebuffer
*
- * Decreases the reference count for the offscreen buffer and frees it when
+ * Decreases the reference count for the @offscreen buffer and frees it when
* the count reaches 0.
*
- * Deprecated: 1.2: cogl_handle_unref() should be used in new code.
+ * Deprecated: 1.2: cogl_object_unref() should be used in new code.
*/
-void cogl_offscreen_unref (CoglHandle handle) G_GNUC_DEPRECATED;
+void
+cogl_offscreen_unref (void *offscreen) G_GNUC_DEPRECATED;
#endif /* COGL_DISABLE_DEPRECATED */
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index c50e732..b68fa81 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -1019,6 +1019,7 @@ get_texture_bits_via_offscreen (CoglTexture *texture,
unsigned int dst_rowstride,
CoglPixelFormat dst_format)
{
+ CoglOffscreen *offscreen;
CoglFramebuffer *framebuffer;
_COGL_GET_CONTEXT (ctx, FALSE);
@@ -1026,14 +1027,16 @@ get_texture_bits_via_offscreen (CoglTexture *texture,
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
return FALSE;
- framebuffer = _cogl_offscreen_new_to_texture_full
+ offscreen = _cogl_offscreen_new_to_texture_full
(texture,
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,
0);
- if (framebuffer == NULL)
+ if (offscreen == NULL)
return FALSE;
+ framebuffer = COGL_FRAMEBUFFER (offscreen);
+
if (!cogl_framebuffer_allocate (framebuffer, NULL))
{
cogl_object_unref (framebuffer);
diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c
index fc7caa4..dacc305 100644
--- a/tests/conform/test-backface-culling.c
+++ b/tests/conform/test-backface-culling.c
@@ -296,7 +296,7 @@ test_cogl_backface_culling (TestUtilsGTestFixture *fixture,
tex = cogl_texture_new_with_size (state.width, state.height,
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY); /* internal fmt */
- state.offscreen = cogl_offscreen_new_to_texture (tex);
+ state.offscreen = COGL_FRAMEBUFFER (cogl_offscreen_new_to_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 75c8a05..deb9cdd 100644
--- a/tests/conform/test-color-mask.c
+++ b/tests/conform/test-color-mask.c
@@ -87,7 +87,8 @@ test_cogl_color_mask (TestUtilsGTestFixture *fixture,
COGL_PIXEL_FORMAT_RGB_888);
- state.fbo[i] = cogl_offscreen_new_to_texture (state.tex[i]);
+ state.fbo[i] = COGL_FRAMEBUFFER (
+ cogl_offscreen_new_to_texture (state.tex[i]));
/* Clear the texture color bits */
cogl_push_framebuffer (state.fbo[i]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]