summaryrefslogtreecommitdiff
path: root/cogl/cogl-bitmap-packing.h
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2014-01-14 15:52:45 +0000
committerNeil Roberts <neil@linux.intel.com>2014-01-20 14:40:45 +0000
commiteb7ef457cb281d5ed75863a269da2a94c427bd7b (patch)
tree015044b69d5a42491b78441b92469b8763849807 /cogl/cogl-bitmap-packing.h
parent06c75ea2e7cdbf9631478620bad469548ace6baa (diff)
downloadcogl-eb7ef457cb281d5ed75863a269da2a94c427bd7b.tar.gz
Add support for RG textures
This adds COGL_PIXEL_FORMAT_RG_88 and COGL_TEXTURE_COMPONENTS_RG in order to support two-component textures. The RG components for a texture is only supported if COGL_FEATURE_ID_TEXTURE_RG is advertised. This is only available on GL 3, GL 2 with the GL_ARB_texture_rg extension or GLES with the GL_EXT_texture_rg extension. The RG pixel format is always supported for images because Cogl can easily do the conversion if an application uses this format to upload to a texture with a different format. If an application tries to create an RG texture when the feature isn't supported then it will raise an error when the texture is allocated. https://bugzilla.gnome.org/show_bug.cgi?id=712830 Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 568677ab3bcb62ababad1623be0d6b9b117d0a26) Conflicts: cogl/cogl-bitmap-packing.h cogl/cogl-types.h cogl/driver/gl/gl/cogl-driver-gl.c tests/conform/test-read-texture-formats.c tests/conform/test-write-texture-formats.c
Diffstat (limited to 'cogl/cogl-bitmap-packing.h')
-rw-r--r--cogl/cogl-bitmap-packing.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/cogl/cogl-bitmap-packing.h b/cogl/cogl-bitmap-packing.h
index e631c17f..e2bc8a10 100644
--- a/cogl/cogl-bitmap-packing.h
+++ b/cogl/cogl-bitmap-packing.h
@@ -79,6 +79,22 @@ G_PASTE (_cogl_unpack_g_8_, component_size) (const uint8_t *src,
}
inline static void
+G_PASTE (_cogl_unpack_rg_88_, component_size) (const uint8_t *src,
+ component_type *dst,
+ int width)
+{
+ while (width-- > 0)
+ {
+ dst[0] = UNPACK_BYTE (src[0]);
+ dst[1] = UNPACK_BYTE (src[1]);
+ dst[2] = 0;
+ dst[3] = UNPACK_BYTE (255);
+ dst += 4;
+ src += 2;
+ }
+}
+
+inline static void
G_PASTE (_cogl_unpack_rgb_888_, component_size) (const uint8_t *src,
component_type *dst,
int width)
@@ -321,6 +337,9 @@ G_PASTE (_cogl_unpack_, component_size) (CoglPixelFormat format,
case COGL_PIXEL_FORMAT_G_8:
G_PASTE (_cogl_unpack_g_8_, component_size) (src, dst, width);
break;
+ case COGL_PIXEL_FORMAT_RG_88:
+ G_PASTE (_cogl_unpack_rg_88_, component_size) (src, dst, width);
+ break;
case COGL_PIXEL_FORMAT_RGB_888:
G_PASTE (_cogl_unpack_rgb_888_, component_size) (src, dst, width);
break;
@@ -425,6 +444,20 @@ G_PASTE (_cogl_pack_g_8_, component_size) (const component_type *src,
}
inline static void
+G_PASTE (_cogl_pack_rg_88_, component_size) (const component_type *src,
+ uint8_t *dst,
+ int width)
+{
+ while (width-- > 0)
+ {
+ dst[0] = PACK_BYTE (src[0]);
+ dst[1] = PACK_BYTE (src[1]);
+ src += 4;
+ dst += 2;
+ }
+}
+
+inline static void
G_PASTE (_cogl_pack_rgb_888_, component_size) (const component_type *src,
uint8_t *dst,
int width)
@@ -665,6 +698,9 @@ G_PASTE (_cogl_pack_, component_size) (CoglPixelFormat format,
case COGL_PIXEL_FORMAT_G_8:
G_PASTE (_cogl_pack_g_8_, component_size) (src, dst, width);
break;
+ case COGL_PIXEL_FORMAT_RG_88:
+ G_PASTE (_cogl_pack_rg_88_, component_size) (src, dst, width);
+ break;
case COGL_PIXEL_FORMAT_RGB_888:
G_PASTE (_cogl_pack_rgb_888_, component_size) (src, dst, width);
break;