[cairo] [patch] gl: set tex_with in cairo_gl_gradient_t instead in cairo_entry.size
Henry (Yu) Song - SISA
hsong at sisa.samsung.com
Mon Nov 5 13:28:31 PST 2012
>From 18e714f260f18e6ae13979a289b6f7892d7f82c2 Mon Sep 17 00:00:00 2001
From: Henry Song <henry.song at samsung.com>
Date: Mon, 5 Nov 2012 13:16:18 -0800
Subject: [PATCH] gl: add tex_width in cairo_gl_gradient_t structure, there is
no need to set cache_entry.size to be tex_width, this makes
it unlikely overflows gradient cache
---
src/cairo-gl-gradient-private.h | 1 +
src/cairo-gl-gradient.c | 3 ++-
src/cairo-gl-operand.c | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/cairo-gl-gradient-private.h b/src/cairo-gl-gradient-private.h
index 77f9bbd..c76c7b2 100644
--- a/src/cairo-gl-gradient-private.h
+++ b/src/cairo-gl-gradient-private.h
@@ -69,6 +69,7 @@ typedef struct _cairo_gl_gradient {
cairo_reference_count_t ref_count;
cairo_device_t *device; /* NB: we don't hold a reference */
GLuint tex;
+ int tex_width;
unsigned int n_stops;
const cairo_gradient_stop_t *stops;
cairo_gradient_stop_t stops_embedded[1];
diff --git a/src/cairo-gl-gradient.c b/src/cairo-gl-gradient.c
index 1c1f972..3ceb3ed 100644
--- a/src/cairo-gl-gradient.c
+++ b/src/cairo-gl-gradient.c
@@ -258,7 +258,8 @@ _cairo_gl_gradient_create (cairo_gl_context_t *ctx,
CAIRO_REFERENCE_COUNT_INIT (&gradient->ref_count, 2);
gradient->cache_entry.hash = hash;
- gradient->cache_entry.size = tex_width;
+ gradient->cache_entry.size = sizeof (cairo_gl_gradient_t *);
+ gradient->tex_width = tex_width;
gradient->device = &ctx->base;
gradient->n_stops = n_stops;
gradient->stops = gradient->stops_embedded;
diff --git a/src/cairo-gl-operand.c b/src/cairo-gl-operand.c
index ee6c08e..e9191aa 100644
--- a/src/cairo-gl-operand.c
+++ b/src/cairo-gl-operand.c
@@ -686,7 +686,7 @@ _cairo_gl_operand_bind_to_shader (cairo_gl_context_t *ctx,
height = operand->texture.surface->height;
}
else {
- width = operand->gradient.gradient->cache_entry.size,
+ width = operand->gradient.gradient->tex_width,
height = 1;
}
strcpy (custom_part, "_texdims");
--
1.7.9.5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20121105/93e8dd01/attachment.html>
More information about the cairo
mailing list