[PATCH 2/3] gl: Track the VBO size as a property of the ctx

Bryce Harrington <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Change suggested by Chris Wilson.  This will enable setting different
vbo sizes for GL vs. EGL.

Signed-off-by: Bryce Harrington <[email protected]>
---
 src/cairo-gl-composite.c |    3 ++-
 src/cairo-gl-device.c    |    4 +++-
 src/cairo-gl-info.c      |   22 ++++++++++------------
 src/cairo-gl-private.h   |    3 ++-
 4 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/cairo-gl-composite.c b/src/cairo-gl-composite.c
index 65b0f26..b50f9a7 100644
--- a/src/cairo-gl-composite.c
+++ b/src/cairo-gl-composite.c
@@ -875,7 +875,8 @@ _cairo_gl_composite_prepare_buffer (cairo_gl_context_t *ctx,
 	ctx->primitive_type = primitive_type;
     }
 
-    if (ctx->vb_offset + n_vertices * ctx->vertex_size > _cairo_gl_get_vbo_size())
+    assert(ctx->vbo_size > 0);
+    if (ctx->vb_offset + n_vertices * ctx->vertex_size > ctx->vbo_size)
 	_cairo_gl_composite_flush (ctx);
 }
 
diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
index dc2b6d6..7235d9a 100644
--- a/src/cairo-gl-device.c
+++ b/src/cairo-gl-device.c
@@ -297,7 +297,9 @@ _cairo_gl_context_init (cairo_gl_context_t *ctx)
     if (unlikely (status))
         return status;
 
-    ctx->vb = malloc (_cairo_gl_get_vbo_size());
+    ctx->vbo_size = _cairo_gl_get_vbo_size();
+
+    ctx->vb = malloc (ctx->vbo_size);
     if (unlikely (ctx->vb == NULL)) {
 	    _cairo_cache_fini (&ctx->gradients);
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-gl-info.c b/src/cairo-gl-info.c
index c47033e..66b0b50 100644
--- a/src/cairo-gl-info.c
+++ b/src/cairo-gl-info.c
@@ -73,21 +73,19 @@ _cairo_gl_get_flavor (void)
     return flavor;
 }
 
-long
+unsigned long
 _cairo_gl_get_vbo_size (void)
 {
-    static long vbo_size = -1;
+    unsigned long vbo_size;
 
-    if (vbo_size < 0) {
-        const char *env = getenv ("CAIRO_GL_VBO_SIZE");
-        if (env == NULL) {
-            vbo_size = CAIRO_GL_VBO_SIZE_DEFAULT;
-	} else {
-	    errno = 0;
-	    vbo_size = strtol (env, NULL, 10);
-	    assert (errno == 0);
-	    assert (vbo_size > 0);
-	}
+    const char *env = getenv ("CAIRO_GL_VBO_SIZE");
+    if (env == NULL) {
+        vbo_size = CAIRO_GL_VBO_SIZE_DEFAULT;
+    } else {
+	errno = 0;
+	vbo_size = strtol (env, NULL, 10);
+	assert (errno == 0);
+	assert (vbo_size > 0);
     }
 
     return vbo_size;
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 79b67a5..c1104b6 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -362,6 +362,7 @@ struct _cairo_gl_context {
     cairo_gl_operand_t operands[2];
     cairo_bool_t spans;
 
+    unsigned int vbo_size;
     unsigned int vb_offset;
     unsigned int vertex_size;
     cairo_region_t *clip_region;
@@ -703,7 +704,7 @@ _cairo_gl_get_version (void);
 cairo_private cairo_gl_flavor_t
 _cairo_gl_get_flavor (void);
 
-cairo_private long
+cairo_private unsigned long
 _cairo_gl_get_vbo_size (void);
 
 cairo_private cairo_bool_t
-- 
1.7.9.5

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.