[cogl/wip/pixel-format-2101010: 5/5] Detect RGB_565 format from masks
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/pixel-format-2101010: 5/5] Detect RGB_565 format from masks
- Date: Sat, 11 Feb 2012 18:55:09 +0000 (UTC)
commit 2f8940bded1087d1fd45dbf46a91afb0142311e1
Author: Robert Bragg <robert linux intel com>
Date: Sat Feb 11 18:43:24 2012 +0000
Detect RGB_565 format from masks
This enables us to detect the RGB_565 format from component masks so it
should work to use texture-from-pixmap extensions with 565 X visuals.
cogl/cogl-util.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-util.c b/cogl/cogl-util.c
index 4368930..26c1778 100644
--- a/cogl/cogl-util.c
+++ b/cogl/cogl-util.c
@@ -131,6 +131,9 @@ _cogl_util_pixel_format_from_masks (unsigned long r_mask,
{
#define MASK_FMT_888(a, b, c) ((a) == 0xff0000 && (b) == 0xff00 && (c) == 0xff)
#define MASK_FMT_101010(a, b, c) ((a) == 0x3ff00000 && (b) == 0xffc00 && (c) == 0x3ff)
+#define MASK_FMT_565(a, b, c) ((a) == (0x1f << 11) && \
+ (b) == (0x3f << 5) && \
+ (c) == 0x1f)
CoglPixelFormat image_format;
@@ -139,6 +142,8 @@ _cogl_util_pixel_format_from_masks (unsigned long r_mask,
image_format = COGL_PIXEL_FORMAT_RGB_888;
else if ((depth == 30 || depth == 32) && MASK_FMT_101010(b_mask, g_mask, r_mask))
image_format = COGL_PIXEL_FORMAT_BGR_101010;
+ else if (depth == 16 && MASK_FMT_565 (r_mask, g_mask, b_mask))
+ return COGL_PIXEL_FORMAT_RGB_565;
else
{
g_warning ("Could not find a matching pixel format for red mask=0x%lx," \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]