From e7cc0c9cc08957e36f6f910ed4048903c30534a0 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 13 Feb 2014 02:10:07 +0200 Subject: [PATCH 3/7] Wrap cairo script device and script surface APIs --- cairomm/context.cc | 6 ++ cairomm/filelist.am | 4 ++ cairomm/script.cc | 103 ++++++++++++++++++++++++++++++++++ cairomm/script.h | 137 ++++++++++++++++++++++++++++++++++++++++++++++ cairomm/script_surface.cc | 58 ++++++++++++++++++++ cairomm/script_surface.h | 87 +++++++++++++++++++++++++++++ cairomm/surface.cc | 13 ++++- 7 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 cairomm/script.cc create mode 100644 cairomm/script.h create mode 100644 cairomm/script_surface.cc create mode 100644 cairomm/script_surface.h diff --git a/cairomm/context.cc b/cairomm/context.cc index 95d33e2..bf70ef4 100644 --- a/cairomm/context.cc +++ b/cairomm/context.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include /* M_PI is defined in math.h in the case of Microsoft Visual C++ */ @@ -836,6 +837,11 @@ RefPtr get_surface_wrapper (cairo_surface_t* surface) return wrap_surface_quartz(surface); break; #endif +#if CAIRO_HAS_SCRIPT_SURFACE + case CAIRO_SURFACE_TYPE_SCRIPT: + return RefPtr(new ScriptSurface(surface, false)); + break; +#endif #if CAIRO_HAS_WIN32_SURFACE case CAIRO_SURFACE_TYPE_WIN32: return wrap_surface_win32(surface); diff --git a/cairomm/filelist.am b/cairomm/filelist.am index 9f0b832..ab26483 100644 --- a/cairomm/filelist.am +++ b/cairomm/filelist.am @@ -17,6 +17,8 @@ cairomm_cc = \ quartz_surface.cc \ region.cc \ scaledfont.cc \ + script.cc \ + script_surface.cc \ surface.cc \ win32_font.cc \ win32_surface.cc \ @@ -37,6 +39,8 @@ cairomm_public_h = \ refptr.h \ region.h \ scaledfont.h \ + script.h \ + script_surface.h \ surface.h \ types.h \ win32_font.h \ diff --git a/cairomm/script.cc b/cairomm/script.cc new file mode 100644 index 0000000..ac8b22e --- /dev/null +++ b/cairomm/script.cc @@ -0,0 +1,103 @@ +/* Copyright (C) 2014 The cairomm Development Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include +#include + +namespace Cairo { + +#ifdef CAIRO_HAS_SCRIPT_SURFACE + +Script::Script(cairo_device_t* cobject, bool has_reference) : + Device(cobject, has_reference) +{} + +Script::~Script() +{ + // script device is destroyed in base class +} + +void Script::add_from_recording_surface(const RefPtr& recording_surface) +{ + ErrorStatus status = cairo_script_from_recording_surface(m_cobject, + recording_surface->cobj()); + check_status_and_throw_exception(status); +} + +ScriptMode Script::get_mode() const +{ + return static_cast(cairo_script_get_mode(m_cobject)); +} + +void Script::set_mode(ScriptMode new_mode) +{ + cairo_script_set_mode(m_cobject, static_cast(new_mode)); +} + +void Script::write_comment(const std::string& comment) +{ + cairo_script_write_comment(m_cobject, comment.data(), comment.length()); +} + +RefPtr