summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-11-27 20:07:47 +0000
committerNeil Roberts <neil@linux.intel.com>2012-11-28 11:16:57 +0000
commit888733d3c3b24080d2f136cedb3876a41312e4cf (patch)
tree98df77d74a46acfd891e1eab32cbb40181ff8c9d
parent8beb3a4cc20f539a50645166485b95e8e5b25779 (diff)
downloadcogl-888733d3c3b24080d2f136cedb3876a41312e4cf.tar.gz
Fix handling of binding errors when uploading a full texture
Both the texture drivers weren't handling errors correctly when a CoglPixelBuffer was used to set the contents of an entire texture. This was causing it to hit an assertion failure in the pixel buffer tests. Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r--cogl/driver/gl/gl/cogl-texture-driver-gl.c17
-rw-r--r--cogl/driver/gl/gles/cogl-texture-driver-gles.c13
-rw-r--r--tests/conform/test-conform-main.c4
-rw-r--r--tests/conform/test-pixel-buffer.c7
4 files changed, 31 insertions, 10 deletions
diff --git a/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
index 4941549c..fffa6262 100644
--- a/cogl/driver/gl/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
@@ -306,10 +306,21 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
GLenum gl_error;
CoglBool status = TRUE;
+ CoglError *internal_error = NULL;
- data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0, error);
- if (!data)
- return FALSE;
+ data = _cogl_bitmap_gl_bind (source_bmp,
+ COGL_BUFFER_ACCESS_READ,
+ 0, /* hints */
+ &internal_error);
+
+ /* NB: _cogl_bitmap_gl_bind() may return NULL when successful so we
+ * have to explicitly check the cogl error pointer to catch
+ * problems... */
+ if (internal_error)
+ {
+ _cogl_propagate_error (error, internal_error);
+ return FALSE;
+ }
/* Setup gl alignment to match rowstride and top-left corner */
prep_gl_for_pixels_upload_full (ctx,
diff --git a/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
index ed7e92bc..6180e67d 100644
--- a/cogl/driver/gl/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
@@ -349,6 +349,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
CoglBitmap *bmp;
uint8_t *data;
GLenum gl_error;
+ CoglError *internal_error = NULL;
CoglBool status = TRUE;
bmp = prepare_bitmap_alignment_for_upload (ctx, source_bmp, error);
@@ -362,10 +363,18 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
- data = _cogl_bitmap_gl_bind (bmp, COGL_BUFFER_ACCESS_READ, 0, error);
- if (!data)
+ data = _cogl_bitmap_gl_bind (bmp,
+ COGL_BUFFER_ACCESS_READ,
+ 0, /* hints */
+ &internal_error);
+
+ /* NB: _cogl_bitmap_gl_bind() may return NULL when successful so we
+ * have to explicitly check the cogl error pointer to catch
+ * problems... */
+ if (internal_error)
{
cogl_object_unref (bmp);
+ _cogl_propagate_error (error, internal_error);
return FALSE;
}
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index a838472b..c49ea581 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -67,8 +67,8 @@ main (int argc, char **argv)
UNPORTED_TEST (test_multitexture);
UNPORTED_TEST (test_texture_mipmaps);
ADD_TEST (test_sub_texture, 0, 0);
- ADD_TEST (test_pixel_buffer_map, 0, TEST_KNOWN_FAILURE);
- ADD_TEST (test_pixel_buffer_set_data, 0, TEST_KNOWN_FAILURE);
+ ADD_TEST (test_pixel_buffer_map, 0, 0);
+ ADD_TEST (test_pixel_buffer_set_data, 0, 0);
ADD_TEST (test_pixel_buffer_sub_region, 0, 0);
UNPORTED_TEST (test_texture_rectangle);
ADD_TEST (test_texture_3d, TEST_REQUIREMENT_TEXTURE_3D, 0);
diff --git a/tests/conform/test-pixel-buffer.c b/tests/conform/test-pixel-buffer.c
index 39df4ab9..96b747d0 100644
--- a/tests/conform/test-pixel-buffer.c
+++ b/tests/conform/test-pixel-buffer.c
@@ -247,11 +247,12 @@ test_pixel_buffer_sub_region (void)
cogl_texture_set_region_from_bitmap (texture,
BITMAP_SIZE / 2, /* src_x */
BITMAP_SIZE / 2, /* src_y */
+ BITMAP_SIZE / 2, /* width */
+ BITMAP_SIZE / 2, /* height */
+ bitmap,
BITMAP_SIZE / 2, /* dst_x */
0, /* dst_y */
- BITMAP_SIZE / 2, /* dst_width */
- BITMAP_SIZE / 2, /* dst_height */
- bitmap,
+ 0, /* level */
NULL /* don't catch errors */);
pipeline = create_pipeline_from_texture (texture);