[cogl] framebuffer: make format internal
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] framebuffer: make format internal
- Date: Wed, 1 Jan 2014 17:48:24 +0000 (UTC)
commit 8cc9e1c8bd2fac8b2a95087249c23c952d5e379f
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_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>
cogl/cogl-framebuffer-private.h | 3 +--
cogl/cogl-framebuffer.c | 17 +++++++----------
cogl/cogl-onscreen.c | 1 -
cogl/driver/gl/cogl-framebuffer-gl.c | 6 +++---
doc/reference/cogl2/cogl2-sections.txt | 1 -
5 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 58e95b8..3b91771 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 4753b1a..9ce2725 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -89,7 +89,6 @@ void
_cogl_framebuffer_init (CoglFramebuffer *framebuffer,
CoglContext *ctx,
CoglFramebufferType type,
- CoglPixelFormat format,
int width,
int height)
{
@@ -98,7 +97,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;
@@ -599,7 +598,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);
@@ -692,6 +690,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;
}
@@ -1011,12 +1014,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)
@@ -1299,7 +1296,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-onscreen.c b/cogl/cogl-onscreen.c
index f97af94..447a4b6 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -74,7 +74,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/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index ff68ed9..d1904a0 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/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index b706c16..f40bc74 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -461,7 +461,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]