Store get_scanline() functions in the image struct
[profile/ivi/pixman.git] / pixman / pixman-image.c
1 /*
2  * Copyright © 2000 SuSE, Inc.
3  * Copyright © 2007 Red Hat, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and its
6  * documentation for any purpose is hereby granted without fee, provided that
7  * the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of SuSE not be used in advertising or
10  * publicity pertaining to distribution of the software without specific,
11  * written prior permission.  SuSE makes no representations about the
12  * suitability of this software for any purpose.  It is provided "as is"
13  * without express or implied warranty.
14  *
15  * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
17  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
19  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
30
31 #include "pixman-private.h"
32
33 #define Alpha(x) ((x) >> 24)
34
35 pixman_bool_t
36 _pixman_init_gradient (gradient_t     *gradient,
37                        const pixman_gradient_stop_t *stops,
38                        int             n_stops)
39 {
40     return_val_if_fail (n_stops > 0, FALSE);
41
42     gradient->stops = pixman_malloc_ab (n_stops, sizeof (pixman_gradient_stop_t));
43     if (!gradient->stops)
44         return FALSE;
45
46     memcpy (gradient->stops, stops, n_stops * sizeof (pixman_gradient_stop_t));
47
48     gradient->n_stops = n_stops;
49
50     gradient->stop_range = 0xffff;
51     gradient->color_table = NULL;
52     gradient->color_table_size = 0;
53     gradient->common.class = SOURCE_IMAGE_CLASS_UNKNOWN;
54
55     return TRUE;
56 }
57
58 pixman_image_t *
59 _pixman_image_allocate (void)
60 {
61     pixman_image_t *image = malloc (sizeof (pixman_image_t));
62
63     if (image)
64     {
65         image_common_t *common = &image->common;
66
67         pixman_region32_init (&common->full_region);
68         pixman_region32_init (&common->clip_region);
69         common->src_clip = &common->full_region;
70         common->has_client_clip = FALSE;
71         common->transform = NULL;
72         common->repeat = PIXMAN_REPEAT_NONE;
73         common->filter = PIXMAN_FILTER_NEAREST;
74         common->filter_params = NULL;
75         common->n_filter_params = 0;
76         common->alpha_map = NULL;
77         common->component_alpha = FALSE;
78         common->ref_count = 1;
79         common->read_func = NULL;
80         common->write_func = NULL;
81         common->classify = NULL;
82     }
83
84     return image;
85 }
86
87 source_pict_class_t
88 _pixman_image_classify (pixman_image_t *image,
89                         int             x,
90                         int             y,
91                         int             width,
92                         int             height)
93 {
94     if (image->common.classify)
95         return image->common.classify (image, x, y, width, height);
96     else
97         return SOURCE_IMAGE_CLASS_UNKNOWN;
98 }
99
100 #define READ_ACCESS(f) ((image->common.read_func)? f##_accessors : f)
101
102 static void fbFetchSolid(bits_image_t * image, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
103 {
104     uint32_t color;
105     uint32_t *end;
106     fetchPixelProc32 fetch = READ_ACCESS(pixman_fetchPixelProcForPicture32)(image);
107
108     color = fetch(image, 0, 0);
109
110     end = buffer + width;
111     while (buffer < end)
112         *(buffer++) = color;
113 }
114
115 static void fbFetchSolid64(bits_image_t * image, int x, int y, int width, uint64_t *buffer, void *unused, uint32_t unused2)
116 {
117     uint64_t color;
118     uint64_t *end;
119     fetchPixelProc64 fetch = READ_ACCESS(pixman_fetchPixelProcForPicture64)(image);
120
121     color = fetch(image, 0, 0);
122
123     end = buffer + width;
124     while (buffer < end)
125         *(buffer++) = color;
126 }
127
128 static void fbFetch(bits_image_t * image, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits)
129 {
130     fetchProc32 fetch = READ_ACCESS(pixman_fetchProcForPicture32)(image);
131
132     fetch(image, x, y, width, buffer);
133 }
134
135 static void fbFetch64(bits_image_t * image, int x, int y, int width, uint64_t *buffer, void *unused, uint32_t unused2)
136 {
137     fetchProc64 fetch = READ_ACCESS(pixman_fetchProcForPicture64)(image);
138
139     fetch(image, x, y, width, buffer);
140 }
141
142 static void
143 set_fetchers (pixman_image_t *image)
144 {
145     if (IS_SOURCE_IMAGE (image))
146     {
147         image->common.get_scanline_64 = (scanFetchProc)pixmanFetchSourcePict64;
148         image->common.get_scanline_32 = (scanFetchProc)pixmanFetchSourcePict;
149     }
150     else
151     {
152         bits_image_t *bits = (bits_image_t *)image;
153
154         if (bits->common.alpha_map)
155         {
156             image->common.get_scanline_64 =
157                 (scanFetchProc)READ_ACCESS(fbFetchExternalAlpha64);
158             image->common.get_scanline_32 =
159                 (scanFetchProc)READ_ACCESS(fbFetchExternalAlpha);
160         }
161         else if ((bits->common.repeat != PIXMAN_REPEAT_NONE) &&
162                  bits->width == 1 &&
163                  bits->height == 1)
164         {
165             image->common.get_scanline_64 = (scanFetchProc)fbFetchSolid64;
166             image->common.get_scanline_32 = (scanFetchProc)fbFetchSolid;
167         }
168         else if (!bits->common.transform &&
169                  bits->common.filter != PIXMAN_FILTER_CONVOLUTION &&
170                  bits->common.repeat != PIXMAN_REPEAT_PAD &&
171                  bits->common.repeat != PIXMAN_REPEAT_REFLECT)
172         {
173             image->common.get_scanline_64 = (scanFetchProc)fbFetch64;
174             image->common.get_scanline_32 = (scanFetchProc)fbFetch;
175         }
176         else
177         {
178             image->common.get_scanline_64 = (scanFetchProc)READ_ACCESS(fbFetchTransformed64);
179             image->common.get_scanline_32 = (scanFetchProc)READ_ACCESS(fbFetchTransformed);
180         }
181     }
182 }
183
184 scanFetchProc
185 _pixman_image_get_fetcher (pixman_image_t *image,
186                            int             wide)
187 {
188     set_fetchers (image);
189     if (wide)
190         return image->common.get_scanline_64;
191     else
192         return image->common.get_scanline_32;
193 }
194
195
196
197 #define WRITE_ACCESS(f) ((image->common.write_func)? f##_accessors : f)
198
199 static void
200 fbStore(bits_image_t * image, int x, int y, int width, uint32_t *buffer)
201 {
202     uint32_t *bits;
203     int32_t stride;
204     storeProc32 store = WRITE_ACCESS(pixman_storeProcForPicture32)(image);
205     const pixman_indexed_t * indexed = image->indexed;
206
207     bits = image->bits;
208     stride = image->rowstride;
209     bits += y*stride;
210     store((pixman_image_t *)image, bits, buffer, x, width, indexed);
211 }
212
213 static void
214 fbStore64(bits_image_t * image, int x, int y, int width, uint64_t *buffer)
215 {
216     uint32_t *bits;
217     int32_t stride;
218     storeProc64 store = WRITE_ACCESS(pixman_storeProcForPicture64)(image);
219     const pixman_indexed_t * indexed = image->indexed;
220
221     bits = image->bits;
222     stride = image->rowstride;
223     bits += y*stride;
224     store((pixman_image_t *)image, bits, buffer, x, width, indexed);
225 }
226
227 scanStoreProc
228 _pixman_image_get_storer (pixman_image_t *image,
229                           int             wide)
230 {
231     if (image->common.alpha_map)
232     {
233         if (wide)
234             return (scanStoreProc)WRITE_ACCESS(fbStoreExternalAlpha64);
235         else
236             return (scanStoreProc)WRITE_ACCESS(fbStoreExternalAlpha);
237     }
238     else
239     {
240         if (wide)
241             return (scanStoreProc)fbStore64;
242         else
243             return (scanStoreProc)fbStore;
244     }
245 }
246
247 static void
248 image_property_changed (pixman_image_t *image)
249 {
250     
251     
252     image->common.property_changed (image);
253 }
254
255 /* Ref Counting */
256 PIXMAN_EXPORT pixman_image_t *
257 pixman_image_ref (pixman_image_t *image)
258 {
259     image->common.ref_count++;
260
261     return image;
262 }
263
264 /* returns TRUE when the image is freed */
265 PIXMAN_EXPORT pixman_bool_t
266 pixman_image_unref (pixman_image_t *image)
267 {
268     image_common_t *common = (image_common_t *)image;
269
270     common->ref_count--;
271
272     if (common->ref_count == 0)
273     {
274         pixman_region32_fini (&common->clip_region);
275         pixman_region32_fini (&common->full_region);
276
277         if (common->transform)
278             free (common->transform);
279
280         if (common->filter_params)
281             free (common->filter_params);
282
283         if (common->alpha_map)
284             pixman_image_unref ((pixman_image_t *)common->alpha_map);
285
286 #if 0
287         if (image->type == BITS && image->bits.indexed)
288             free (image->bits.indexed);
289 #endif
290
291 #if 0
292         memset (image, 0xaa, sizeof (pixman_image_t));
293 #endif
294         if (image->type == LINEAR || image->type == RADIAL || image->type == CONICAL)
295         {
296             if (image->gradient.stops)
297                 free (image->gradient.stops);
298         }
299
300
301         if (image->type == BITS && image->bits.free_me)
302             free (image->bits.free_me);
303
304         free (image);
305
306         return TRUE;
307     }
308
309     return FALSE;
310 }
311
312 /* Constructors */
313
314 void
315 _pixman_image_reset_clip_region (pixman_image_t *image)
316 {
317     pixman_region32_fini (&image->common.clip_region);
318
319     if (image->type == BITS)
320     {
321         pixman_region32_init_rect (&image->common.clip_region, 0, 0,
322                                    image->bits.width, image->bits.height);
323     }
324     else
325     {
326         pixman_region32_init (&image->common.clip_region);
327     }
328 }
329
330 PIXMAN_EXPORT pixman_bool_t
331 pixman_image_set_clip_region32 (pixman_image_t *image,
332                                 pixman_region32_t *region)
333 {
334     image_common_t *common = (image_common_t *)image;
335     pixman_bool_t result;
336
337     if (region)
338     {
339         result = pixman_region32_copy (&common->clip_region, region);
340     }
341     else
342     {
343         _pixman_image_reset_clip_region (image);
344
345         result = TRUE;
346     }
347
348     image_property_changed (image);
349
350     return result;
351 }
352
353
354 PIXMAN_EXPORT pixman_bool_t
355 pixman_image_set_clip_region (pixman_image_t    *image,
356                               pixman_region16_t *region)
357 {
358     image_common_t *common = (image_common_t *)image;
359     pixman_bool_t result;
360
361     if (region)
362     {
363         result = pixman_region32_copy_from_region16 (&common->clip_region, region);
364     }
365     else
366     {
367         _pixman_image_reset_clip_region (image);
368
369         result = TRUE;
370     }
371
372     image_property_changed (image);
373
374     return result;
375 }
376
377 /* Sets whether the clip region includes a clip region set by the client
378  */
379 PIXMAN_EXPORT void
380 pixman_image_set_has_client_clip (pixman_image_t *image,
381                                   pixman_bool_t   client_clip)
382 {
383     image->common.has_client_clip = client_clip;
384
385     image_property_changed (image);
386 }
387
388 PIXMAN_EXPORT pixman_bool_t
389 pixman_image_set_transform (pixman_image_t           *image,
390                             const pixman_transform_t *transform)
391 {
392     static const pixman_transform_t id =
393     {
394         { { pixman_fixed_1, 0, 0 },
395           { 0, pixman_fixed_1, 0 },
396           { 0, 0, pixman_fixed_1 }
397         }
398     };
399
400     image_common_t *common = (image_common_t *)image;
401     pixman_bool_t result;
402
403     if (common->transform == transform)
404         return TRUE;
405
406     if (memcmp (&id, transform, sizeof (pixman_transform_t)) == 0)
407     {
408         free(common->transform);
409         common->transform = NULL;
410         result = TRUE;
411         goto out;
412     }
413
414     if (common->transform == NULL)
415         common->transform = malloc (sizeof (pixman_transform_t));
416
417     if (common->transform == NULL)
418     {
419         result = FALSE;
420         goto out;
421     }
422
423     memcpy(common->transform, transform, sizeof(pixman_transform_t));
424
425 out:
426     image_property_changed (image);
427     
428     return TRUE;
429 }
430
431 PIXMAN_EXPORT void
432 pixman_image_set_repeat (pixman_image_t  *image,
433                          pixman_repeat_t  repeat)
434 {
435     image->common.repeat = repeat;
436
437     image_property_changed (image);
438 }
439
440 PIXMAN_EXPORT pixman_bool_t
441 pixman_image_set_filter (pixman_image_t       *image,
442                          pixman_filter_t       filter,
443                          const pixman_fixed_t *params,
444                          int                   n_params)
445 {
446     image_common_t *common = (image_common_t *)image;
447     pixman_fixed_t *new_params;
448
449     if (params == common->filter_params && filter == common->filter)
450         return TRUE;
451
452     new_params = NULL;
453     if (params)
454     {
455         new_params = pixman_malloc_ab (n_params, sizeof (pixman_fixed_t));
456         if (!new_params)
457             return FALSE;
458
459         memcpy (new_params,
460                 params, n_params * sizeof (pixman_fixed_t));
461     }
462
463     common->filter = filter;
464
465     if (common->filter_params)
466         free (common->filter_params);
467
468     common->filter_params = new_params;
469     common->n_filter_params = n_params;
470
471     image_property_changed (image);
472     return TRUE;
473 }
474
475 PIXMAN_EXPORT void
476 pixman_image_set_source_clipping (pixman_image_t  *image,
477                                   pixman_bool_t    source_clipping)
478 {
479     image_common_t *common = &image->common;
480
481     if (source_clipping)
482         common->src_clip = &common->clip_region;
483     else
484         common->src_clip = &common->full_region;
485
486     image_property_changed (image);
487 }
488
489 /* Unlike all the other property setters, this function does not
490  * copy the content of indexed. Doing this copying is simply
491  * way, way too expensive.
492  */
493 PIXMAN_EXPORT void
494 pixman_image_set_indexed (pixman_image_t         *image,
495                           const pixman_indexed_t *indexed)
496 {
497     bits_image_t *bits = (bits_image_t *)image;
498
499     bits->indexed = indexed;
500
501     image_property_changed (image);
502 }
503
504 PIXMAN_EXPORT void
505 pixman_image_set_alpha_map (pixman_image_t *image,
506                             pixman_image_t *alpha_map,
507                             int16_t         x,
508                             int16_t         y)
509 {
510     image_common_t *common = (image_common_t *)image;
511
512     return_if_fail (!alpha_map || alpha_map->type == BITS);
513
514     if (common->alpha_map != (bits_image_t *)alpha_map)
515     {
516         if (common->alpha_map)
517             pixman_image_unref ((pixman_image_t *)common->alpha_map);
518
519         if (alpha_map)
520             common->alpha_map = (bits_image_t *)pixman_image_ref (alpha_map);
521         else
522             common->alpha_map = NULL;
523     }
524
525     common->alpha_origin.x = x;
526     common->alpha_origin.y = y;
527
528     image_property_changed (image);
529 }
530
531 PIXMAN_EXPORT void
532 pixman_image_set_component_alpha   (pixman_image_t       *image,
533                                     pixman_bool_t         component_alpha)
534 {
535     image->common.component_alpha = component_alpha;
536
537     image_property_changed (image);
538 }
539
540
541 PIXMAN_EXPORT void
542 pixman_image_set_accessors (pixman_image_t             *image,
543                             pixman_read_memory_func_t   read_func,
544                             pixman_write_memory_func_t  write_func)
545 {
546     return_if_fail (image != NULL);
547
548     image->common.read_func = read_func;
549     image->common.write_func = write_func;
550
551     image_property_changed (image);
552 }
553
554 PIXMAN_EXPORT uint32_t *
555 pixman_image_get_data (pixman_image_t *image)
556 {
557     if (image->type == BITS)
558         return image->bits.bits;
559
560     return NULL;
561 }
562
563 PIXMAN_EXPORT int
564 pixman_image_get_width (pixman_image_t *image)
565 {
566     if (image->type == BITS)
567         return image->bits.width;
568
569     return 0;
570 }
571
572 PIXMAN_EXPORT int
573 pixman_image_get_height (pixman_image_t *image)
574 {
575     if (image->type == BITS)
576         return image->bits.height;
577
578     return 0;
579 }
580
581 PIXMAN_EXPORT int
582 pixman_image_get_stride (pixman_image_t *image)
583 {
584     if (image->type == BITS)
585         return image->bits.rowstride * (int) sizeof (uint32_t);
586
587     return 0;
588 }
589
590 PIXMAN_EXPORT int
591 pixman_image_get_depth (pixman_image_t *image)
592 {
593     if (image->type == BITS)
594         return PIXMAN_FORMAT_DEPTH (image->bits.format);
595
596     return 0;
597 }
598
599 static uint32_t
600 color_to_uint32 (const pixman_color_t *color)
601 {
602     return
603         (color->alpha >> 8 << 24) |
604         (color->red >> 8 << 16) |
605         (color->green & 0xff00) |
606         (color->blue >> 8);
607 }
608
609 static pixman_bool_t
610 color_to_pixel (pixman_color_t *color,
611                 uint32_t       *pixel,
612                 pixman_format_code_t format)
613 {
614     uint32_t c = color_to_uint32 (color);
615
616     if (!(format == PIXMAN_a8r8g8b8     ||
617           format == PIXMAN_x8r8g8b8     ||
618           format == PIXMAN_a8b8g8r8     ||
619           format == PIXMAN_x8b8g8r8     ||
620           format == PIXMAN_b8g8r8a8     ||
621           format == PIXMAN_b8g8r8x8     ||
622           format == PIXMAN_r5g6b5       ||
623           format == PIXMAN_b5g6r5       ||
624           format == PIXMAN_a8))
625     {
626         return FALSE;
627     }
628
629     if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_ABGR)
630     {
631         c = ((c & 0xff000000) >>  0) |
632             ((c & 0x00ff0000) >> 16) |
633             ((c & 0x0000ff00) >>  0) |
634             ((c & 0x000000ff) << 16);
635     }
636     if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_BGRA)
637     {
638         c = ((c & 0xff000000) >> 24) |
639             ((c & 0x00ff0000) >>  8) |
640             ((c & 0x0000ff00) <<  8) |
641             ((c & 0x000000ff) << 24);
642     }
643
644     if (format == PIXMAN_a8)
645         c = c >> 24;
646     else if (format == PIXMAN_r5g6b5 ||
647              format == PIXMAN_b5g6r5)
648         c = cvt8888to0565 (c);
649
650 #if 0
651     printf ("color: %x %x %x %x\n", color->alpha, color->red, color->green, color->blue);
652     printf ("pixel: %x\n", c);
653 #endif
654
655     *pixel = c;
656     return TRUE;
657 }
658
659 PIXMAN_EXPORT pixman_bool_t
660 pixman_image_fill_rectangles (pixman_op_t                   op,
661                               pixman_image_t               *dest,
662                               pixman_color_t               *color,
663                               int                           n_rects,
664                               const pixman_rectangle16_t   *rects)
665 {
666     pixman_image_t *solid;
667     pixman_color_t c;
668     int i;
669
670     if (color->alpha == 0xffff)
671     {
672         if (op == PIXMAN_OP_OVER)
673             op = PIXMAN_OP_SRC;
674     }
675
676     if (op == PIXMAN_OP_CLEAR)
677     {
678         c.red = 0;
679         c.green = 0;
680         c.blue = 0;
681         c.alpha = 0;
682
683         color = &c;
684
685         op = PIXMAN_OP_SRC;
686     }
687
688     if (op == PIXMAN_OP_SRC)
689     {
690         uint32_t pixel;
691
692         if (color_to_pixel (color, &pixel, dest->bits.format))
693         {
694             for (i = 0; i < n_rects; ++i)
695             {
696                 pixman_region32_t fill_region;
697                 int n_boxes, j;
698                 pixman_box32_t *boxes;
699
700                 pixman_region32_init_rect (&fill_region, rects[i].x, rects[i].y, rects[i].width, rects[i].height);
701                 if (!pixman_region32_intersect (&fill_region,
702                                                 &fill_region,
703                                                 &dest->common.clip_region))
704                     return FALSE;
705
706
707                 boxes = pixman_region32_rectangles (&fill_region, &n_boxes);
708                 for (j = 0; j < n_boxes; ++j)
709                 {
710                     const pixman_box32_t *box = &(boxes[j]);
711                     pixman_fill (dest->bits.bits, dest->bits.rowstride, PIXMAN_FORMAT_BPP (dest->bits.format),
712                                  box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1,
713                                  pixel);
714                 }
715
716                 pixman_region32_fini (&fill_region);
717             }
718             return TRUE;
719         }
720     }
721
722     solid = pixman_image_create_solid_fill (color);
723     if (!solid)
724         return FALSE;
725
726     for (i = 0; i < n_rects; ++i)
727     {
728         const pixman_rectangle16_t *rect = &(rects[i]);
729
730         pixman_image_composite (op, solid, NULL, dest,
731                                 0, 0, 0, 0,
732                                 rect->x, rect->y,
733                                 rect->width, rect->height);
734     }
735
736     pixman_image_unref (solid);
737
738     return TRUE;
739 }
740
741 pixman_bool_t
742 pixman_image_can_get_solid (pixman_image_t *image)
743 {
744     if (image->type == SOLID)
745         return TRUE;
746
747     if (image->type != BITS     ||
748         image->bits.width != 1  ||
749         image->bits.height != 1)
750     {
751         return FALSE;
752     }
753
754     if (image->common.repeat != PIXMAN_REPEAT_NORMAL)
755         return FALSE;
756
757     switch (image->bits.format)
758     {
759     case PIXMAN_a8r8g8b8:
760     case PIXMAN_x8r8g8b8:
761     case PIXMAN_a8b8g8r8:
762     case PIXMAN_x8b8g8r8:
763     case PIXMAN_b8g8r8a8:
764     case PIXMAN_b8g8r8x8:
765     case PIXMAN_r8g8b8:
766     case PIXMAN_b8g8r8:
767     case PIXMAN_r5g6b5:
768     case PIXMAN_b5g6r5:
769         return TRUE;
770     default:
771         return FALSE;
772     }
773 }
774
775 pixman_bool_t
776 pixman_image_is_opaque(pixman_image_t *image)
777 {
778     int i = 0;
779     int gradientNumberOfColors = 0;
780
781     if(image->common.alpha_map)
782         return FALSE;
783
784     switch(image->type)
785     {
786     case BITS:
787         if(PIXMAN_FORMAT_A(image->bits.format))
788             return FALSE;
789         break;
790
791     case LINEAR:
792     case CONICAL:
793     case RADIAL:
794         gradientNumberOfColors = image->gradient.n_stops;
795         i=0;
796         while(i<gradientNumberOfColors)
797         {
798             if(image->gradient.stops[i].color.alpha != 0xffff)
799                 return FALSE;
800             i++;
801         }
802         break;
803
804     case SOLID:
805          if(Alpha(image->solid.color) != 0xff)
806             return FALSE;
807         break;
808     }
809
810     /* Convolution filters can introduce translucency if the sum of the weights
811        is lower than 1. */
812     if (image->common.filter == PIXMAN_FILTER_CONVOLUTION)
813          return FALSE;
814
815     if (image->common.repeat == PIXMAN_REPEAT_NONE)
816     {
817         if (image->common.filter != PIXMAN_FILTER_NEAREST)
818             return FALSE;
819
820         if (image->common.transform)
821             return FALSE;
822
823         /* Gradients do not necessarily cover the entire compositing area */
824         if (image->type == LINEAR || image->type == CONICAL || image->type == RADIAL)
825             return FALSE;
826     }
827
828      return TRUE;
829 }