summaryrefslogtreecommitdiff
path: root/test/show-glyphs-many.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-06-18 16:30:41 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-06-19 00:28:58 +0100
commit6e78c94615e407d72d4778d5558dc218e0402cbc (patch)
treef7d727f4dfe6ada8eb42b712fd2f265df7a2e73d /test/show-glyphs-many.c
parent3da32e35afa57533379c3de35459f23aef7c3d04 (diff)
downloadcairo-6e78c94615e407d72d4778d5558dc218e0402cbc.tar.gz
[test] Move calls to the getters from out of the innermost loops.
Tidy the code slightly by removing excess and unsightly calls to cairo_test_get_context() and cairo_get_scaled_font().
Diffstat (limited to 'test/show-glyphs-many.c')
-rw-r--r--test/show-glyphs-many.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/show-glyphs-many.c b/test/show-glyphs-many.c
index dbfd6a1cd..f689fe080 100644
--- a/test/show-glyphs-many.c
+++ b/test/show-glyphs-many.c
@@ -80,7 +80,10 @@
#define NUM_GLYPHS 65535
static cairo_test_status_t
-get_glyph (cairo_t *cr, const char *utf8, cairo_glyph_t *glyph)
+get_glyph (const cairo_test_context_t *ctx,
+ cairo_scaled_font_t *scaled_font,
+ const char *utf8,
+ cairo_glyph_t *glyph)
{
cairo_glyph_t *text_to_glyphs;
cairo_status_t status;
@@ -88,15 +91,14 @@ get_glyph (cairo_t *cr, const char *utf8, cairo_glyph_t *glyph)
text_to_glyphs = glyph;
i = 1;
- status = cairo_scaled_font_text_to_glyphs (cairo_get_scaled_font (cr),
+ status = cairo_scaled_font_text_to_glyphs (scaled_font,
0, 0,
utf8, -1,
&text_to_glyphs, &i,
NULL, NULL,
0);
if (status != CAIRO_STATUS_SUCCESS)
- return cairo_test_status_from_status (cairo_test_get_context (cr),
- status);
+ return cairo_test_status_from_status (ctx, status);
if (text_to_glyphs != glyph) {
*glyph = text_to_glyphs[0];
@@ -109,7 +111,9 @@ get_glyph (cairo_t *cr, const char *utf8, cairo_glyph_t *glyph)
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
+ const cairo_test_context_t *ctx = cairo_test_get_context (cr);
cairo_glyph_t *glyphs = xmalloc (NUM_GLYPHS * sizeof (cairo_glyph_t));
+ cairo_scaled_font_t *scaled_font;
const char *characters[] = { /* try to exercise different widths of index */
"m", /* Latin letter m, index=0x50 */
"μ", /* Greek letter mu, index=0x349 */
@@ -126,9 +130,10 @@ draw (cairo_t *cr, int width, int height)
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, TEXT_SIZE);
+ scaled_font = cairo_get_scaled_font (cr);
for (utf8 = characters; *utf8 != NULL; utf8++) {
- status = get_glyph (cr, *utf8, &glyphs[0]);
+ status = get_glyph (ctx, scaled_font, *utf8, &glyphs[0]);
if (status)
goto BAIL;
@@ -143,13 +148,13 @@ draw (cairo_t *cr, int width, int height)
}
/* we can pack ~21k 1-byte glyphs into a single XRenderCompositeGlyphs8 */
- status = get_glyph (cr, "m", &glyphs[0]);
+ status = get_glyph (ctx, scaled_font, "m", &glyphs[0]);
if (status)
goto BAIL;
for (i=1; i < 21500; i++)
glyphs[i] = glyphs[0];
/* so check expanding the current 1-byte request for 2-byte glyphs */
- status = get_glyph (cr, "μ", &glyphs[i]);
+ status = get_glyph (ctx, scaled_font, "μ", &glyphs[i]);
if (status)
goto BAIL;
for (j=i+1; j < NUM_GLYPHS; j++)