1
0
Fork 0

MetaShapedTexture: Use a proper stride, calculated by cairo

This will help us when painting directly on to the mask texture with
cairo, which is needed for rounded corner AA.

https://bugzilla.gnome.org/show_bug.cgi?id=628195
This commit is contained in:
Jasper St. Pierre 2011-07-11 12:58:09 -04:00
parent 46415bb248
commit f83568fc4e

View file

@ -198,10 +198,13 @@ meta_shaped_texture_ensure_mask (MetaShapedTexture *stex)
guchar *mask_data; guchar *mask_data;
int i; int i;
int n_rects; int n_rects;
int stride;
GLenum paint_gl_target; GLenum paint_gl_target;
stride = cairo_format_stride_for_width (CAIRO_FORMAT_A8, tex_width);
/* Create data for an empty image */ /* Create data for an empty image */
mask_data = g_malloc0 (tex_width * tex_height); mask_data = g_malloc0 (stride * tex_height);
n_rects = cairo_region_num_rectangles (priv->shape_region); n_rects = cairo_region_num_rectangles (priv->shape_region);
@ -222,9 +225,9 @@ meta_shaped_texture_ensure_mask (MetaShapedTexture *stex)
y2 = CLAMP (y2, y1, (gint) tex_height); y2 = CLAMP (y2, y1, (gint) tex_height);
/* Fill the rectangle */ /* Fill the rectangle */
for (p = mask_data + y1 * tex_width + x1; for (p = mask_data + y1 * stride + x1;
y1 < y2; y1 < y2;
y1++, p += tex_width) y1++, p += stride)
memset (p, 255, x2 - x1); memset (p, 255, x2 - x1);
} }
@ -243,7 +246,7 @@ meta_shaped_texture_ensure_mask (MetaShapedTexture *stex)
/* internal cogl format */ /* internal cogl format */
COGL_PIXEL_FORMAT_A_8, COGL_PIXEL_FORMAT_A_8,
/* rowstride */ /* rowstride */
tex_width, stride,
mask_data); mask_data);
} }
else else
@ -252,7 +255,7 @@ meta_shaped_texture_ensure_mask (MetaShapedTexture *stex)
COGL_TEXTURE_NONE, COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_A_8, COGL_PIXEL_FORMAT_A_8,
COGL_PIXEL_FORMAT_ANY, COGL_PIXEL_FORMAT_ANY,
tex_width, stride,
mask_data); mask_data);
g_free (mask_data); g_free (mask_data);