]> git.pld-linux.org Git - packages/cairo.git/blame - cairo-glitz.patch
- updated to 0.2.0 (License is LGPL v2.1/MPL v1.1 now)
[packages/cairo.git] / cairo-glitz.patch
CommitLineData
25625c4c
JB
1===================================================================
2RCS file: /cvs/cairo/cairo/src/cairo_gl_surface.c,v
3retrieving revision 1.8
4retrieving revision 1.9
5diff -u -r1.8 -r1.9
6--- cairo/src/cairo_gl_surface.c 2004/05/11 12:31:16 1.8
7+++ cairo/src/cairo_gl_surface.c 2004/05/24 09:28:05 1.9
8@@ -321,15 +321,27 @@
9 static cairo_surface_t *
10 _cairo_gl_surface_create_similar (void *abstract_src,
11 cairo_format_t format,
12+ int drawable,
13 int width,
14 int height)
15 {
16 cairo_gl_surface_t *src = abstract_src;
17 glitz_surface_t *surface;
18 cairo_surface_t *crsurface;
19+ glitz_format_t *glitz_format;
20+ unsigned long option_mask;
21+
22+ option_mask = GLITZ_FORMAT_OPTION_OFFSCREEN_MASK;
23+ if (!drawable)
24+ option_mask |= GLITZ_FORMAT_OPTION_READONLY_MASK;
25+
26+ glitz_format =
27+ glitz_surface_find_similar_standard_format (src->surface, option_mask,
28+ _glitz_format (format));
29+ if (glitz_format == NULL)
30+ return NULL;
31
32- surface = glitz_surface_create_similar (src->surface,
33- _glitz_format (format),
34+ surface = glitz_surface_create_similar (src->surface, glitz_format,
35 width, height);
36 if (surface == NULL)
37 return NULL;
38@@ -352,7 +364,7 @@
39 src_image = _cairo_surface_get_image (src);
40
41 clone = (cairo_gl_surface_t *)
42- _cairo_gl_surface_create_similar (template, format,
43+ _cairo_gl_surface_create_similar (template, format, 0,
44 src_image->width,
45 src_image->height);
46 if (clone == NULL)
47===================================================================
48RCS file: /cvs/cairo/cairo/src/cairo_gl_surface.c,v
49retrieving revision 1.10
50retrieving revision 1.11
51diff -u -r1.10 -r1.11
52--- cairo/src/cairo_gl_surface.c 2004/06/11 15:08:27 1.10
53+++ cairo/src/cairo_gl_surface.c 2004/06/21 22:13:52 1.11
54@@ -132,6 +132,7 @@
55 int width, height;
56 int rowstride;
57 cairo_format_masks_t format;
58+ glitz_pixel_format_t pf;
59
60 if (surface->hints & GLITZ_HINT_PROGRAMMATIC_MASK)
61 return _cairo_pattern_get_image (&surface->pattern,
62@@ -140,23 +141,49 @@
63 width = glitz_surface_get_width (surface->surface);
64 height = glitz_surface_get_height (surface->surface);
65
66- rowstride = (width * (surface->format->bpp / 8) + 3) & -4;
67-
68- pixels = (char *) malloc (sizeof (char) * height * rowstride);
69-
70- glitz_surface_read_pixels (surface->surface, 0, 0, width, height, pixels);
71-
72- format.bpp = surface->format->bpp;
73- format.red_mask = surface->format->red_mask;
74- format.green_mask = surface->format->green_mask;
75- format.blue_mask = surface->format->blue_mask;
76- format.alpha_mask = surface->format->alpha_mask;
77+ if (surface->format->red_size > 0) {
78+ format.bpp = 32;
79+
80+ if (surface->format->alpha_size > 0)
81+ format.alpha_mask = 0xff000000;
82+ else
83+ format.alpha_mask = 0x0;
84+
85+ format.red_mask = 0xff0000;
86+ format.green_mask = 0xff00;
87+ format.blue_mask = 0xff;
88+ } else {
89+ format.bpp = 8;
90+ format.blue_mask = format.green_mask = format.red_mask = 0x0;
91+ format.alpha_mask = 0xff;
92+ }
93+
94+ rowstride = (((width * format.bpp) / 8) + 3) & -4;
95+
96+ pf.masks.bpp = format.bpp;
97+ pf.masks.alpha_mask = format.alpha_mask;
98+ pf.masks.red_mask = format.red_mask;
99+ pf.masks.green_mask = format.green_mask;
100+ pf.masks.blue_mask = format.blue_mask;
101+ pf.xoffset = 0;
102+ pf.bytes_per_line = rowstride;
103+ pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
104
105+ pixels = (char *) malloc (height * rowstride);
106+ if (!pixels)
107+ return NULL;
108+
109+ glitz_get_pixels (surface->surface,
110+ 0, 0,
111+ width, height,
112+ &pf,
113+ pixels);
114+
115 image = (cairo_image_surface_t *)
116 _cairo_image_surface_create_with_masks (pixels,
117 &format,
118 width, height, rowstride);
119-
120+
121 _cairo_image_surface_assume_ownership_of_data (image);
122
123 _cairo_image_surface_set_repeat (image, surface->base.repeat);
124@@ -170,10 +197,35 @@
125 cairo_image_surface_t *image)
126 {
127 cairo_gl_surface_t *surface = abstract_surface;
128+ glitz_pixel_format_t pf;
129
130- glitz_surface_draw_pixels (surface->surface, 0, 0,
131- image->width, image->height, image->data);
132-
133+ if (image->depth > 8) {
134+ pf.masks.bpp = 32;
135+
136+ if (surface->format->alpha_size)
137+ pf.masks.alpha_mask = 0xff000000;
138+ else
139+ pf.masks.alpha_mask = 0x0;
140+
141+ pf.masks.red_mask = 0xff0000;
142+ pf.masks.green_mask = 0xff00;
143+ pf.masks.blue_mask = 0xff;
144+ } else {
145+ pf.masks.bpp = 8;
146+ pf.masks.alpha_mask = 0xff;
147+ pf.masks.red_mask = pf.masks.green_mask = pf.masks.blue_mask = 0x0;
148+ }
149+
150+ pf.xoffset = 0;
151+ pf.bytes_per_line = (((image->width * pf.masks.bpp) / 8) + 3) & -4;
152+ pf.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
153+
154+ glitz_put_pixels (surface->surface,
155+ 0, 0,
156+ image->width, image->height,
157+ &pf,
158+ image->data);
159+
160 return CAIRO_STATUS_SUCCESS;
161 }
162
163@@ -208,9 +260,9 @@
164 {
165 static glitz_convolution_t gaussian = {
166 {
167- {0, 1 << 16, 0},
168- {1 << 16, 4 << 16, 1 << 16},
169- {0, 1 << 16, 0}
170+ { 0, 1 << 16, 0 },
171+ { 1 << 16, 4 << 16, 1 << 16 },
172+ { 0, 1 << 16, 0 }
173 }
174 };
175 cairo_gl_surface_t *surface = abstract_surface;
176@@ -332,9 +384,13 @@
177 cairo_surface_t *crsurface;
178 glitz_format_t *glitz_format;
179 unsigned long option_mask;
180+ glitz_format_name_t format_name = _glitz_format (format);
181
182 option_mask = GLITZ_FORMAT_OPTION_OFFSCREEN_MASK;
183- if (!drawable)
184+
185+ if (drawable)
186+ option_mask |= GLITZ_FORMAT_OPTION_READDRAW_MASK;
187+ else
188 option_mask |= GLITZ_FORMAT_OPTION_READONLY_MASK;
189
190 if (src->format->multisample.samples < 2)
191@@ -342,7 +398,15 @@
192
193 glitz_format =
194 glitz_surface_find_similar_standard_format (src->surface, option_mask,
195- _glitz_format (format));
196+ format_name);
197+ if (glitz_format == NULL) {
198+ option_mask &= ~GLITZ_FORMAT_OPTION_READDRAW_MASK;
199+ glitz_format =
200+ glitz_surface_find_similar_standard_format (src->surface,
201+ option_mask,
202+ format_name);
203+ }
204+
205 if (glitz_format == NULL)
206 return NULL;
207
208@@ -638,17 +696,6 @@
209 }
210
211 static void
212-_cario_gl_uint_to_power_of_two (unsigned int *value)
213-{
214- unsigned int x = 1;
215-
216- while (x < *value)
217- x <<= 1;
218-
219- *value = x;
220-}
221-
222-static void
223 _cairo_gl_create_color_range (cairo_pattern_t *pattern,
224 unsigned char *data,
225 unsigned int size)
226@@ -684,10 +731,17 @@
227
228 source = glitz_surface_create_solid (&color);
229 } break;
230- case CAIRO_PATTERN_LINEAR:
231- case CAIRO_PATTERN_RADIAL: {
232- unsigned int color_range_size;
233+ case CAIRO_PATTERN_RADIAL:
234+ /* glitz doesn't support inner circle yet. */
235+ if (pattern->u.radial.center0.x != pattern->u.radial.center1.x ||
236+ pattern->u.radial.center0.y != pattern->u.radial.center1.y)
237+ return CAIRO_INT_STATUS_UNSUPPORTED;
238+ /* fall-through */
239+ case CAIRO_PATTERN_LINEAR: {
240+ int color_range_size;
241 glitz_color_range_t *color_range;
242+ int width = ((box->p2.x + 65535) >> 16) - (box->p1.x >> 16);
243+ int height = ((box->p2.y + 65535) >> 16) - (box->p1.y >> 16);
244
245 if (!CAIRO_GL_FRAGMENT_PROGRAM_SUPPORT (surface))
246 return CAIRO_INT_STATUS_UNSUPPORTED;
247@@ -698,26 +752,17 @@
248 if (pattern->extend == CAIRO_EXTEND_REFLECT &&
249 (!CAIRO_GL_TEXTURE_MIRRORED_REPEAT_SUPPORT (surface)))
250 return CAIRO_INT_STATUS_UNSUPPORTED;
251-
252- if (pattern->type == CAIRO_PATTERN_LINEAR) {
253- double dx, dy;
254-
255- dx = pattern->u.linear.point1.x - pattern->u.linear.point0.x;
256- dy = pattern->u.linear.point1.y - pattern->u.linear.point0.y;
257-
258- color_range_size = sqrt (dx * dx + dy * dy);
259- } else {
260- /* glitz doesn't support inner circle yet. */
261- if (pattern->u.radial.center0.x != pattern->u.radial.center1.x ||
262- pattern->u.radial.center0.y != pattern->u.radial.center1.y)
263- return CAIRO_INT_STATUS_UNSUPPORTED;
264-
265- color_range_size = pattern->u.radial.radius1;
266- }
267-
268- if ((!CAIRO_GL_TEXTURE_NPOT_SUPPORT (surface)))
269- _cario_gl_uint_to_power_of_two (&color_range_size);
270-
271+
272+ /* TODO: how do we figure out the color range resolution? transforming
273+ the gradient vector with the inverse of the pattern matrix should
274+ give us a good hint. */
275+ color_range_size = 512;
276+
277+ /* destination surface size less than color range size, an image
278+ gradient is probably more efficient. */
279+ if ((width * height) <= color_range_size)
280+ return CAIRO_INT_STATUS_UNSUPPORTED;
281+
282 color_range = glitz_color_range_create (color_range_size);
283 if (!color_range)
284 return CAIRO_STATUS_NO_MEMORY;
285@@ -725,7 +770,9 @@
286 _cairo_gl_create_color_range (pattern,
287 glitz_color_range_get_data (color_range),
288 color_range_size);
289-
290+
291+ glitz_color_range_put_back_data (color_range);
292+
293 switch (pattern->extend) {
294 case CAIRO_EXTEND_REPEAT:
295 glitz_color_range_set_extend (color_range, GLITZ_EXTEND_REPEAT);
This page took 3.030561 seconds and 4 git commands to generate.