summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-03-28 16:19:47 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-09-29 09:58:19 -0400
commitd97fc0ebe78dea9e851b35dc0d90b9d84808e9a6 (patch)
tree2eedc20c38ef9d62ad5f1905f2ce6972944ef716
parent92d0c246f8483e112d240d4face484dfd8f05a72 (diff)
Initial skeleton for pixman surface.
FIXME: configure.ac enables it by default and there should probably be some checking.
-rw-r--r--boilerplate/Makefile.win32.features12
-rw-r--r--build/Makefile.win32.features1
-rw-r--r--build/Makefile.win32.features-h3
-rw-r--r--configure.ac4
-rw-r--r--src/Makefile.sources3
-rw-r--r--src/Makefile.win32.features16
-rw-r--r--src/cairo-pixman-surface.c247
-rw-r--r--src/cairo-pixman.h58
-rw-r--r--src/cairo.h4
9 files changed, 347 insertions, 1 deletions
diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index e60a95ba..25c9c756 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -175,6 +175,18 @@ enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_os2_cxx_sources)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_os2_sources)
endif
+supported_cairo_boilerplate_headers += $(cairo_boilerplate_pixman_headers)
+all_cairo_boilerplate_headers += $(cairo_boilerplate_pixman_headers)
+all_cairo_boilerplate_private += $(cairo_boilerplate_pixman_private)
+all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pixman_cxx_sources)
+all_cairo_boilerplate_sources += $(cairo_boilerplate_pixman_sources)
+ifeq ($(CAIRO_HAS_PIXMAN_SURFACE),1)
+enabled_cairo_boilerplate_headers += $(cairo_boilerplate_pixman_headers)
+enabled_cairo_boilerplate_private += $(cairo_boilerplate_pixman_private)
+enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_pixman_cxx_sources)
+enabled_cairo_boilerplate_sources += $(cairo_boilerplate_pixman_sources)
+endif
+
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_beos_headers)
all_cairo_boilerplate_headers += $(cairo_boilerplate_beos_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_beos_private)
diff --git a/build/Makefile.win32.features b/build/Makefile.win32.features
index 8cb155dc..9782f2d3 100644
--- a/build/Makefile.win32.features
+++ b/build/Makefile.win32.features
@@ -13,6 +13,7 @@ CAIRO_HAS_WIN32_SURFACE=1
CAIRO_HAS_WIN32_FONT=1
CAIRO_HAS_SKIA_SURFACE=0
CAIRO_HAS_OS2_SURFACE=0
+CAIRO_HAS_PIXMAN_SURFACE=1
CAIRO_HAS_BEOS_SURFACE=0
CAIRO_HAS_DRM_SURFACE=0
CAIRO_HAS_GALLIUM_SURFACE=0
diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h
index 13904cfa..702bacdd 100644
--- a/build/Makefile.win32.features-h
+++ b/build/Makefile.win32.features-h
@@ -44,6 +44,9 @@ endif
ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
@echo "#define CAIRO_HAS_OS2_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
endif
+ifeq ($(CAIRO_HAS_PIXMAN_SURFACE),1)
+ @echo "#define CAIRO_HAS_PIXMAN_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
+endif
ifeq ($(CAIRO_HAS_BEOS_SURFACE),1)
@echo "#define CAIRO_HAS_BEOS_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
endif
diff --git a/configure.ac b/configure.ac
index 67b68e2d..6d479732 100644
--- a/configure.ac
+++ b/configure.ac
@@ -232,6 +232,10 @@ CAIRO_ENABLE_SURFACE_BACKEND(os2, OS/2, no, [
dnl ===========================================================================
+CAIRO_ENABLE_SURFACE_BACKEND(pixman, Pixman, yes, [])
+
+dnl ===========================================================================
+
CAIRO_ENABLE_SURFACE_BACKEND(beos, BeOS/Zeta, no, [
case "$host" in
*-*-beos)
diff --git a/src/Makefile.sources b/src/Makefile.sources
index d6793b09..f62594af 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -372,6 +372,9 @@ cairo_os2_headers = cairo-os2.h
cairo_os2_private = cairo-os2-private.h
cairo_os2_sources = cairo-os2-surface.c
+cairo_pixman_headers = cairo-pixman.h
+cairo_pixman_sources = cairo-pixman-surface.c
+
# automake is stupid enough to always use c++ linker if we enable the
# following lines, even if beos surface is not enabled. Disable it for now.
cairo_beos_headers = cairo-beos.h
diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features
index 2274f4ad..879098ef 100644
--- a/src/Makefile.win32.features
+++ b/src/Makefile.win32.features
@@ -229,6 +229,22 @@ ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
enabled_cairo_pkgconf += cairo-os2.pc
endif
+supported_cairo_headers += $(cairo_pixman_headers)
+all_cairo_headers += $(cairo_pixman_headers)
+all_cairo_private += $(cairo_pixman_private)
+all_cairo_cxx_sources += $(cairo_pixman_cxx_sources)
+all_cairo_sources += $(cairo_pixman_sources)
+ifeq ($(CAIRO_HAS_PIXMAN_SURFACE),1)
+enabled_cairo_headers += $(cairo_pixman_headers)
+enabled_cairo_private += $(cairo_pixman_private)
+enabled_cairo_cxx_sources += $(cairo_pixman_cxx_sources)
+enabled_cairo_sources += $(cairo_pixman_sources)
+endif
+all_cairo_pkgconf += cairo-pixman.pc
+ifeq ($(CAIRO_HAS_PIXMAN_SURFACE),1)
+enabled_cairo_pkgconf += cairo-pixman.pc
+endif
+
unsupported_cairo_headers += $(cairo_beos_headers)
all_cairo_headers += $(cairo_beos_headers)
all_cairo_private += $(cairo_beos_private)
diff --git a/src/cairo-pixman-surface.c b/src/cairo-pixman-surface.c
new file mode 100644
index 00000000..5a60b663
--- /dev/null
+++ b/src/cairo-pixman-surface.c
@@ -0,0 +1,247 @@
+/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2003 University of Southern California
+ * Copyright © 2009,2010,2011 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):
+ * Carl D. Worth <cworth@cworth.org>
+ * Chris Wilson <chris@chris-wilson.co.uk>
+ */
+
+#include "cairoint.h"
+
+#include "cairo-pixman.h"
+#include "cairo-default-context-private.h"
+
+/* Limit on the width / height of an image surface in pixels. This is
+ * mainly determined by coordinates of things sent to pixman at the
+ * moment being in 16.16 format. */
+#define MAX_IMAGE_SIZE 32767
+
+/**
+ * SECTION:cairo-pixman
+ * @Title: Pixman Surfaces
+ * @Short_Description: Rendering to pixman images
+ * @See_Also: #cairo_surface_t
+ *
+ * Pixman surfaces provide the ability to render to pixman images
+ * allocated by the calling code. The supported pixman formats are
+ * those for which pixman_supported_destination() returns TRUE.
+ */
+
+/**
+ * CAIRO_HAS_PIXMAN_SURFACE:
+ *
+ * Defined if the pixman surface backend is available.
+ *
+ * @Since: 1.13
+ */
+
+/**
+ * cairo_pixman_surface_create:
+ * @format: format of pixels in the surface to create
+ * @width: width of the surface, in pixels
+ * @height: height of the surface, in pixels
+ *
+ * Creates an image surface of the specified format and
+ * dimensions. Initially the surface contents are all
+ * 0. (Specifically, within each pixel, each color or alpha channel
+ * belonging to format will be 0. The contents of bits within a pixel,
+ * but not belonging to the given format are undefined).
+ *
+ * Return value: a pointer to the newly created surface. The caller
+ * owns the surface and should call cairo_surface_destroy() when done
+ * with it.
+ *
+ * This function always returns a valid pointer, but it will return a
+ * pointer to a "nil" surface if an error such as out of memory
+ * occurs. You can use cairo_surface_status() to check for this.
+ **/
+cairo_surface_t *
+cairo_pixman_surface_create (pixman_image_t *image)
+{
+ return NULL;
+}
+
+static cairo_status_t
+_cairo_pixman_surface_finish (void *abstract_surface)
+{
+}
+
+static cairo_surface_t *
+_cairo_pixman_surface_create_similar (void *abstract_other,
+ cairo_content_t content,
+ int width,
+ int height)
+{
+}
+
+static cairo_surface_t *
+_cairo_pixman_surface_map_to_image (void *abstract_other,
+ const cairo_rectangle_int_t *extents)
+{
+}
+
+static cairo_int_status_t
+_cairo_pixman_surface_unmap_image (void *abstract_surface,
+ cairo_image_surface_t *image)
+{
+}
+
+static cairo_surface_t *
+_cairo_pixman_surface_source (void *abstract_surface,
+ cairo_rectangle_int_t *extents)
+{
+}
+
+static cairo_status_t
+_cairo_pixman_surface_acquire_source_image (void *abstract_surface,
+ cairo_image_surface_t **image_out,
+ void **image_extra)
+{
+ *image_out = abstract_surface;
+ *image_extra = NULL;
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+static void
+_cairo_pixman_surface_release_source_image (void *abstract_surface,
+ cairo_image_surface_t *image,
+ void *image_extra)
+{
+}
+
+static cairo_surface_t *
+_cairo_pixman_surface_snapshot (void *abstract_surface)
+{
+}
+
+static cairo_bool_t
+_cairo_pixman_surface_get_extents (void *abstract_surface,
+ cairo_rectangle_int_t *rectangle)
+{
+}
+
+static void
+_cairo_pixman_surface_get_font_options (void *abstract_surface,
+ cairo_font_options_t *options)
+{
+}
+
+static cairo_int_status_t
+_cairo_pixman_surface_paint (void *abstract_surface,
+ cairo_operator_t op,
+ const cairo_pattern_t *source,
+ const cairo_clip_t *clip)
+{
+}
+
+static cairo_int_status_t
+_cairo_pixman_surface_mask (void *abstract_surface,
+ cairo_operator_t op,
+ const cairo_pattern_t *source,
+ const cairo_pattern_t *mask,
+ const cairo_clip_t *clip)
+{
+}
+
+static cairo_int_status_t
+_cairo_pixman_surface_stroke (void *abstract_surface,
+ cairo_operator_t op,
+ const cairo_pattern_t *source,
+ const cairo_path_fixed_t *path,
+ const cairo_stroke_style_t *style,
+ const cairo_matrix_t *ctm,
+ const cairo_matrix_t *ctm_inverse,
+ double tolerance,
+ cairo_antialias_t antialias,
+ const cairo_clip_t *clip)
+{
+}
+
+static cairo_int_status_t
+_cairo_pixman_surface_fill (void *abstract_surface,
+ cairo_operator_t op,
+ const cairo_pattern_t *source,
+ const cairo_path_fixed_t *path,
+ cairo_fill_rule_t fill_rule,
+ double tolerance,
+ cairo_antialias_t antialias,
+ const cairo_clip_t *clip)
+{
+}
+
+static cairo_int_status_t
+_cairo_pixman_surface_glyphs (void *abstract_surface,
+ cairo_operator_t op,
+ const cairo_pattern_t *source,
+ cairo_glyph_t *glyphs,
+ int num_glyphs,
+ cairo_scaled_font_t *scaled_font,
+ const cairo_clip_t *clip)
+{
+}
+
+const cairo_surface_backend_t _cairo_pixman_surface_backend =
+{
+ CAIRO_SURFACE_TYPE_IMAGE,
+ _cairo_pixman_surface_finish,
+
+ _cairo_default_context_create,
+
+ _cairo_pixman_surface_create_similar,
+ NULL, /* create similar image */
+ _cairo_pixman_surface_map_to_image,
+ _cairo_pixman_surface_unmap_image,
+
+ _cairo_pixman_surface_source,
+ _cairo_pixman_surface_acquire_source_image,
+ _cairo_pixman_surface_release_source_image,
+ _cairo_pixman_surface_snapshot,
+
+ NULL, /* copy_page */
+ NULL, /* show_page */
+
+ _cairo_pixman_surface_get_extents,
+ _cairo_pixman_surface_get_font_options,
+
+ NULL, /* flush */
+ NULL,
+
+ _cairo_pixman_surface_paint,
+ _cairo_pixman_surface_mask,
+ _cairo_pixman_surface_stroke,
+ _cairo_pixman_surface_fill,
+ NULL, /* fill-stroke */
+ _cairo_pixman_surface_glyphs,
+};
diff --git a/src/cairo-pixman.h b/src/cairo-pixman.h
new file mode 100644
index 00000000..8aa81a2e
--- /dev/null
+++ b/src/cairo-pixman.h
@@ -0,0 +1,58 @@
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2002 University of Southern California
+ *
+ * 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):
+ * Carl D. Worth <cworth@cworth.org>
+ */
+
+#ifndef CAIRO_PIXMAN_H
+#define CAIRO_PIXMAN_H
+
+#include "cairo.h"
+#include <pixman.h>
+
+#if CAIRO_HAS_PIXMAN_SURFACE
+
+CAIRO_BEGIN_DECLS
+
+cairo_public cairo_surface_t *
+cairo_pixman_surface_create (pixman_image_t *target);
+
+CAIRO_END_DECLS
+
+#else
+
+# error Cairo was not compiled with support for the Pixman backend
+
+#endif
+
+#endif
diff --git a/src/cairo.h b/src/cairo.h
index a2f5aa37..c8dee0f3 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -2332,6 +2332,7 @@ cairo_surface_status (cairo_surface_t *surface);
* @CAIRO_SURFACE_TYPE_SUBSURFACE: The surface is a subsurface created with
* cairo_surface_create_for_rectangle(), since 1.10
* @CAIRO_SURFACE_TYPE_COGL: This surface is of type Cogl, since 1.12
+ * @CAIRO_SURFACE_TYPE_PIXMAN: This surface is a Pixman surface, since 1.14
*
* #cairo_surface_type_t is used to describe the type of a given
* surface. The surface types are also known as "backends" or "surface
@@ -2382,7 +2383,8 @@ typedef enum _cairo_surface_type {
CAIRO_SURFACE_TYPE_XML,
CAIRO_SURFACE_TYPE_SKIA,
CAIRO_SURFACE_TYPE_SUBSURFACE,
- CAIRO_SURFACE_TYPE_COGL
+ CAIRO_SURFACE_TYPE_COGL,
+ CAIRO_SURFACE_TYPE_PIXMAN
} cairo_surface_type_t;
cairo_public cairo_surface_type_t