static void _cairo_gl_composite_emit_solid_span (cairo_gl_context_t *ctx, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, uint8_t alpha) { GLfloat *v; union fi { float f; GLbyte bytes[4]; } fi; _cairo_gl_composite_prepare_buffer (ctx, 6, CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES); v = (GLfloat *) (void *) &ctx->vb[ctx->vb_offset]; v[15] = v[ 6] = v[0] = x1; v[10] = v[ 4] = v[1] = y1; v[12] = v[ 9] = v[3] = x2; v[16] = v[13] = v[7] = y2; fi.bytes[0] = 0; fi.bytes[1] = 0; fi.bytes[2] = 0; fi.bytes[3] = alpha; v[17] =v[14] = v[11] = v[8] = v[5] = v[2] = fi.f; ctx->vb_offset += 6*3 * sizeof(GLfloat); }
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) { if (ctx->draw_mode != CAIRO_GL_VERTEX) { _cairo_gl_composite_flush (ctx); ctx->draw_mode = CAIRO_GL_VERTEX; } _cairo_gl_composite_prepare_buffer (ctx, 6, CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES); _cairo_gl_composite_emit_glyph_vertex (ctx, x1, y1, glyph_x1, glyph_y1); _cairo_gl_composite_emit_glyph_vertex (ctx, x2, y1, glyph_x2, glyph_y1); _cairo_gl_composite_emit_glyph_vertex (ctx, x1, y2, glyph_x1, glyph_y2); _cairo_gl_composite_emit_glyph_vertex (ctx, x2, y1, glyph_x2, glyph_y1); _cairo_gl_composite_emit_glyph_vertex (ctx, x2, y2, glyph_x2, glyph_y2); _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_int_status_t _cairo_gl_composite_emit_triangle_as_tristrip (cairo_gl_context_t *ctx, cairo_gl_composite_t *setup, const cairo_point_t triangle[3]) { _cairo_gl_composite_prepare_buffer (ctx, 3); _cairo_gl_composite_emit_tristrip_vertex (ctx, &triangle[0]); _cairo_gl_composite_emit_tristrip_vertex (ctx, &triangle[1]); _cairo_gl_composite_emit_tristrip_vertex (ctx, &triangle[2]); return _cairo_gl_composite_append_vertex_indices (ctx, 3); }
cairo_int_status_t _cairo_gl_composite_emit_triangle_as_tristrip (cairo_gl_context_t *ctx, cairo_gl_composite_t *setup, const cairo_point_t triangle[3]) { _cairo_gl_composite_prepare_buffer (ctx, 3, CAIRO_GL_PRIMITIVE_TYPE_TRISTRIPS); _cairo_gl_composite_emit_point (ctx, &triangle[0], 0); _cairo_gl_composite_emit_point (ctx, &triangle[1], 0); _cairo_gl_composite_emit_point (ctx, &triangle[2], 0); return _cairo_gl_composite_append_vertex_indices (ctx, 3); }
static void _cairo_gl_composite_emit_rect (cairo_gl_context_t *ctx, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { _cairo_gl_composite_prepare_buffer (ctx, 6, CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES); _cairo_gl_composite_emit_vertex (ctx, x1, y1); _cairo_gl_composite_emit_vertex (ctx, x2, y1); _cairo_gl_composite_emit_vertex (ctx, x1, y2); _cairo_gl_composite_emit_vertex (ctx, x2, y1); _cairo_gl_composite_emit_vertex (ctx, x2, y2); _cairo_gl_composite_emit_vertex (ctx, x1, y2); }
cairo_int_status_t _cairo_gl_composite_emit_point_as_single_line (cairo_gl_context_t *ctx, const cairo_point_t point[2]) { int num_indices = 2; if (ctx->draw_mode != CAIRO_GL_LINES) _cairo_gl_composite_flush (ctx); ctx->draw_mode = CAIRO_GL_LINES; _cairo_gl_composite_prepare_buffer (ctx, 2, CAIRO_GL_PRIMITIVE_TYPE_TRISTRIPS); _cairo_gl_composite_emit_point (ctx, &point[0], 0); _cairo_gl_composite_emit_point (ctx, &point[1], 0); return _cairo_gl_composite_append_vertex_indices (ctx, num_indices, FALSE); }
static void _cairo_gl_composite_emit_span (cairo_gl_context_t *ctx, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, uint8_t alpha) { _cairo_gl_composite_prepare_buffer (ctx, 6, CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES); _cairo_gl_composite_emit_alpha_vertex (ctx, x1, y1, alpha); _cairo_gl_composite_emit_alpha_vertex (ctx, x2, y1, alpha); _cairo_gl_composite_emit_alpha_vertex (ctx, x1, y2, alpha); _cairo_gl_composite_emit_alpha_vertex (ctx, x2, y1, alpha); _cairo_gl_composite_emit_alpha_vertex (ctx, x2, y2, alpha); _cairo_gl_composite_emit_alpha_vertex (ctx, x1, y2, alpha); }
cairo_int_status_t _cairo_gl_composite_emit_quad_as_tristrip (cairo_gl_context_t *ctx, cairo_gl_composite_t *setup, const cairo_point_t quad[4]) { _cairo_gl_composite_prepare_buffer (ctx, 4); _cairo_gl_composite_emit_tristrip_vertex (ctx, &quad[0]); _cairo_gl_composite_emit_tristrip_vertex (ctx, &quad[1]); /* Cairo stores quad vertices in counter-clockwise order, but we need to emit them from top to bottom in the triangle strip, so we need to reverse the order of the last two vertices. */ _cairo_gl_composite_emit_tristrip_vertex (ctx, &quad[3]); _cairo_gl_composite_emit_tristrip_vertex (ctx, &quad[2]); return _cairo_gl_composite_append_vertex_indices (ctx, 4); }
void _cairo_gl_composite_emit_rect (cairo_gl_context_t *ctx, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, uint8_t alpha) { _cairo_gl_composite_prepare_buffer (ctx, 6); _cairo_gl_composite_emit_vertex (ctx, x1, y1, alpha); _cairo_gl_composite_emit_vertex (ctx, x2, y1, alpha); _cairo_gl_composite_emit_vertex (ctx, x1, y2, alpha); _cairo_gl_composite_emit_vertex (ctx, x2, y1, alpha); _cairo_gl_composite_emit_vertex (ctx, x2, y2, alpha); _cairo_gl_composite_emit_vertex (ctx, x1, y2, alpha); }
cairo_int_status_t _cairo_gl_composite_emit_triangle_as_tristrip (cairo_gl_context_t *ctx, cairo_gl_composite_t *setup, const cairo_point_t triangle[3]) { if (ctx->draw_mode != CAIRO_GL_VERTEX) { _cairo_gl_composite_flush (ctx); ctx->draw_mode = CAIRO_GL_VERTEX; } _cairo_gl_composite_prepare_buffer (ctx, 3, CAIRO_GL_PRIMITIVE_TYPE_TRISTRIPS); _cairo_gl_composite_emit_point (ctx, &triangle[0], 0); _cairo_gl_composite_emit_point (ctx, &triangle[1], 0); _cairo_gl_composite_emit_point (ctx, &triangle[2], 0); return _cairo_gl_composite_append_vertex_indices (ctx, 3, TRUE); }
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) { _cairo_gl_composite_prepare_buffer (ctx, 6); _cairo_gl_composite_emit_glyph_vertex (ctx, x1, y1, glyph_x1, glyph_y1); _cairo_gl_composite_emit_glyph_vertex (ctx, x2, y1, glyph_x2, glyph_y1); _cairo_gl_composite_emit_glyph_vertex (ctx, x1, y2, glyph_x1, glyph_y2); _cairo_gl_composite_emit_glyph_vertex (ctx, x2, y1, glyph_x2, glyph_y1); _cairo_gl_composite_emit_glyph_vertex (ctx, x2, y2, glyph_x2, glyph_y2); _cairo_gl_composite_emit_glyph_vertex (ctx, x1, y2, glyph_x1, glyph_y2); }
cairo_int_status_t _cairo_gl_composite_emit_quad_as_tristrip (cairo_gl_context_t *ctx, cairo_gl_composite_t *setup, const cairo_point_t quad[4]) { if (ctx->draw_mode != CAIRO_GL_VERTEX) { _cairo_gl_composite_flush (ctx); ctx->draw_mode = CAIRO_GL_VERTEX; } _cairo_gl_composite_prepare_buffer (ctx, 4, CAIRO_GL_PRIMITIVE_TYPE_TRISTRIPS); _cairo_gl_composite_emit_point (ctx, &quad[0], 0); _cairo_gl_composite_emit_point (ctx, &quad[1], 0); /* Cairo stores quad vertices in counter-clockwise order, but we need to emit them from top to bottom in the triangle strip, so we need to reverse the order of the last two vertices. */ _cairo_gl_composite_emit_point (ctx, &quad[3], 0); _cairo_gl_composite_emit_point (ctx, &quad[2], 0); return _cairo_gl_composite_append_vertex_indices (ctx, 4, TRUE); }
void _cairo_gl_composite_emit_rect (cairo_gl_context_t *ctx, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, uint8_t alpha) { if (ctx->draw_mode != CAIRO_GL_VERTEX) { _cairo_gl_composite_flush (ctx); ctx->draw_mode = CAIRO_GL_VERTEX; } _cairo_gl_composite_prepare_buffer (ctx, 6, CAIRO_GL_PRIMITIVE_TYPE_TRIANGLES); _cairo_gl_composite_emit_vertex (ctx, x1, y1, alpha); _cairo_gl_composite_emit_vertex (ctx, x2, y1, alpha); _cairo_gl_composite_emit_vertex (ctx, x1, y2, alpha); _cairo_gl_composite_emit_vertex (ctx, x2, y1, alpha); _cairo_gl_composite_emit_vertex (ctx, x2, y2, alpha); _cairo_gl_composite_emit_vertex (ctx, x1, y2, alpha); }