summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-tests/mask.cpp
diff options
context:
space:
mode:
authorsuyambulingamrm <suyambu.rm@samsung.com>2014-05-15 09:31:05 +0530
committerBryce Harrington <b.harrington@samsung.com>2014-05-20 17:56:25 -0700
commit226dd607a3797d9f8ee5f1071fe76e8f65bff842 (patch)
treee505f3ddb38a188cd8fbe79611770ee8a26de852 /src/cairo-tests/mask.cpp
parentcea09733638d03edb68ceeac2c578705b4f78893 (diff)
mask: Use gl surface instead of image surface to optimize test performance.
ref: https://github.com/SRA-SiliconValley/caskbench/issues/17
Diffstat (limited to 'src/cairo-tests/mask.cpp')
-rw-r--r--src/cairo-tests/mask.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/cairo-tests/mask.cpp b/src/cairo-tests/mask.cpp
index 982dae0..4a288b7 100644
--- a/src/cairo-tests/mask.cpp
+++ b/src/cairo-tests/mask.cpp
@@ -9,6 +9,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <cairo.h>
+#if USE_EGL
+# include <cairo-gl.h>
+#endif
#include "caskbench.h"
#include "cairo-shapes.h"
@@ -24,11 +27,34 @@ ca_setup_mask(caskbench_context_t *ctx)
0x00, 0xFF, 0xFF, 0x00,
0xFF, 0x00, 0x00, 0xFF, };
static cairo_surface_t *stippled = NULL;
+ cairo_surface_t *cairo_surface;
if (stippled == NULL) {
stippled = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_A8, 2, 2, 4);
}
+
+#if USE_EGL
+ cairo_device_t *cairo_device = cairo_surface_get_device (ctx->cairo_surface);
+ if (cairo_surface_get_type (ctx->cairo_surface) == CAIRO_SURFACE_TYPE_IMAGE) {
+ cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2);
+ } else if (cairo_surface_get_type (ctx->cairo_surface) == CAIRO_SURFACE_TYPE_GL) {
+ /* create a gl surface the same size as image surface */
+ cairo_surface = cairo_gl_surface_create (cairo_device, CAIRO_CONTENT_COLOR_ALPHA, 2, 2);
+ }
+
+ cairo_t *gl_ctx = cairo_create (cairo_surface);
+ cairo_pattern_t *pattern = cairo_pattern_create_for_surface (stippled);
+ cairo_set_source (gl_ctx, pattern);
+
+ /* paint image surface to gl surface */
+ cairo_paint (gl_ctx);
+ cairo_destroy (gl_ctx);
+
+ /* use gl surface as mask */
+ mask = cairo_pattern_create_for_surface (cairo_surface);
+#else
mask = cairo_pattern_create_for_surface (stippled);
+#endif
cairo_pattern_set_extend (mask, CAIRO_EXTEND_REPEAT);
cairo_pattern_set_filter (mask, CAIRO_FILTER_NEAREST);