mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-03-23 09:40:33 +01:00
Add skia backend
Originally written by Vladimir Vukicevic to investigate using Skia for Mozilla, it provides a nice integration with a rather interesting code base. By hooking Skia underneath Cairo it allows us to directly compare code paths... which is interesting. [updated by Chris Wilson]
This commit is contained in:
parent
af6df4af51
commit
d7faec024a
14 changed files with 1363 additions and 1 deletions
|
|
@ -36,6 +36,7 @@ cairo_boilerplate_ps_sources = cairo-boilerplate-ps.c
|
||||||
cairo_boilerplate_qt_sources = cairo-boilerplate-qt.cpp
|
cairo_boilerplate_qt_sources = cairo-boilerplate-qt.cpp
|
||||||
cairo_boilerplate_quartz_sources = cairo-boilerplate-quartz.c
|
cairo_boilerplate_quartz_sources = cairo-boilerplate-quartz.c
|
||||||
cairo_boilerplate_script_sources = cairo-boilerplate-script.c
|
cairo_boilerplate_script_sources = cairo-boilerplate-script.c
|
||||||
|
cairo_boilerplate_skia_sources = cairo-boilerplate-skia.c
|
||||||
cairo_boilerplate_svg_sources = cairo-boilerplate-svg.c
|
cairo_boilerplate_svg_sources = cairo-boilerplate-svg.c
|
||||||
cairo_boilerplate_test_surfaces_sources = cairo-boilerplate-test-surfaces.c
|
cairo_boilerplate_test_surfaces_sources = cairo-boilerplate-test-surfaces.c
|
||||||
cairo_boilerplate_win32_sources = cairo-boilerplate-win32.c cairo-boilerplate-win32-printing.c
|
cairo_boilerplate_win32_sources = cairo-boilerplate-win32.c cairo-boilerplate-win32-printing.c
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,16 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_win32_font_private)
|
||||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_font_sources)
|
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_font_sources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_skia_headers)
|
||||||
|
all_cairo_boilerplate_headers += $(cairo_boilerplate_skia_headers)
|
||||||
|
all_cairo_boilerplate_private += $(cairo_boilerplate_skia_private)
|
||||||
|
all_cairo_boilerplate_sources += $(cairo_boilerplate_skia_sources)
|
||||||
|
ifeq ($(CAIRO_HAS_SKIA_SURFACE),1)
|
||||||
|
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_skia_headers)
|
||||||
|
enabled_cairo_boilerplate_private += $(cairo_boilerplate_skia_private)
|
||||||
|
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_skia_sources)
|
||||||
|
endif
|
||||||
|
|
||||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers)
|
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers)
|
||||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers)
|
all_cairo_boilerplate_headers += $(cairo_boilerplate_os2_headers)
|
||||||
all_cairo_boilerplate_private += $(cairo_boilerplate_os2_private)
|
all_cairo_boilerplate_private += $(cairo_boilerplate_os2_private)
|
||||||
|
|
|
||||||
50
boilerplate/cairo-boilerplate-skia.c
Normal file
50
boilerplate/cairo-boilerplate-skia.c
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
|
||||||
|
#include "cairo-boilerplate-private.h"
|
||||||
|
|
||||||
|
#include <cairo-skia.h>
|
||||||
|
|
||||||
|
static cairo_surface_t *
|
||||||
|
_cairo_boilerplate_skia_create_surface (const char *name,
|
||||||
|
cairo_content_t content,
|
||||||
|
double width,
|
||||||
|
double height,
|
||||||
|
double max_width,
|
||||||
|
double max_height,
|
||||||
|
cairo_boilerplate_mode_t mode,
|
||||||
|
int id,
|
||||||
|
void **closure)
|
||||||
|
{
|
||||||
|
cairo_format_t format;
|
||||||
|
|
||||||
|
*closure = NULL;
|
||||||
|
|
||||||
|
if (content == CAIRO_CONTENT_COLOR_ALPHA) {
|
||||||
|
format = CAIRO_FORMAT_ARGB32;
|
||||||
|
} else if (content == CAIRO_CONTENT_COLOR) {
|
||||||
|
format = CAIRO_FORMAT_RGB24;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cairo_skia_surface_create (format, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const cairo_boilerplate_target_t targets[] = {
|
||||||
|
{
|
||||||
|
"skia", "skia", NULL, NULL,
|
||||||
|
CAIRO_SURFACE_TYPE_SKIA, CAIRO_CONTENT_COLOR_ALPHA, 0,
|
||||||
|
_cairo_boilerplate_skia_create_surface,
|
||||||
|
NULL, NULL,
|
||||||
|
_cairo_boilerplate_get_image_surface,
|
||||||
|
cairo_surface_write_to_png
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"skia", "skia", NULL, NULL,
|
||||||
|
CAIRO_SURFACE_TYPE_SKIA, CAIRO_CONTENT_COLOR, 0,
|
||||||
|
_cairo_boilerplate_skia_create_surface,
|
||||||
|
NULL, NULL,
|
||||||
|
_cairo_boilerplate_get_image_surface,
|
||||||
|
cairo_surface_write_to_png
|
||||||
|
},
|
||||||
|
};
|
||||||
|
CAIRO_BOILERPLATE (skia, targets)
|
||||||
|
|
@ -9,6 +9,7 @@ CAIRO_HAS_QUARTZ_FONT=0
|
||||||
CAIRO_HAS_QUARTZ_IMAGE_SURFACE=0
|
CAIRO_HAS_QUARTZ_IMAGE_SURFACE=0
|
||||||
CAIRO_HAS_WIN32_SURFACE=1
|
CAIRO_HAS_WIN32_SURFACE=1
|
||||||
CAIRO_HAS_WIN32_FONT=1
|
CAIRO_HAS_WIN32_FONT=1
|
||||||
|
CAIRO_HAS_SKIA_SURFACE=0
|
||||||
CAIRO_HAS_OS2_SURFACE=0
|
CAIRO_HAS_OS2_SURFACE=0
|
||||||
CAIRO_HAS_BEOS_SURFACE=0
|
CAIRO_HAS_BEOS_SURFACE=0
|
||||||
CAIRO_HAS_DRM_SURFACE=0
|
CAIRO_HAS_DRM_SURFACE=0
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ endif
|
||||||
ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
||||||
@echo "#define CAIRO_HAS_WIN32_FONT 1" >> src/cairo-features.h
|
@echo "#define CAIRO_HAS_WIN32_FONT 1" >> src/cairo-features.h
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(CAIRO_HAS_SKIA_SURFACE),1)
|
||||||
|
@echo "#define CAIRO_HAS_SKIA_SURFACE 1" >> src/cairo-features.h
|
||||||
|
endif
|
||||||
ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
|
ifeq ($(CAIRO_HAS_OS2_SURFACE),1)
|
||||||
@echo "#define CAIRO_HAS_OS2_SURFACE 1" >> src/cairo-features.h
|
@echo "#define CAIRO_HAS_OS2_SURFACE 1" >> src/cairo-features.h
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -360,6 +360,7 @@ AC_DEFUN([CAIRO_REPORT],
|
||||||
echo " Meta: yes (always builtin)"
|
echo " Meta: yes (always builtin)"
|
||||||
echo " Tee: yes (always builtin)"
|
echo " Tee: yes (always builtin)"
|
||||||
echo " XML: $use_xml"
|
echo " XML: $use_xml"
|
||||||
|
echo " Skia: $use_skia"
|
||||||
echo " Xlib: $use_xlib"
|
echo " Xlib: $use_xlib"
|
||||||
echo " Xlib Xrender: $use_xlib_xrender"
|
echo " Xlib Xrender: $use_xlib_xrender"
|
||||||
echo " Qt: $use_qt"
|
echo " Qt: $use_qt"
|
||||||
|
|
|
||||||
13
configure.ac
13
configure.ac
|
|
@ -142,6 +142,19 @@ AM_CONDITIONAL(CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE, test "x$test_win32_printin
|
||||||
|
|
||||||
dnl ===========================================================================
|
dnl ===========================================================================
|
||||||
|
|
||||||
|
CAIRO_ENABLE_SURFACE_BACKEND(skia, Skia, no, [
|
||||||
|
AC_ARG_WITH([skia],
|
||||||
|
[AS_HELP_STRING([--with-skia=/path/to/skia],
|
||||||
|
[directory to find compiled skia sources])],
|
||||||
|
[skia_DIR="$withval"],
|
||||||
|
[skia_DIR="`pwd`/../mesa"])
|
||||||
|
skia_NONPKGCONFIG_CFLAGS="-I$skia_DIR/include/config -I$skia_DIR/include/core -I$skia_DIR/include/effects"
|
||||||
|
skia_NONPKGCONFIG_LIBS="$skia_DIR/out/libskia.a"
|
||||||
|
AC_SUBST(skia_DIR)
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl ===========================================================================
|
||||||
|
|
||||||
CAIRO_ENABLE_SURFACE_BACKEND(os2, OS/2, no, [
|
CAIRO_ENABLE_SURFACE_BACKEND(os2, OS/2, no, [
|
||||||
case "$host" in
|
case "$host" in
|
||||||
*-*-os2*)
|
*-*-os2*)
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,9 @@ target_is_measurable (const cairo_boilerplate_target_t *target)
|
||||||
#endif
|
#endif
|
||||||
#if CAIRO_HAS_DRM_SURFACE
|
#if CAIRO_HAS_DRM_SURFACE
|
||||||
case CAIRO_SURFACE_TYPE_DRM:
|
case CAIRO_SURFACE_TYPE_DRM:
|
||||||
|
#endif
|
||||||
|
#if CAIRO_HAS_SKIA_SURFACE
|
||||||
|
case CAIRO_SURFACE_TYPE_SKIA:
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case CAIRO_SURFACE_TYPE_PDF:
|
case CAIRO_SURFACE_TYPE_PDF:
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,9 @@ target_is_measurable (const cairo_boilerplate_target_t *target)
|
||||||
#endif
|
#endif
|
||||||
#if CAIRO_HAS_DRM_SURFACE
|
#if CAIRO_HAS_DRM_SURFACE
|
||||||
case CAIRO_SURFACE_TYPE_DRM:
|
case CAIRO_SURFACE_TYPE_DRM:
|
||||||
|
#endif
|
||||||
|
#if CAIRO_HAS_SKIA_SURFACE
|
||||||
|
case CAIRO_SURFACE_TYPE_SKIA:
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,9 @@ cairo_win32_sources = cairo-win32-surface.c cairo-win32-printing-surface.c
|
||||||
|
|
||||||
cairo_win32_font_sources = cairo-win32-font.c
|
cairo_win32_font_sources = cairo-win32-font.c
|
||||||
|
|
||||||
|
cairo_skia_headers =
|
||||||
|
cairo_skia_sources = cairo-skia-surface.cpp
|
||||||
|
|
||||||
cairo_os2_headers = cairo-os2.h
|
cairo_os2_headers = cairo-os2.h
|
||||||
cairo_os2_private = cairo-os2-private.h
|
cairo_os2_private = cairo-os2-private.h
|
||||||
cairo_os2_sources = cairo-os2-surface.c
|
cairo_os2_sources = cairo-os2-surface.c
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,20 @@ ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
||||||
enabled_cairo_pkgconf += cairo-win32-font.pc
|
enabled_cairo_pkgconf += cairo-win32-font.pc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
unsupported_cairo_headers += $(cairo_skia_headers)
|
||||||
|
all_cairo_headers += $(cairo_skia_headers)
|
||||||
|
all_cairo_private += $(cairo_skia_private)
|
||||||
|
all_cairo_sources += $(cairo_skia_sources)
|
||||||
|
ifeq ($(CAIRO_HAS_SKIA_SURFACE),1)
|
||||||
|
enabled_cairo_headers += $(cairo_skia_headers)
|
||||||
|
enabled_cairo_private += $(cairo_skia_private)
|
||||||
|
enabled_cairo_sources += $(cairo_skia_sources)
|
||||||
|
endif
|
||||||
|
all_cairo_pkgconf += cairo-skia.pc
|
||||||
|
ifeq ($(CAIRO_HAS_SKIA_SURFACE),1)
|
||||||
|
enabled_cairo_pkgconf += cairo-skia.pc
|
||||||
|
endif
|
||||||
|
|
||||||
unsupported_cairo_headers += $(cairo_os2_headers)
|
unsupported_cairo_headers += $(cairo_os2_headers)
|
||||||
all_cairo_headers += $(cairo_os2_headers)
|
all_cairo_headers += $(cairo_os2_headers)
|
||||||
all_cairo_private += $(cairo_os2_private)
|
all_cairo_private += $(cairo_os2_private)
|
||||||
|
|
|
||||||
1174
src/cairo-skia-surface.cpp
Normal file
1174
src/cairo-skia-surface.cpp
Normal file
File diff suppressed because it is too large
Load diff
84
src/cairo-skia.h
Normal file
84
src/cairo-skia.h
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
/* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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_SKIA_H
|
||||||
|
#define CAIRO_SKIA_H
|
||||||
|
|
||||||
|
#include "cairo.h"
|
||||||
|
|
||||||
|
#ifdef CAIRO_HAS_SKIA_SURFACE
|
||||||
|
|
||||||
|
CAIRO_BEGIN_DECLS
|
||||||
|
|
||||||
|
cairo_public cairo_surface_t *
|
||||||
|
cairo_skia_surface_create (cairo_format_t format,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
|
||||||
|
cairo_public cairo_surface_t *
|
||||||
|
cairo_skia_surface_create_for_data (unsigned char *data,
|
||||||
|
cairo_format_t format,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
int stride);
|
||||||
|
|
||||||
|
cairo_public unsigned char *
|
||||||
|
cairo_skia_surface_get_data (cairo_surface_t *surface);
|
||||||
|
|
||||||
|
cairo_public cairo_format_t
|
||||||
|
cairo_skia_surface_get_format (cairo_surface_t *surface);
|
||||||
|
|
||||||
|
cairo_public int
|
||||||
|
cairo_skia_surface_get_width (cairo_surface_t *surface);
|
||||||
|
|
||||||
|
cairo_public int
|
||||||
|
cairo_skia_surface_get_height (cairo_surface_t *surface);
|
||||||
|
|
||||||
|
cairo_public int
|
||||||
|
cairo_skia_surface_get_stride (cairo_surface_t *surface);
|
||||||
|
|
||||||
|
cairo_public cairo_surface_t *
|
||||||
|
cairo_skia_surface_get_image (cairo_surface_t *surface);
|
||||||
|
|
||||||
|
CAIRO_END_DECLS
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# error Cairo was not compiled with support for the Skia backend
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1950,6 +1950,7 @@ cairo_surface_status (cairo_surface_t *surface);
|
||||||
* @CAIRO_SURFACE_TYPE_DRM: The surface is of type Direct Render Manager, since 1.10
|
* @CAIRO_SURFACE_TYPE_DRM: The surface is of type Direct Render Manager, since 1.10
|
||||||
* @CAIRO_SURFACE_TYPE_TEE: The surface is of type 'tee' (a multiplexing surface), since 1.10
|
* @CAIRO_SURFACE_TYPE_TEE: The surface is of type 'tee' (a multiplexing surface), since 1.10
|
||||||
* @CAIRO_SURFACE_TYPE_XML: The surface is of type XML (for debugging), since 1.10
|
* @CAIRO_SURFACE_TYPE_XML: The surface is of type XML (for debugging), since 1.10
|
||||||
|
* @CAIRO_SURFACE_TYPE_SKIA: The surface is of type Skia, since 1.10
|
||||||
*
|
*
|
||||||
* #cairo_surface_type_t is used to describe the type of a given
|
* #cairo_surface_type_t is used to describe the type of a given
|
||||||
* surface. The surface types are also known as "backends" or "surface
|
* surface. The surface types are also known as "backends" or "surface
|
||||||
|
|
@ -1996,7 +1997,8 @@ typedef enum _cairo_surface_type {
|
||||||
CAIRO_SURFACE_TYPE_GL,
|
CAIRO_SURFACE_TYPE_GL,
|
||||||
CAIRO_SURFACE_TYPE_DRM,
|
CAIRO_SURFACE_TYPE_DRM,
|
||||||
CAIRO_SURFACE_TYPE_TEE,
|
CAIRO_SURFACE_TYPE_TEE,
|
||||||
CAIRO_SURFACE_TYPE_XML
|
CAIRO_SURFACE_TYPE_XML,
|
||||||
|
CAIRO_SURFACE_TYPE_SKIA
|
||||||
} cairo_surface_type_t;
|
} cairo_surface_type_t;
|
||||||
|
|
||||||
cairo_public cairo_surface_type_t
|
cairo_public cairo_surface_type_t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue