summaryrefslogtreecommitdiff
path: root/boilerplate
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2007-04-20 00:50:48 -0400
committerBehdad Esfahbod <behdad@behdad.org>2007-04-20 00:52:04 -0400
commitabcd929c57459f95e93504e0ef07b012b497a363 (patch)
tree5d5086d4a7f9b79ef0d3e5c1d3b8589be29c733a /boilerplate
parent97624dc488b41eb83d70b2c44a595daa5d833e7f (diff)
[boilerplate] Add cairo_boilerplate_format_from_content
Diffstat (limited to 'boilerplate')
-rw-r--r--boilerplate/cairo-boilerplate-quartz.c9
-rw-r--r--boilerplate/cairo-boilerplate-test-surfaces.c13
-rw-r--r--boilerplate/cairo-boilerplate-win32.c8
-rw-r--r--boilerplate/cairo-boilerplate.c18
-rw-r--r--boilerplate/cairo-boilerplate.h3
5 files changed, 25 insertions, 26 deletions
diff --git a/boilerplate/cairo-boilerplate-quartz.c b/boilerplate/cairo-boilerplate-quartz.c
index d6df7fa03..3b23aed2a 100644
--- a/boilerplate/cairo-boilerplate-quartz.c
+++ b/boilerplate/cairo-boilerplate-quartz.c
@@ -39,14 +39,7 @@ _cairo_boilerplate_quartz_create_surface (const char *name,
{
cairo_format_t format;
- switch (content) {
- case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;
- case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
- case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
- default:
- assert (0); /* not reached */
- return NULL;
- }
+ format = cairo_boilerplate_format_from_content (content);
*closure = NULL;
diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c
index ab202d51e..93ca5e7fc 100644
--- a/boilerplate/cairo-boilerplate-test-surfaces.c
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -128,18 +128,7 @@ _cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface
tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
- switch (tpc->content) {
- case CAIRO_CONTENT_COLOR:
- format = CAIRO_FORMAT_RGB24;
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- format = CAIRO_FORMAT_ARGB32;
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- assert (0); /* not reached */
- return CAIRO_STATUS_NO_MEMORY;
- }
+ format = cairo_boilerplate_format_from_content (tpc->content);
image = cairo_image_surface_create_for_data (tpc->data,
format,
diff --git a/boilerplate/cairo-boilerplate-win32.c b/boilerplate/cairo-boilerplate-win32.c
index 3b95378d6..cd15873ae 100644
--- a/boilerplate/cairo-boilerplate-win32.c
+++ b/boilerplate/cairo-boilerplate-win32.c
@@ -39,13 +39,9 @@ _cairo_boilerplate_win32_create_surface (const char *name,
{
cairo_format_t format;
- if (content == CAIRO_CONTENT_COLOR)
- format = CAIRO_FORMAT_RGB24;
- else if (content == CAIRO_CONTENT_COLOR_ALPHA)
- format = CAIRO_FORMAT_ARGB32;
- else
- return NULL;
+ format = cairo_boilerplate_format_from_content (content);
*closure = NULL;
+
return cairo_win32_surface_create_with_dib (format, width, height);
}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 6165d7e59..1f49e8210 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -100,6 +100,24 @@ cairo_boilerplate_content_name (cairo_content_t content)
}
}
+cairo_format_t
+cairo_boilerplate_format_from_content (cairo_content_t content)
+{
+ cairo_format_t format;
+
+ switch (content) {
+ case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;
+ case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
+ case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
+ default:
+ assert (0); /* not reached */
+ format = (cairo_format_t) -1;
+ break;
+ }
+
+ return format;
+}
+
static cairo_surface_t *
_cairo_boilerplate_image_create_surface (const char *name,
cairo_content_t content,
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index aa23e1ce9..9f0fc56f5 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -94,6 +94,9 @@
const char *
cairo_boilerplate_content_name (cairo_content_t content);
+cairo_format_t
+cairo_boilerplate_format_from_content (cairo_content_t content);
+
typedef enum {
CAIRO_BOILERPLATE_MODE_TEST,
CAIRO_BOILERPLATE_MODE_PERF