summaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-05-08 10:22:35 -0700
committerBryce Harrington <b.harrington@samsung.com>2014-05-08 18:50:52 -0700
commite4a47f2f5e6a4422c8899cf1858df649f11098ea (patch)
treea27c72a2661f4a0ac671100049074db7223dd94a /src
parent6462239c7432142640eaa3cc0f9b80fb102014d2 (diff)
Track the image path as part of the cairo context, not a shape default
We aren't randomizing the image or varying it from shape to shape, so it doesn't really belong in the shapes structure.
Diffstat (limited to 'src')
-rw-r--r--src/cairo-tests/clip.cpp2
-rw-r--r--src/cairo-tests/fill.cpp5
-rw-r--r--src/caskbench.cpp9
-rw-r--r--src/caskbench.h1
-rw-r--r--src/shapes.h1
-rw-r--r--src/skia-tests/fill.cpp2
6 files changed, 9 insertions, 11 deletions
diff --git a/src/cairo-tests/clip.cpp b/src/cairo-tests/clip.cpp
index e8f2872..f688c35 100644
--- a/src/cairo-tests/clip.cpp
+++ b/src/cairo-tests/clip.cpp
@@ -60,7 +60,7 @@ void drawClip(caskbench_context_t *ctx,kinetics_t *particles)
int w, h;
double x,y;
cairo_t *cr = ctx->cairo_cr;
- image = cairo_image_surface_create_from_png (ctx->shape_defaults.image_path);
+ image = cairo_image_surface_create_from_png (ctx->stock_image_path);
for (j=0; j<num_y_elements; j++) {
y = particles?particles->y : j * element_spacing;
for (i=0; i<num_x_elements; i++) {
diff --git a/src/cairo-tests/fill.cpp b/src/cairo-tests/fill.cpp
index e9975c8..69bfc55 100644
--- a/src/cairo-tests/fill.cpp
+++ b/src/cairo-tests/fill.cpp
@@ -102,18 +102,17 @@ void drawshapes(caskbench_context_t *ctx,kinetics_t *particles)
}
else if(ctx->shape_defaults.fill_type == CB_FILL_HERRINGBONE_PATTERN){}
- else if(ctx->shape_defaults.fill_type == CB_FILL_IMAGE_PATTERN && (ctx->shape_defaults.image_path))
+ else if(ctx->shape_defaults.fill_type == CB_FILL_IMAGE_PATTERN && (ctx->stock_image_path))
{
cairo_matrix_t matrix;
- image = cairo_image_surface_create_from_png (ctx->shape_defaults.image_path);
+ image = cairo_image_surface_create_from_png (ctx->stock_image_path);
int w = cairo_image_surface_get_width (image);
int h = cairo_image_surface_get_height (image);
pattern = cairo_pattern_create_for_surface (image);
cairo_set_source (cr, pattern);
}
-
if (!ctx->shape_defaults.multi_shapes && !ctx->shape_defaults.animation) {
x = ctx->shape_defaults.x;
y = ctx->shape_defaults.y;
diff --git a/src/caskbench.cpp b/src/caskbench.cpp
index 9e92576..6701d59 100644
--- a/src/caskbench.cpp
+++ b/src/caskbench.cpp
@@ -59,7 +59,7 @@ typedef struct _caskbench_options {
double blue;
double alpha;
int animation;
- char *image_path;
+ char *stock_image_path;
int stroke_width;
int multi_shapes;
@@ -238,8 +238,8 @@ process_options(caskbench_options_t *opt, int argc, char *argv[])
{"animation", 'g', POPT_ARG_INT, &opt->animation, 0,
"Controls the kinematics of the objects drawn",
NULL},
- {"image-path", 'I', POPT_ARG_STRING, &opt->image_path, 0,
- "Image path to refer the image for setting source, clipping, patterns",
+ {"image-path", 'I', POPT_ARG_STRING, &opt->stock_image_path, 0,
+ "Path to a stock image for use in clipping, patterns, etc.",
NULL},
{"stroke-width", 'w', POPT_ARG_INT, &opt->stroke_width, 0,
"represents stroke width of the object",
@@ -295,7 +295,7 @@ process_options(caskbench_options_t *opt, int argc, char *argv[])
opt->blue = 0;
opt->alpha = 0;
opt->animation = 0;
- opt->image_path = NULL;
+ opt->stock_image_path = NULL;
opt->multi_shapes = 0;
opt->stroke_width = 0;
opt->stroke_red = 0;
@@ -529,7 +529,6 @@ shape_defaults_init(shapes *shape_defaults, caskbench_options_t *opt)
shape_defaults->green = opt->green;
shape_defaults->blue = opt->blue;
shape_defaults->alpha = opt->alpha;
- shape_defaults->image_path = opt->image_path;
shape_defaults->stroke_width = opt->stroke_width;
shape_defaults->multi_shapes = opt->multi_shapes;
shape_defaults->animation = opt->animation;
diff --git a/src/caskbench.h b/src/caskbench.h
index d59a888..afd80e2 100644
--- a/src/caskbench.h
+++ b/src/caskbench.h
@@ -45,6 +45,7 @@ typedef struct _caskbench_context {
void (*update_cairo)(void);
void (*update_skia)(void);
+ const char *stock_image_path;
shapes_t shape_defaults;
} caskbench_context_t;
diff --git a/src/shapes.h b/src/shapes.h
index 43622fd..90d27af 100644
--- a/src/shapes.h
+++ b/src/shapes.h
@@ -40,7 +40,6 @@ typedef struct shapes
double blue;
double alpha;
int animation;
- char *image_path;
int stroke_width;
int multi_shapes;
diff --git a/src/skia-tests/fill.cpp b/src/skia-tests/fill.cpp
index 9373453..d8ca2c5 100644
--- a/src/skia-tests/fill.cpp
+++ b/src/skia-tests/fill.cpp
@@ -149,7 +149,7 @@ void drawSkiaShapes(caskbench_context_t *ctx, kinetics_t *particle)
{
SkBitmap bm;
- SkImageDecoder::DecodeFile(ctx->shape_defaults.image_path, &bm);
+ SkImageDecoder::DecodeFile(ctx->stock_image_path, &bm);
shader = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode);
}