[cairo-commit] src/cairo-gl-glyphs.c src/cairo-gl-private.h src/cairo-gl-surface.c

Eric Anholt anholt at kemper.freedesktop.org
Sat Feb 6 05:11:42 PST 2010


 src/cairo-gl-glyphs.c  |   10 ++--------
 src/cairo-gl-private.h |    1 +
 src/cairo-gl-surface.c |    8 +++-----
 3 files changed, 6 insertions(+), 13 deletions(-)

New commits:
commit b028d287e6effe30833963f4df40db3846e7f4da
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Feb 5 07:25:04 2010 -0800

    [gl] Make the VBO once at startup instead of recreating per glyphs/spans.
    
    This shaves 2% off of firefox-talos-gfx.

diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c
index 00948d6..9e130d0 100644
--- a/src/cairo-gl-glyphs.c
+++ b/src/cairo-gl-glyphs.c
@@ -457,7 +457,6 @@ _render_glyphs (cairo_gl_surface_t	*dst,
     cairo_gl_composite_setup_t composite_setup;
     cairo_status_t status;
     int i = 0;
-    GLuint vbo = 0;
 
     *has_component_alpha = FALSE;
 
@@ -505,8 +504,7 @@ _render_glyphs (cairo_gl_surface_t	*dst,
     setup.op = op;
     setup.in = CAIRO_GL_SHADER_IN_COUNT; /* unset */
 
-    glGenBuffersARB (1, &vbo);
-    glBindBufferARB (GL_ARRAY_BUFFER_ARB, vbo);
+    glBindBufferARB (GL_ARRAY_BUFFER_ARB, ctx->vbo);
 
     glVertexPointer (2, GL_FLOAT, setup.vertex_size * sizeof (GLfloat),
 		     (void *)(uintptr_t)(0));
@@ -622,11 +620,7 @@ _render_glyphs (cairo_gl_surface_t	*dst,
     glDisable (GL_TEXTURE_2D);
     _cairo_gl_use_program (NULL);
 
-    if (vbo != 0) {
-	glBindBufferARB (GL_ARRAY_BUFFER_ARB, 0);
-	glDeleteBuffersARB (1, &vbo);
-    }
-
+    glBindBufferARB (GL_ARRAY_BUFFER_ARB, 0);
     _cairo_gl_context_release (ctx);
 
     _cairo_gl_operand_destroy (&composite_setup.src);
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index c544c91..6cd3ec8 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -119,6 +119,7 @@ typedef struct _cairo_gl_context {
 
     GLuint dummy_tex;
     GLuint texture_load_pbo;
+    GLuint vbo;
     GLint max_framebuffer_size;
     GLint max_texture_size;
     cairo_bool_t using_glsl;
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index 776043b..ae77463 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -139,6 +139,7 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
 
     /* PBO for any sort of texture upload */
     glGenBuffersARB (1, &ctx->texture_load_pbo);
+    glGenBuffersARB (1, &ctx->vbo);
 
     ctx->max_framebuffer_size = 0;
     glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &ctx->max_framebuffer_size);
@@ -2481,7 +2482,6 @@ typedef struct _cairo_gl_surface_span_renderer {
     cairo_gl_context_t *ctx;
     cairo_region_t *clip;
 
-    GLuint vbo;
     void *vbo_base;
     unsigned int vbo_size;
     unsigned int vbo_offset;
@@ -2525,10 +2525,9 @@ _cairo_gl_span_renderer_get_vbo (cairo_gl_surface_span_renderer_t *renderer,
 {
     unsigned int offset;
 
-    if (renderer->vbo == 0) {
+    if (renderer->vbo_size == 0) {
 	renderer->vbo_size = 16384;
-	glGenBuffersARB (1, &renderer->vbo);
-	glBindBufferARB (GL_ARRAY_BUFFER_ARB, renderer->vbo);
+	glBindBufferARB (GL_ARRAY_BUFFER_ARB, renderer->ctx->vbo);
 
 	if (renderer->setup.src.type == OPERAND_TEXTURE)
 	    renderer->vertex_size = 4 * sizeof (float) + sizeof (uint32_t);
@@ -2701,7 +2700,6 @@ _cairo_gl_surface_span_renderer_finish (void *abstract_renderer)
     _cairo_gl_span_renderer_flush (renderer);
 
     glBindBufferARB (GL_ARRAY_BUFFER_ARB, 0);
-    glDeleteBuffersARB (1, &renderer->vbo);
     glDisableClientState (GL_VERTEX_ARRAY);
     glDisableClientState (GL_COLOR_ARRAY);
 


More information about the cairo-commit mailing list