[cogl/cogl-1.18] framebuffer: make format internal
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/cogl-1.18] framebuffer: make format internal
- Date: Thu, 9 Jan 2014 16:00:33 +0000 (UTC)
commit 2e6131891455a624678f878d55927721c7860af7
Author: Robert Bragg <robert linux intel com>
Date: Wed Jun 26 21:26:40 2013 +0100
framebuffer: make format internal
This removes cogl_framebuffer_get_color_format() since the actual
internal format isn't strictly controlled by us. CoglFramebuffer::format
has been renamed to ::internal_format to make it clearer that it only
really represents the premultiplication status.
The plan is to make most of the work involved in creating a texture
happen lazily when allocating so this patch also changes
_cogl_framebuffer_init() to not take a format argument anymore since we
won't know the format of offscreen framebuffers until the framebuffer is
allocated, after the corresponding texture has been allocated. In the
case of offscreen framebuffers we now update the framebuffer
internal_format during allocation.
Reviewed-by: Neil Roberts <neil linux intel com>
(cherry picked from commit 8cc9e1c8bd2fac8b2a95087249c23c952d5e379f)
Note: Since we can't break API compatibility on the 1.x branch this
actually keeps the cogl_framebuffer_get_color_format() api but moves it
into a new deprecated/cogl-framebuffer-deprecated.c file and it now
returns the newly name ::internal_format.
cogl/Makefile.am | 2 +
cogl/cogl-framebuffer-private.h | 3 +-
cogl/cogl-framebuffer.c | 17 +++----
cogl/cogl-framebuffer.h | 15 -----
cogl/cogl-onscreen.c | 2 -
cogl/cogl.h | 1 +
cogl/deprecated/cogl-framebuffer-deprecated.c | 36 +++++++++++++
cogl/deprecated/cogl-framebuffer-deprecated.h | 55 ++++++++++++++++++++
cogl/driver/gl/cogl-framebuffer-gl.c | 6 +-
.../cogl-2.0-experimental-sections.txt | 1 -
10 files changed, 105 insertions(+), 33 deletions(-)
---
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index b428180..337d59d 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -76,6 +76,7 @@ cogl_deprecated_h = \
$(srcdir)/deprecated/cogl-shader.h \
$(srcdir)/deprecated/cogl-clutter.h \
$(srcdir)/deprecated/cogl-type-casts.h \
+ $(srcdir)/deprecated/cogl-framebuffer-deprecated.h \
$(NULL)
# public 1.x api headers
@@ -401,6 +402,7 @@ cogl_sources_c = \
$(srcdir)/deprecated/cogl-shader-private.h \
$(srcdir)/deprecated/cogl-shader.c \
$(srcdir)/deprecated/cogl-clutter.c \
+ $(srcdir)/deprecated/cogl-framebuffer-deprecated.c \
$(NULL)
if USE_GLIB
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index f7386e1..6d8b05b 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -130,7 +130,7 @@ struct _CoglFramebuffer
int height;
/* Format of the pixels in the framebuffer (including the expected
premult state) */
- CoglPixelFormat format;
+ CoglPixelFormat internal_format;
CoglBool allocated;
CoglMatrixStack *modelview_stack;
@@ -222,7 +222,6 @@ void
_cogl_framebuffer_init (CoglFramebuffer *framebuffer,
CoglContext *ctx,
CoglFramebufferType type,
- CoglPixelFormat format,
int width,
int height);
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 1e29bff..cf9b20d 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -97,7 +97,6 @@ void
_cogl_framebuffer_init (CoglFramebuffer *framebuffer,
CoglContext *ctx,
CoglFramebufferType type,
- CoglPixelFormat format,
int width,
int height)
{
@@ -106,7 +105,7 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
framebuffer->type = type;
framebuffer->width = width;
framebuffer->height = height;
- framebuffer->format = format;
+ framebuffer->internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
framebuffer->viewport_x = 0;
framebuffer->viewport_y = 0;
framebuffer->viewport_width = width;
@@ -638,7 +637,6 @@ _cogl_offscreen_new_with_texture_full (CoglTexture *texture,
_cogl_framebuffer_init (fb,
ctx,
COGL_FRAMEBUFFER_TYPE_OFFSCREEN,
- cogl_texture_get_format (texture),
level_width,
level_height);
@@ -748,6 +746,11 @@ cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
if (!cogl_texture_allocate (offscreen->texture, error))
return FALSE;
+ /* Forward the texture format as the internal format of the
+ * framebuffer */
+ framebuffer->internal_format =
+ cogl_texture_get_format (offscreen->texture);
+
if (!ctx->driver_vtable->offscreen_allocate (offscreen, error))
return FALSE;
}
@@ -1312,12 +1315,6 @@ cogl_framebuffer_set_dither_enabled (CoglFramebuffer *framebuffer,
COGL_FRAMEBUFFER_STATE_DITHER;
}
-CoglPixelFormat
-cogl_framebuffer_get_color_format (CoglFramebuffer *framebuffer)
-{
- return framebuffer->format;
-}
-
void
cogl_framebuffer_set_depth_texture_enabled (CoglFramebuffer *framebuffer,
CoglBool enabled)
@@ -1617,7 +1614,7 @@ _cogl_blit_framebuffer (CoglFramebuffer *src,
_COGL_RETURN_IF_FAIL (cogl_is_offscreen (src));
_COGL_RETURN_IF_FAIL (cogl_is_offscreen (dest));
/* The buffers must be the same format */
- _COGL_RETURN_IF_FAIL (src->format == dest->format);
+ _COGL_RETURN_IF_FAIL (src->internal_format == dest->internal_format);
/* Make sure the current framebuffers are bound. We explicitly avoid
flushing the clip state so we can bind our own empty state */
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index e802ba5..f2a96c9 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -829,21 +829,6 @@ cogl_framebuffer_set_color_mask (CoglFramebuffer *framebuffer,
CoglColorMask color_mask);
/**
- * cogl_framebuffer_get_color_format:
- * @framebuffer: A #CoglFramebuffer framebuffer
- *
- * Queries the common #CoglPixelFormat of all color buffers attached
- * to this framebuffer. For an offscreen framebuffer created with
- * cogl_offscreen_new_with_texture() this will correspond to the format
- * of the texture.
- *
- * Since: 1.8
- * Stability: unstable
- */
-CoglPixelFormat
-cogl_framebuffer_get_color_format (CoglFramebuffer *framebuffer);
-
-/**
* cogl_framebuffer_set_depth_texture_enabled:
* @framebuffer: A #CoglFramebuffer
* @enabled: TRUE or FALSE
diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c
index cffbe33..637cb30 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -69,7 +69,6 @@ _cogl_onscreen_new (void)
_cogl_framebuffer_init (COGL_FRAMEBUFFER (onscreen),
ctx,
COGL_FRAMEBUFFER_TYPE_ONSCREEN,
- COGL_PIXEL_FORMAT_RGBA_8888_PRE,
0x1eadbeef, /* width */
0x1eadbeef); /* height */
/* NB: make sure to pass positive width/height numbers here
@@ -104,7 +103,6 @@ cogl_onscreen_new (CoglContext *ctx, int width, int height)
_cogl_framebuffer_init (COGL_FRAMEBUFFER (onscreen),
ctx,
COGL_FRAMEBUFFER_TYPE_ONSCREEN,
- COGL_PIXEL_FORMAT_RGBA_8888_PRE,
width, /* width */
height); /* height */
diff --git a/cogl/cogl.h b/cogl/cogl.h
index 6299b91..b316cd1 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -79,6 +79,7 @@
#include <cogl/deprecated/cogl-fixed.h>
#include <cogl/deprecated/cogl-material-compat.h>
#include <cogl/deprecated/cogl-shader.h>
+#include <cogl/deprecated/cogl-framebuffer-deprecated.h>
#endif
/* It would be good to move these casts up into 1.x only api if we can
diff --git a/cogl/deprecated/cogl-framebuffer-deprecated.c b/cogl/deprecated/cogl-framebuffer-deprecated.c
new file mode 100644
index 0000000..dc099d9
--- /dev/null
+++ b/cogl/deprecated/cogl-framebuffer-deprecated.c
@@ -0,0 +1,36 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2014 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/>.
+ *
+ *
+ */
+
+#include <config.h>
+
+#include "cogl-types.h"
+#include "cogl-framebuffer-private.h"
+#include "cogl-framebuffer-deprecated.h"
+
+CoglPixelFormat
+cogl_framebuffer_get_color_format (CoglFramebuffer *framebuffer)
+{
+ return framebuffer->internal_format;
+}
+
diff --git a/cogl/deprecated/cogl-framebuffer-deprecated.h b/cogl/deprecated/cogl-framebuffer-deprecated.h
new file mode 100644
index 0000000..92962bd
--- /dev/null
+++ b/cogl/deprecated/cogl-framebuffer-deprecated.h
@@ -0,0 +1,55 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2014 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/>.
+ *
+ *
+ */
+
+#ifndef __COGL_FRAMEBUFFER_DEPRECATED_H__
+#define __COGL_FRAMEBUFFER_DEPRECATED_H__
+
+#include <cogl/cogl-macros.h>
+
+/* XXX: Since this api was marked unstable, maybe we can just
+ * remove this api if we can't find anyone is using it. */
+/**
+ * cogl_framebuffer_get_color_format:
+ * @framebuffer: A #CoglFramebuffer framebuffer
+ *
+ * Queries the common #CoglPixelFormat of all color buffers attached
+ * to this framebuffer. For an offscreen framebuffer created with
+ * cogl_offscreen_new_with_texture() this will correspond to the format
+ * of the texture.
+ *
+ * This API is deprecated because it is missleading to report a
+ * #CoglPixelFormat for the internal format of the @framebuffer since
+ * #CoglPixelFormat is such a precise format description and it's
+ * only the set of components and the premultiplied alpha status
+ * that is really known.
+ *
+ * Since: 1.8
+ * Stability: unstable
+ * Deprecated 1.18: Removed since it is misleading
+ */
+COGL_DEPRECATED_IN_1_18
+CoglPixelFormat
+cogl_framebuffer_get_color_format (CoglFramebuffer *framebuffer);
+
+#endif /* __COGL_FRAMEBUFFER_DEPRECATED_H__ */
diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index 68ac661..23d851f 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -1004,7 +1004,7 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
* stored in the red component */
if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_ALPHA_TEXTURES) &&
framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN &&
- framebuffer->format == COGL_PIXEL_FORMAT_A_8)
+ framebuffer->internal_format == COGL_PIXEL_FORMAT_A_8)
{
framebuffer->bits.alpha = framebuffer->bits.red;
framebuffer->bits.red = 0;
@@ -1375,7 +1375,7 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (read_format))
read_format = ((read_format & ~COGL_PREMULT_BIT) |
- (framebuffer->format & COGL_PREMULT_BIT));
+ (framebuffer->internal_format & COGL_PREMULT_BIT));
tmp_bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
width, height,
@@ -1429,7 +1429,7 @@ _cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
* converted to the right format below */
if (COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT (format))
bmp_format = ((format & ~COGL_PREMULT_BIT) |
- (framebuffer->format & COGL_PREMULT_BIT));
+ (framebuffer->internal_format & COGL_PREMULT_BIT));
else
bmp_format = format;
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 385a97a..1f757fe 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
@@ -521,7 +521,6 @@ cogl_framebuffer_get_viewport_y
cogl_framebuffer_get_viewport_width
cogl_framebuffer_get_viewport_height
cogl_framebuffer_get_viewport4fv
-cogl_framebuffer_get_color_format
cogl_framebuffer_get_red_bits
cogl_framebuffer_get_green_bits
cogl_framebuffer_get_blue_bits
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]