diff --git a/cogl/Makefile.am b/cogl/Makefile.am index b42818086..337d59dc7 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 f7386e11d..6d8b05bf9 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 1e29bffe3..cf9b20d05 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 e802ba52e..f2a96c93b 100644 --- a/cogl/cogl-framebuffer.h +++ b/cogl/cogl-framebuffer.h @@ -828,21 +828,6 @@ void 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 diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c index cffbe3371..637cb303b 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 6299b9114..b316cd126 100644 --- a/cogl/cogl.h +++ b/cogl/cogl.h @@ -79,6 +79,7 @@ #include #include #include +#include #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 000000000..dc099d97d --- /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 + * . + * + * + */ + +#include + +#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 000000000..92962bd33 --- /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 + * . + * + * + */ + +#ifndef __COGL_FRAMEBUFFER_DEPRECATED_H__ +#define __COGL_FRAMEBUFFER_DEPRECATED_H__ + +#include + +/* 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 68ac66158..23d851f07 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 385a97a7f..1f757fe51 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