From e510a208b01c87a341b43d74d8d901f992379b84 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 19 Mar 2015 14:43:08 +0000 Subject: move cairo helpers to vcl and make per-plug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4de4d5c3a191784598e93a8cf70e45a3f59ae857 Reviewed-on: https://gerrit.libreoffice.org/14907 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/vcl/cairo.hxx | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/vcl/outdev.hxx | 12 +++++++++ 2 files changed, 79 insertions(+) create mode 100644 include/vcl/cairo.hxx (limited to 'include') diff --git a/include/vcl/cairo.hxx b/include/vcl/cairo.hxx new file mode 100644 index 000000000000..c8cc23e802b3 --- /dev/null +++ b/include/vcl/cairo.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_CAIRO_HXX +#define INCLUDED_VCL_CAIRO_HXX + +#include +#include + +typedef struct _cairo_surface cairo_surface_t; +typedef struct _cairo cairo_t; + +class VirtualDevice; + +namespace cairo { + + typedef boost::shared_ptr CairoSurfaceSharedPtr; + typedef boost::shared_ptr CairoSharedPtr; + + /** Cairo surface interface + + For each cairo-supported platform, there's an implementation of + this interface + */ + struct Surface + { + public: + virtual ~Surface() {} + + // Query methods + virtual CairoSharedPtr getCairo() const = 0; + virtual CairoSurfaceSharedPtr getCairoSurface() const = 0; + virtual boost::shared_ptr getSimilar(int cairo_content_type, int width, int height) const = 0; + + /// factory for VirDev on this surface + virtual boost::shared_ptr createVirtualDevice() const = 0; + + /// Resize the surface (possibly destroying content), only possible for X11 typically + /// so on failure caller must create a new surface instead + virtual bool Resize( int /*width*/, int /*height*/ ) { return false; } + + /// Flush all pending output to surface + virtual void flush() const = 0; + }; + + typedef boost::shared_ptr SurfaceSharedPtr; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index c3adbbff7bfc..7911b662b285 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -120,6 +121,8 @@ namespace basegfx { class B2DHomMatrix; class B2DPolygon; class B2DPolyPolygon; + class B2IVector; + typedef B2IVector B2ISize; } namespace com { @@ -233,6 +236,7 @@ class FontSelectPattern; class ImplFontMetricData; class VCLXGraphics; class OutDevStateStack; +struct BitmapSystemData; typedef boost::intrusive_ptr< FontCharMap > FontCharMapPtr; @@ -377,6 +381,14 @@ public: SystemGraphicsData GetSystemGfxData() const; bool SupportsCairo() const; + /// Create Surface from given cairo surface + cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const; + /// Create surface with given dimensions + cairo::SurfaceSharedPtr CreateSurface(int x, int y, int width, int height) const; + /// Create Surface for given bitmap data + cairo::SurfaceSharedPtr CreateBitmapSurface(const BitmapSystemData& rData, const Size& rSize) const; + /// Return native handle for underlying surface + css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const; css::uno::Any GetSystemGfxDataAny() const; void SetRefPoint(); -- cgit