diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-06-07 03:29:54 +0900 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-06-07 03:29:54 +0900 |
| commit | 44e4036a74e0be8e960bc30a77b57fa6f44bea72 (patch) | |
| tree | 54811f7a5b823559fd2166c5ac74cdeca938f9d7 /src | |
| parent | 79c8e88722f523363abeef95d2a4ce1511fc80d8 (diff) | |
| parent | 49500c1a630e8df30ae2ba189c8d982bf2d6fac6 (diff) | |
Merge pull request #86 from Samsung/Issue_77
Add ENABLE_CAIRO option to permit building caskbench without Cairo support.
ref: https://github.com/Samsung/caskbench/issues/77
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 22 | ||||
| -rw-r--r-- | src/cairo-tests/mask.cpp | 4 | ||||
| -rw-r--r-- | src/caskbench.cpp | 30 | ||||
| -rw-r--r-- | src/caskbench_context.cpp | 7 | ||||
| -rwxr-xr-x | src/generate_tests | 4 |
5 files changed, 54 insertions, 13 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5e1abb0..763415a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,23 +5,17 @@ file(GLOB caskbench_SOURCES kinetics.cpp image.cpp shapes.cpp - cairo-util.cpp - cairo-image.cpp - cairo-shapes.cpp - cairo-tests/*.cpp ) if (USE_GLX) list(APPEND caskbench_SOURCES glx.cpp - cairo-glx.cpp ) endif (USE_GLX) if (USE_EGL) list(APPEND caskbench_SOURCES egl.cpp - cairo-egl.cpp ) endif (USE_EGL) @@ -41,6 +35,22 @@ if (USE_SKIA) endif (USE_EGL) endif (USE_SKIA) +if (USE_CAIRO) + file(GLOB cairo_files + cairo-util.cpp + cairo-image.cpp + cairo-shapes.cpp + cairo-tests/*.cpp + ) + list(APPEND caskbench_SOURCES ${cairo_files} ) + if (USE_GLX) + list(APPEND caskbench_SOURCES cairo-glx.cpp) + endif (USE_GLX) + if (USE_EGL) + list(APPEND caskbench_SOURCES cairo-egl.cpp) + endif (USE_EGL) +endif (USE_CAIRO) + add_executable(generate_tests IMPORTED) set_property(TARGET generate_tests PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/generate_tests") diff --git a/src/cairo-tests/mask.cpp b/src/cairo-tests/mask.cpp index 7213bec..feb1db1 100644 --- a/src/cairo-tests/mask.cpp +++ b/src/cairo-tests/mask.cpp @@ -46,9 +46,9 @@ ca_setup_mask(caskbench_context_t *ctx) /* use gl surface as mask */ mask = cairo_pattern_create_for_surface (cairo_surface); } -#else - mask = cairo_pattern_create_for_surface (stippled); + else #endif + mask = cairo_pattern_create_for_surface (stippled); cairo_pattern_set_extend (mask, CAIRO_EXTEND_REPEAT); cairo_pattern_set_filter (mask, CAIRO_FILTER_NEAREST); diff --git a/src/caskbench.cpp b/src/caskbench.cpp index 3260ed1..e813363 100644 --- a/src/caskbench.cpp +++ b/src/caskbench.cpp @@ -393,6 +393,10 @@ process_drawing_libs (const char *libs, int &num_tests, int *test_ids) bool skia_cairo = false; memset(filter, 0, sizeof(filter)); +#ifndef USE_CAIRO + if (strstr(libs, "cairo")) + errx (0, "cairo is unavailable in the build\n"); +#endif #ifndef USE_SKIA if (strstr(libs, "skia")) errx (0, "skia is unavailable in this build\n"); @@ -430,27 +434,43 @@ process_drawing_libs (const char *libs, int &num_tests, int *test_ids) void populate_user_tests (const char** tests, int& num_tests, int* test_ids) { int i = 0, id = -1, test_index = 0; + char skia_test[MAX_BUFFER]; + char cairo_test[MAX_BUFFER]; + strncpy(cairo_test, "cairo-", 6); + strncpy(skia_test, "skia-", 5); if (tests == NULL) return; while (tests[i] != NULL) { - id = convertToTestId (tests[i]); - if (id < 0) + if (strlen(tests[i]) >= MAX_BUFFER) errx (0, "Incorrect test case, please check the test case provided as input \n"); + /* We can assume no more that skia test will be next to cairo */ + cairo_test[6] = skia_test[5] = '\0'; + strncat(cairo_test, tests[i], strlen(tests[i])); + strncat(skia_test, tests[i], strlen(tests[i])); + +#ifdef USE_CAIRO /* Add cairo test index to the test list */ + id = convertToTestId (cairo_test); + if (id < 0) + errx (0, "Incorrect test case, please check the test case provided as input \n"); test_ids[test_index++] = id; + num_tests = num_tests + 1; +#endif #ifdef USE_SKIA /* Add skia test index to the test list */ - test_ids[test_index++] = id + 1; - num_tests = num_tests + 2; -#else + id = convertToTestId (skia_test); + if (id < 0) + errx (0, "Incorrect test case, please check the test case provided as input \n"); + test_ids[test_index++] = id; num_tests = num_tests + 1; #endif i++; } } + int main (int argc, char *argv[]) { diff --git a/src/caskbench_context.cpp b/src/caskbench_context.cpp index a80fe7b..979a79d 100644 --- a/src/caskbench_context.cpp +++ b/src/caskbench_context.cpp @@ -9,11 +9,14 @@ #include <assert.h> #include <err.h> +#include <string.h> +#ifdef USE_CAIRO #include <cairo.h> #ifdef HAVE_CAIRO_GL_H # include <cairo-gl.h> #endif +#endif #ifdef USE_SKIA # include <SkBitmap.h> @@ -45,6 +48,7 @@ context_init(caskbench_context_t *context, int size) context->tolerance = 0.25; } +#ifdef USE_CAIRO void context_setup_cairo(caskbench_context_t *context, const device_config_t& config) { @@ -90,6 +94,7 @@ context_setup_cairo(caskbench_context_t *context, const device_config_t& config) // Ease up Cairo's tessellation tolerance (default is 0.001) cairo_set_tolerance (context->cairo_cr, context->tolerance); } +#endif void context_update_cairo(caskbench_context_t *context) @@ -102,8 +107,10 @@ context_destroy_cairo(caskbench_context_t *context) { if (!context) return; +#ifdef USE_CAIRO cairo_destroy(context->cairo_cr); cairo_surface_destroy(context->cairo_surface); +#endif context->destroy_cairo(); context->cairo_cr = NULL; } diff --git a/src/generate_tests b/src/generate_tests index 56e2883..8c281fe 100755 --- a/src/generate_tests +++ b/src/generate_tests @@ -16,6 +16,7 @@ EOF ) > $out_file echo "" >> $out_file +echo "#ifdef USE_CAIRO" >> $out_file echo "// Cairo Tests" >> $out_file for source_file in $(ls ${source_dir}/cairo-tests/*.cpp); do test=$(basename ${source_file%.cpp}) @@ -27,6 +28,7 @@ int ca_test_${test}(struct _caskbench_context *ctx); EOF ) >> $out_file done +echo "#endif // USE_CAIRO" >> $out_file echo "" >> $out_file echo "#ifdef USE_SKIA" >> $out_file @@ -54,8 +56,10 @@ for source_file in $(ls ${source_dir}/cairo-tests/*.cpp); do fi (cat <<EOF +#ifdef USE_CAIRO {"cairo-${test}", ca_setup_${test}, ca_teardown_${test}, ca_test_${test}, write_image_file_cairo, context_setup_cairo, context_destroy_cairo, context_update_cairo }, +#endif #ifdef USE_SKIA {"skia-${test}", sk_setup_${test}, sk_teardown_${test}, sk_test_${test}, write_image_file_skia, context_setup_skia, context_destroy_skia, context_update_skia }, |