gl: do not force flush everytime uploading a glyph image to glyph cache

In normal cases, we want to flush pending operations reading from the
texture before modifying its contents.  However during uploading of
glyphs into the glyph cache, we repeatedly modify the texture as we
construct the vbo (whilst referencing it for that operation). We track
unused areas in the glyph cache so that if we run out of space, we can
explicitly flush the pending glyphs and start afresh and avoid having to
flush the operation in common case.
This commit is contained in:
Henry Song 2013-01-29 17:53:38 +00:00 committed by Chris Wilson
parent 260c16331a
commit 4cb181d985
6 changed files with 24 additions and 15 deletions

View file

@ -134,7 +134,7 @@ _cairo_gl_glyph_cache_add_glyph (cairo_gl_context_t *ctx,
status = _cairo_gl_surface_draw_image (cache->surface, glyph_surface,
0, 0,
glyph_surface->width, glyph_surface->height,
node->x, node->y);
node->x, node->y, FALSE);
if (unlikely (status))
return status;

View file

@ -437,7 +437,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
cairo_image_surface_t *src,
int src_x, int src_y,
int width, int height,
int dst_x, int dst_y);
int dst_x, int dst_y,
cairo_bool_t force_flush);
static cairo_always_inline cairo_bool_t
_cairo_gl_device_has_glsl (cairo_device_t *device)

View file

@ -311,7 +311,7 @@ draw_image_boxes (void *_dst,
status = _cairo_gl_surface_draw_image (dst, image,
x + dx, y + dy,
w, h,
x, y);
x, y, TRUE);
if (unlikely (status))
return status;
}

View file

@ -77,7 +77,8 @@ _cairo_gl_surface_release_dest_image (void *abstract_surface,
status = _cairo_gl_surface_draw_image (abstract_surface, image,
0, 0,
image->width, image->height,
image_rect->x, image_rect->y);
image_rect->x, image_rect->y,
TRUE);
/* as we created the image, its format should be directly applicable */
assert (status == CAIRO_STATUS_SUCCESS);
@ -126,7 +127,7 @@ _cairo_gl_surface_clone_similar (void *abstract_surface,
status = _cairo_gl_surface_draw_image (clone, image_src,
src_x, src_y,
width, height,
0, 0);
0, 0, TRUE);
if (status) {
cairo_surface_destroy (&clone->base);
return status;
@ -236,7 +237,7 @@ _cairo_gl_surface_composite (cairo_operator_t op,
status = _cairo_gl_surface_draw_image (dst, image,
dx, dy,
width, height,
dst_x, dst_y);
dst_x, dst_y, TRUE);
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
return status;
}

View file

@ -840,7 +840,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
cairo_image_surface_t *src,
int src_x, int src_y,
int width, int height,
int dst_x, int dst_y)
int dst_x, int dst_y,
cairo_bool_t force_flush)
{
GLenum internal_format, format, type;
cairo_bool_t has_alpha, needs_swap;
@ -882,9 +883,11 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
cpp = PIXMAN_FORMAT_BPP (src->pixman_format) / 8;
status = _cairo_gl_surface_flush (&dst->base, 0);
if (unlikely (status))
goto FAIL;
if (force_flush) {
status = _cairo_gl_surface_flush (&dst->base, 0);
if (unlikely (status))
goto FAIL;
}
if (_cairo_gl_surface_is_texture (dst)) {
void *data_start = src->data + src_y * src->stride + src_x * cpp;
@ -951,7 +954,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
src,
src_x, src_y,
width, height,
0, 0);
0, 0, force_flush);
if (status == CAIRO_INT_STATUS_SUCCESS) {
cairo_surface_pattern_t tmp_pattern;
cairo_rectangle_int_t r;
@ -1231,7 +1234,8 @@ _cairo_gl_surface_unmap_image (void *abstract_surface,
0, 0,
image->width, image->height,
image->base.device_transform_inverse.x0,
image->base.device_transform_inverse.y0);
image->base.device_transform_inverse.y0,
TRUE);
cairo_surface_finish (&image->base);
cairo_surface_destroy (&image->base);

View file

@ -96,7 +96,8 @@ draw_image_boxes (void *_dst,
status = _cairo_gl_surface_draw_image (dst, image,
x + dx, y + dy,
w, h,
x, y);
x, y,
TRUE);
if (unlikely (status))
return status;
}
@ -345,7 +346,8 @@ traps_to_operand (void *_dst,
(cairo_image_surface_t *)image,
0, 0,
extents->width, extents->height,
0, 0);
0, 0,
TRUE);
cairo_surface_destroy (image);
if (unlikely (status))
@ -456,7 +458,8 @@ tristrip_to_surface (void *_dst,
(cairo_image_surface_t *)image,
0, 0,
extents->width, extents->height,
0, 0);
0, 0,
TRUE);
cairo_surface_destroy (image);
if (unlikely (status)) {
cairo_surface_destroy (mask);