diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-15 14:28:44 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-23 12:53:27 +0100 |
commit | 054f34111d220541bc785b30207387541fdd31d2 (patch) | |
tree | 433f3b223c69ecc08752286a8f4640da469fe2a9 | |
parent | 95f320e3f26b2a1552a53ebad14dd5086ccf0c60 (diff) |
Provide backwards compatibilty with old pixman
The goal is to allow compilation against older pixman to ease regression
testing.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/Makefile.sources | 1 | ||||
-rw-r--r-- | src/cairo-ft-font.c | 6 | ||||
-rw-r--r-- | src/cairo-image-compositor.c | 44 | ||||
-rw-r--r-- | src/cairo-image-surface.c | 5 | ||||
-rw-r--r-- | src/cairo-pixman-private.h | 45 | ||||
-rw-r--r-- | src/cairo-xlib-render-compositor.c | 1 | ||||
-rw-r--r-- | src/cairo-xlib-surface.c | 1 |
8 files changed, 86 insertions, 19 deletions
diff --git a/configure.ac b/configure.ac index c08dbb296..fd54ad1e3 100644 --- a/configure.ac +++ b/configure.ac @@ -656,7 +656,7 @@ CAIRO_ENABLE(test_surfaces, test surfaces, no) dnl =========================================================================== CAIRO_ENABLE_SURFACE_BACKEND(image, image, always, [ - pixman_REQUIRES="pixman-1 >= 0.22.0" + pixman_REQUIRES="pixman-1 >= 0.16.0" PKG_CHECK_MODULES(pixman, $pixman_REQUIRES, , [use_image="no (requires $pixman_REQUIRES http://cairographics.org/releases/)"]) image_REQUIRES=$pixman_REQUIRES diff --git a/src/Makefile.sources b/src/Makefile.sources index 4abf57dfb..2e14fff8a 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -99,6 +99,7 @@ cairo_private = \ cairo-path-private.h \ cairo-pattern-inline.h \ cairo-pattern-private.h \ + cairo-pixman-private.h \ cairo-private.h \ cairo-recording-surface-inline.h \ cairo-recording-surface-private.h \ diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 0dfe9bea6..9f4b5244d 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -45,6 +45,7 @@ #include "cairo-image-surface-private.h" #include "cairo-ft-private.h" #include "cairo-pattern-private.h" +#include "cairo-pixman-private.h" #include <float.h> @@ -1126,9 +1127,10 @@ _get_bitmap_surface (FT_Bitmap *bitmap, cairo_font_options_t *font_options, cairo_image_surface_t **surface) { - int width, height, stride; + unsigned int width, height; unsigned char *data; int format = CAIRO_FORMAT_A8; + int stride; cairo_image_surface_t *image; cairo_bool_t component_alpha = FALSE; @@ -1599,7 +1601,7 @@ _transform_glyph_bitmap (cairo_matrix_t * shape, if (unlikely (status)) return status; - if (cairo_image_surface_get_format (*surface) == CAIRO_FORMAT_ARGB32 && + if ((*surface)->format == CAIRO_FORMAT_ARGB32 && !pixman_image_get_component_alpha ((*surface)->pixman_image)) image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); else diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c index 824588208..d0c4dd971 100644 --- a/src/cairo-image-compositor.c +++ b/src/cairo-image-compositor.c @@ -52,6 +52,8 @@ #include "cairo-traps-private.h" #include "cairo-tristrip-private.h" +#include "cairo-pixman-private.h" + static pixman_image_t * to_pixman_image (cairo_surface_t *s) { @@ -256,9 +258,9 @@ _pixman_operator (cairo_operator_t op) } static cairo_bool_t -fill_reduces_to_source (cairo_operator_t op, - const cairo_color_t *color, - cairo_image_surface_t *dst) +__fill_reduces_to_source (cairo_operator_t op, + const cairo_color_t *color, + const cairo_image_surface_t *dst) { if (op == CAIRO_OPERATOR_SOURCE || op == CAIRO_OPERATOR_CLEAR) return TRUE; @@ -270,6 +272,20 @@ fill_reduces_to_source (cairo_operator_t op, return FALSE; } +static cairo_bool_t +fill_reduces_to_source (cairo_operator_t op, + const cairo_color_t *color, + const cairo_image_surface_t *dst, + uint32_t *pixel) +{ + if (__fill_reduces_to_source (op, color, dst)) { + color_to_pixel (color, dst->pixman_format, pixel); + return TRUE; + } + + return FALSE; +} + static cairo_int_status_t fill_rectangles (void *_dst, cairo_operator_t op, @@ -283,9 +299,7 @@ fill_rectangles (void *_dst, TRACE ((stderr, "%s\n", __FUNCTION__)); - if (fill_reduces_to_source (op, color, dst) && - color_to_pixel (color, dst->pixman_format, &pixel)) - { + if (fill_reduces_to_source (op, color, dst, &pixel)) { for (i = 0; i < num_rects; i++) { pixman_fill ((uint32_t *) dst->data, dst->stride / sizeof (uint32_t), PIXMAN_FORMAT_BPP (dst->pixman_format), @@ -293,9 +307,7 @@ fill_rectangles (void *_dst, rects[i].width, rects[i].height, pixel); } - } - else - { + } else { pixman_image_t *src = _pixman_image_for_color (color); op = _pixman_operator (op); @@ -327,9 +339,7 @@ fill_boxes (void *_dst, TRACE ((stderr, "%s x %d\n", __FUNCTION__, boxes->num_boxes)); - if (fill_reduces_to_source (op, color, dst) && - color_to_pixel (color, dst->pixman_format, &pixel)) - { + if (fill_reduces_to_source (op, color, dst, &pixel)) { for (chunk = &boxes->chunks; chunk; chunk = chunk->next) { for (i = 0; i < chunk->count; i++) { int x = _cairo_fixed_integer_part (chunk->base[i].p1.x); @@ -674,6 +684,7 @@ composite_traps (void *_dst, return CAIRO_STATUS_SUCCESS; } +#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0) static void set_point (pixman_point_fixed_t *p, cairo_point_t *c) { @@ -749,6 +760,7 @@ composite_tristrip (void *_dst, return CAIRO_STATUS_SUCCESS; } +#endif static cairo_int_status_t check_composite_glyphs (const cairo_composite_rectangles_t *extents, @@ -1215,7 +1227,9 @@ _cairo_image_traps_compositor_get (void) //compositor.check_composite_traps = check_composite_traps; compositor.composite_traps = composite_traps; //compositor.check_composite_tristrip = check_composite_traps; +#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0) compositor.composite_tristrip = composite_tristrip; +#endif compositor.check_composite_glyphs = check_composite_glyphs; compositor.composite_glyphs = composite_glyphs; } @@ -2010,8 +2024,7 @@ mono_renderer_init (cairo_image_span_renderer_t *r, if (composite->op == CAIRO_OPERATOR_CLEAR) color = CAIRO_COLOR_TRANSPARENT; - if (fill_reduces_to_source (composite->op, color, dst) && - color_to_pixel (color, dst->pixman_format, &r->u.fill.pixel)) { + if (fill_reduces_to_source (composite->op, color, dst, &r->u.fill.pixel)) { /* Use plain C for the fill operations as the span length is * typically small, too small to payback the startup overheads of * using SSE2 etc. @@ -2755,8 +2768,7 @@ inplace_renderer_init (cairo_image_span_renderer_t *r, if (composite->op == CAIRO_OPERATOR_CLEAR) color = CAIRO_COLOR_TRANSPARENT; - if (fill_reduces_to_source (composite->op, color, dst) && - color_to_pixel (color, dst->pixman_format, &r->u.fill.pixel)) { + if (fill_reduces_to_source (composite->op, color, dst, &r->u.fill.pixel)) { /* Use plain C for the fill operations as the span length is * typically small, too small to payback the startup overheads of * using SSE2 etc. diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 98d928f48..5390d4a37 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -48,6 +48,7 @@ #include "cairo-image-surface-inline.h" #include "cairo-paginated-private.h" #include "cairo-pattern-private.h" +#include "cairo-pixman-private.h" #include "cairo-recording-surface-private.h" #include "cairo-region-private.h" #include "cairo-scaled-font-private.h" @@ -103,7 +104,9 @@ _cairo_format_from_pixman_format (pixman_format_code_t pixman_format) return CAIRO_FORMAT_A1; case PIXMAN_r5g6b5: return CAIRO_FORMAT_RGB16_565; +#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0) case PIXMAN_r8g8b8a8: case PIXMAN_r8g8b8x8: +#endif case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: case PIXMAN_r8g8b8: case PIXMAN_b8g8r8: case PIXMAN_b5g6r5: case PIXMAN_a1r5g5b5: case PIXMAN_x1r5g5b5: case PIXMAN_a1b5g5r5: @@ -120,7 +123,9 @@ _cairo_format_from_pixman_format (pixman_format_code_t pixman_format) case PIXMAN_a2b10g10r10: case PIXMAN_x2b10g10r10: case PIXMAN_a2r10g10b10: +#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0) case PIXMAN_x14r6g6b6: +#endif default: return CAIRO_FORMAT_INVALID; } diff --git a/src/cairo-pixman-private.h b/src/cairo-pixman-private.h new file mode 100644 index 000000000..13ec82e2f --- /dev/null +++ b/src/cairo-pixman-private.h @@ -0,0 +1,45 @@ +/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */ +/* cairo - a vector graphics library with display and print output + * + * Copyright ©2013 Intel Corporation + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + * + * The Original Code is the cairo graphics library. + * + * The Initial Developer of the Original Code is University of Southern + * California. + * + * Contributor(s): + * Chris Wilson <chris@chris-wilson.co.uk> + */ + +#include <pixman.h> + +#if PIXMAN_VERSION < PIXMAN_VERSION_ENCODE(0,22,0) +#define pixman_image_composite32 pixman_image_composite +#define pixman_image_get_component_alpha(i) 0 +#define pixman_image_set_component_alpha(i, x) do { } while (0) +#endif + diff --git a/src/cairo-xlib-render-compositor.c b/src/cairo-xlib-render-compositor.c index 013e2aff1..68e7ce5a5 100644 --- a/src/cairo-xlib-render-compositor.c +++ b/src/cairo-xlib-render-compositor.c @@ -51,6 +51,7 @@ #include "cairo-image-surface-private.h" #include "cairo-list-inline.h" #include "cairo-pattern-private.h" +#include "cairo-pixman-private.h" #include "cairo-traps-private.h" #include "cairo-tristrip-private.h" diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 41e3a8d3b..029a542b9 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -60,6 +60,7 @@ #include "cairo-image-surface-private.h" #include "cairo-list-inline.h" #include "cairo-pattern-private.h" +#include "cairo-pixman-private.h" #include "cairo-region-private.h" #include "cairo-scaled-font-private.h" #include "cairo-surface-snapshot-private.h" |