summaryrefslogtreecommitdiff
path: root/cogl/cogl.c
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2012-02-13 23:02:04 +0000
committerRobert Bragg <robert@linux.intel.com>2012-02-20 23:12:44 +0000
commitfbec2a5ad74e42ec4290e691b9d7653d30686c4e (patch)
treea0c6a605f143332a84020adfaf03d0507a8774d9 /cogl/cogl.c
parente376058533d527e37df323488e014b1308105728 (diff)
downloadcogl-fbec2a5ad74e42ec4290e691b9d7653d30686c4e.tar.gz
moves and renames _cogl_get_format_bpp
This moves _cogl_get_format_bpp from cogl-bitmap.c to cogl.c and renames it to _cogl_pixel_format_get_bytes_per_pixel. This makes it clearer that it doesn't return bits per pixel and makes the naming consistent with other cogl api. The prototype has been moved to cogl-private.h since it seems we should be aiming to get rid of cogl-internal.h at some point. The patch also adds a simple gtk-doc comment since we might want to make this api public. Reviewed-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'cogl/cogl.c')
-rw-r--r--cogl/cogl.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/cogl/cogl.c b/cogl/cogl.c
index 8ed44592..d22a91fa 100644
--- a/cogl/cogl.c
+++ b/cogl/cogl.c
@@ -436,7 +436,7 @@ _cogl_read_pixels_with_rowstride (int x,
y = framebuffer_height - y - height;
/* Initialise the CoglBitmap */
- bpp = _cogl_get_format_bpp (format);
+ bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
bmp_format = format;
if ((format & COGL_A_BIT))
@@ -574,10 +574,11 @@ cogl_read_pixels (int x,
CoglPixelFormat format,
guint8 *pixels)
{
+ int bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
_cogl_read_pixels_with_rowstride (x, y, width, height,
source, format, pixels,
/* rowstride */
- _cogl_get_format_bpp (format) * width);
+ bpp * width);
}
void
@@ -1005,3 +1006,21 @@ _cogl_init (void)
g_once_init_leave (&init_status, 1);
}
}
+
+int
+_cogl_pixel_format_get_bytes_per_pixel (CoglPixelFormat format)
+{
+ int bpp_lut[] = {
+ 0, /* invalid */
+ 1, /* A_8 */
+ 3, /* 888 */
+ 4, /* 8888 */
+ 2, /* 565 */
+ 2, /* 4444 */
+ 2, /* 5551 */
+ 2, /* YUV */
+ 1 /* G_8 */
+ };
+
+ return bpp_lut [format & 0xf];
+}