diff options
author | Carl Worth <cworth@cworth.org> | 2007-09-04 16:47:49 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2007-09-05 14:38:21 -0700 |
commit | 0682b9a9c18640c284c7cc8ba8792a329414998e (patch) | |
tree | 44c51e6025dfbb222d70b54c6617b55cfb048597 /test/rgb24-ignore-alpha.c | |
parent | 84a2c8968a57ed7593db1515718115218072bc0d (diff) |
Add rgb24-ignore-alpha test
This test demonstrates a bug when compositing an rgb24 image over an argb32
image, (the implementation appears to be examining the alpha channel
rather than ignoring it).
Diffstat (limited to 'test/rgb24-ignore-alpha.c')
-rw-r--r-- | test/rgb24-ignore-alpha.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/rgb24-ignore-alpha.c b/test/rgb24-ignore-alpha.c new file mode 100644 index 00000000..bb5ec356 --- /dev/null +++ b/test/rgb24-ignore-alpha.c @@ -0,0 +1,65 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Author: Carl D. Worth <cworth@cworth.org> + */ + +#include "cairo-test.h" + +static cairo_test_draw_function_t draw; + +#define WIDTH 2 +#define HEIGHT 2 + +cairo_test_t test = { + "rgb24-ignore-alpha", + "Test that when using an RGB24 image as a source, there is no alpha channel", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_surface_t *surface; + /* Four green pixels with different "alpha" values, (but which + * should be entirely ignored). */ + uint32_t colors[4] = { + 0xff00ff00, 0x8800ff00, + 0x4400ff00, 0x0000ff00 + }; + + surface = cairo_image_surface_create_for_data ((unsigned char *) colors, + CAIRO_FORMAT_RGB24, 2, 2, 8); + + cairo_set_source_surface (cr, surface, 0, 0); + cairo_paint (cr); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +} |