summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-12-30 12:32:45 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-12-30 12:47:02 +0000
commitd3848521c497dbcd3d9ae0fab34fa70c72752e60 (patch)
tree29a87a808645a17a47c493629259d1232d8b0d10 /src
parent127dd466695dcb05e6178e4ed2471dba1b229d17 (diff)
downloadcairo-d3848521c497dbcd3d9ae0fab34fa70c72752e60.tar.gz
gl: Provide a fast emitter for solid glyphs
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/cairo-gl-composite.c62
1 files changed, 49 insertions, 13 deletions
diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 90feb6a8b..61dc7456f 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -936,10 +936,8 @@ _cairo_gl_context_choose_emit_span (cairo_gl_context_t *ctx)
static inline void
_cairo_gl_composite_emit_glyph_vertex (cairo_gl_context_t *ctx,
- GLfloat x,
- GLfloat y,
- GLfloat glyph_x,
- GLfloat glyph_y)
+ GLfloat x, GLfloat y,
+ GLfloat glyph_x, GLfloat glyph_y)
{
GLfloat *vb = (GLfloat *) (void *) &ctx->vb[ctx->vb_offset];
@@ -956,14 +954,10 @@ _cairo_gl_composite_emit_glyph_vertex (cairo_gl_context_t *ctx,
static void
_cairo_gl_composite_emit_glyph (cairo_gl_context_t *ctx,
- GLfloat x1,
- GLfloat y1,
- GLfloat x2,
- GLfloat y2,
- GLfloat glyph_x1,
- GLfloat glyph_y1,
- GLfloat glyph_x2,
- GLfloat glyph_y2)
+ GLfloat x1, GLfloat y1,
+ GLfloat x2, GLfloat y2,
+ GLfloat glyph_x1, GLfloat glyph_y1,
+ GLfloat glyph_x2, GLfloat glyph_y2)
{
_cairo_gl_composite_prepare_buffer (ctx, 6,
CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES);
@@ -977,10 +971,52 @@ _cairo_gl_composite_emit_glyph (cairo_gl_context_t *ctx,
_cairo_gl_composite_emit_glyph_vertex (ctx, x1, y2, glyph_x1, glyph_y2);
}
+static void
+_cairo_gl_composite_emit_solid_glyph (cairo_gl_context_t *ctx,
+ GLfloat x1, GLfloat y1,
+ GLfloat x2, GLfloat y2,
+ GLfloat glyph_x1, GLfloat glyph_y1,
+ GLfloat glyph_x2, GLfloat glyph_y2)
+{
+ GLfloat *v;
+
+ _cairo_gl_composite_prepare_buffer (ctx, 6,
+ CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES);
+
+ v = (GLfloat *) (void *) &ctx->vb[ctx->vb_offset];
+
+ v[20] = v[ 8] = v[0] = x1;
+ v[13] = v[ 5] = v[1] = y1;
+ v[22] = v[10] = v[2] = glyph_x1;
+ v[15] = v[ 7] = v[3] = glyph_y1;
+
+ v[16] = v[12] = v[4] = x2;
+ v[18] = v[14] = v[6] = glyph_x2;
+
+ v[21] = v[17] = v[ 9] = y2;
+ v[23] = v[19] = v[11] = glyph_y2;
+
+ ctx->vb_offset += 4 * 6 * sizeof (GLfloat);
+}
+
cairo_gl_emit_glyph_t
_cairo_gl_context_choose_emit_glyph (cairo_gl_context_t *ctx)
{
- return _cairo_gl_composite_emit_glyph;
+ switch (ctx->operands[CAIRO_GL_TEX_SOURCE].type) {
+ default:
+ case CAIRO_GL_OPERAND_COUNT:
+ ASSERT_NOT_REACHED;
+ case CAIRO_GL_OPERAND_NONE:
+ case CAIRO_GL_OPERAND_CONSTANT:
+ return _cairo_gl_composite_emit_solid_glyph;
+
+ case CAIRO_GL_OPERAND_LINEAR_GRADIENT:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE:
+ case CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT:
+ case CAIRO_GL_OPERAND_TEXTURE:
+ return _cairo_gl_composite_emit_glyph;
+ }
}
void