summaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-08-09 18:08:55 -0700
committerBryce Harrington <b.harrington@samsung.com>2014-08-09 18:08:55 -0700
commit4ca2997ddac3b31c18c8b0b084cef661acb28b71 (patch)
tree3fa2423f8ab24d443008c7c2ef6e3279e90cb530
parent7e0df210dd9cb58817c023ca2d16fde9206efce1 (diff)
parent6d68b9b3c7d7a4bd0880268e7c3f57c8f51a77c3 (diff)
Merge pull request #132 from Samsung/Issue_130
Issue 130.
-rw-r--r--src/cairo-tests/text.cpp81
-rw-r--r--src/skia-tests/linear-gradient.cpp2
-rw-r--r--src/skia-tests/radial-gradient.cpp2
-rw-r--r--src/skia-tests/text.cpp5
4 files changed, 28 insertions, 62 deletions
diff --git a/src/cairo-tests/text.cpp b/src/cairo-tests/text.cpp
index d40f0e6..bf3028d 100644
--- a/src/cairo-tests/text.cpp
+++ b/src/cairo-tests/text.cpp
@@ -8,34 +8,25 @@
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <cairo.h>
+#include <string.h>
#include "caskbench.h"
#include "caskbench_context.h"
#include "cairo-shapes.h"
-// This test converts a text string to glyphs and displays it at various font sizes
-
-static int max_dim;
-static char rand_text_array[19][100];
-
-static void
-gen_random(char *s, const int len) {
- static const char alphanum[] =
- "ABCD EFG HIJKL MNOPQ RSTUVW XYZ";
-
- for (int i = 0; i < len; ++i) {
- s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
- }
-
- s[len] = 0;
-}
+// This tests basic (non-glyph) text functionality
int
ca_setup_text(caskbench_context_t *ctx)
{
- max_dim = MIN (ctx->canvas_width, ctx->canvas_height)/2;
+ cairo_t *cr = ctx->cairo_cr;
+ cairo_select_font_face(cr, "Serif",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_BOLD);
+
+ cairo_set_font_size(cr, 20);
+ cairo_set_antialias(cr,CAIRO_ANTIALIAS_NONE);
return 1;
}
@@ -47,54 +38,28 @@ ca_teardown_text(void)
int
ca_test_text(caskbench_context_t *ctx)
{
+ char text[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cairo_t *cr = ctx->cairo_cr;
- double font_size = 18;
- int ypos = 15, xpos = 0;
- int num_glyphs = 0, num_clusters = 0;
-
- double font_factor = 0.5;
+ size_t byteLength = strlen(text) * sizeof(char);
+ cairo_text_extents_t text_metrics;
+ cairo_text_extents (cr, text, &text_metrics);
+ double tw = text_metrics.width + 3; // Adding 3 to make tw value same as skia text.
+ double w = (double) ctx->canvas_width;
+ double h = (double) ctx->canvas_height;
+ double off = abs (w - tw);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 0, 0, ctx->canvas_width ,ctx->canvas_height);
cairo_fill (cr);
+
for (int i = 0; i < ctx->size; i++)
{
- num_glyphs = 0;
- num_clusters = 0;
- cairo_set_font_size (cr, font_size);
- cairoRandomizeColor (ctx);
-
- cairo_status_t status;
- cairo_scaled_font_t *font;
- font = cairo_get_scaled_font (cr);
- cairo_glyph_t *glyphs = NULL;
- cairo_text_cluster_t *clusters = NULL;
- cairo_text_cluster_flags_t cluster_flags;
-
- char text[(int)font_size];
- gen_random (text,font_size);
-
- status = cairo_scaled_font_text_to_glyphs (font,
- xpos, ypos,
- text, font_size,
- &glyphs, &num_glyphs,
- &clusters, &num_clusters, &cluster_flags);
-
- if (status == CAIRO_STATUS_SUCCESS) {
- cairo_show_text_glyphs (cr,
- text,font_size,
- glyphs, num_glyphs,
- clusters, num_clusters, cluster_flags);
- }
+ double x = drand48() * off;
+ double y = drand48() * h;
- font_size = font_size+font_factor;
- ypos += (font_size/2);
- if (font_size >= 36)
- font_size = 36;
- if (ypos > ctx->canvas_height/2)
- font_factor = -0.5;
- if (font_size < 18)
- font_size = 18;
+ cairoRandomizeColor(ctx);
+ cairo_move_to(cr, x, y);
+ cairo_show_text(cr, text);
}
return 1;
}
diff --git a/src/skia-tests/linear-gradient.cpp b/src/skia-tests/linear-gradient.cpp
index f2c776b..723274c 100644
--- a/src/skia-tests/linear-gradient.cpp
+++ b/src/skia-tests/linear-gradient.cpp
@@ -39,7 +39,7 @@ sk_test_linear_gradient(caskbench_context_t *ctx)
{
int w = ctx->canvas_width;
int h = ctx->canvas_height;
- int stops = 2;
+ int stops = 10;
SkPoint pts[2];
pts[0].iset(0, 0);
diff --git a/src/skia-tests/radial-gradient.cpp b/src/skia-tests/radial-gradient.cpp
index 21025a8..69cfb05 100644
--- a/src/skia-tests/radial-gradient.cpp
+++ b/src/skia-tests/radial-gradient.cpp
@@ -33,7 +33,7 @@ sk_test_radial_gradient(caskbench_context_t *ctx)
{
int w = ctx->canvas_width;
int h = ctx->canvas_height;
- int stops = 2;
+ int stops = 10;
SkPoint pts[2];
pts[0].iset(20, 20);
diff --git a/src/skia-tests/text.cpp b/src/skia-tests/text.cpp
index bff88eb..4d3b399 100644
--- a/src/skia-tests/text.cpp
+++ b/src/skia-tests/text.cpp
@@ -51,8 +51,9 @@ sk_test_text(caskbench_context_t *ctx)
char text[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
size_t byteLength = strlen(text) * sizeof(char);
double tw = SkScalarToDouble(ctx->skia_paint->measureText(text, byteLength));
- double w = (double)ctx->skia_canvas->getDevice()->width();
- double h = (double)ctx->skia_canvas->getDevice()->height();
+
+ double w = (double)ctx->canvas_width;
+ double h = (double)ctx->canvas_height;
double off = abs (w - tw);
ctx->skia_canvas->drawColor(SK_ColorBLACK);