summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2013-06-26 21:26:40 +0100
committerRobert Bragg <robert@linux.intel.com>2013-11-29 23:18:07 +0000
commitf9ff28a068b362d12fe3123b62f6ece48e8bc9f8 (patch)
tree67fbaf736794a80ad04b11ba26a2b5a15088a117
parentf2072ab07566461b849f60e4e347171fcc9a9877 (diff)
downloadcogl-f9ff28a068b362d12fe3123b62f6ece48e8bc9f8.tar.gz
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.
-rw-r--r--cogl/cogl-framebuffer-private.h3
-rw-r--r--cogl/cogl-framebuffer.c17
-rw-r--r--cogl/cogl-onscreen.c1
-rw-r--r--cogl/driver/gl/cogl-framebuffer-gl.c6
-rw-r--r--doc/reference/cogl2/cogl2-sections.txt1
5 files changed, 11 insertions, 17 deletions
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 94bc6d24..51c91c53 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 2be598ae..626e8b36 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;
@@ -602,7 +601,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);
@@ -695,6 +693,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;
}
@@ -1017,12 +1020,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)
@@ -1305,7 +1302,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 f97af94f..447a4b6d 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 b88ed343..77e72f3e 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -1005,7 +1005,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;
@@ -1376,7 +1376,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,
@@ -1430,7 +1430,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 b706c165..f40bc74e 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