Branch libreoffice-5-0-4
[LibreOffice.git] / canvas / source / cairo / cairo_devicehelper.hxx
blobeafc5065e10b5c8164eb84687697418fb520c04e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_DEVICEHELPER_HXX
21 #define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_DEVICEHELPER_HXX
23 #include <com/sun/star/awt/Rectangle.hpp>
24 #include <com/sun/star/rendering/XGraphicDevice.hpp>
25 #include <com/sun/star/rendering/XBufferController.hpp>
27 #include <boost/utility.hpp>
29 #include <vcl/window.hxx>
30 #include <vcl/bitmap.hxx>
32 #include "cairo_surfaceprovider.hxx"
34 /* Definition of DeviceHelper class */
36 namespace cairocanvas
38 class DeviceHelper : private ::boost::noncopyable
40 public:
41 DeviceHelper();
43 /** init helper
45 @param rCanvas
46 Owning canvas.
48 @param rRefDevice
49 Reference output device. Needed for resolution
50 calculations etc.
52 void init( SurfaceProvider& rSurfaceProvider,
53 OutputDevice& rRefDevice );
55 /// Dispose all internal references
56 void disposing();
58 // XWindowGraphicDevice
59 ::com::sun::star::geometry::RealSize2D getPhysicalResolution();
60 ::com::sun::star::geometry::RealSize2D getPhysicalSize();
61 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XLinePolyPolygon2D > createCompatibleLinePolyPolygon(
62 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
63 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points );
64 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBezierPolyPolygon2D > createCompatibleBezierPolyPolygon(
65 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
66 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points );
67 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleBitmap(
68 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
69 const ::com::sun::star::geometry::IntegerSize2D& size );
70 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileBitmap(
71 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
72 const ::com::sun::star::geometry::IntegerSize2D& size );
73 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleAlphaBitmap(
74 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
75 const ::com::sun::star::geometry::IntegerSize2D& size );
76 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileAlphaBitmap(
77 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
78 const ::com::sun::star::geometry::IntegerSize2D& size );
80 ::com::sun::star::uno::Any isAccelerated() const;
81 ::com::sun::star::uno::Any getDeviceHandle() const;
82 ::com::sun::star::uno::Any getSurfaceHandle() const;
83 ::com::sun::star::uno::Reference<
84 ::com::sun::star::rendering::XColorSpace > getColorSpace() const;
86 /** called when DumpScreenContent property is enabled on
87 XGraphicDevice, and writes out bitmaps of current screen.
89 void dumpScreenContent() const;
91 OutputDevice* getOutputDevice() const { return mpRefDevice; }
92 ::cairo::SurfaceSharedPtr getSurface() { return mpSurface; }
93 ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent = CAIRO_CONTENT_COLOR_ALPHA );
94 ::cairo::SurfaceSharedPtr createSurface( BitmapSystemData& rData, const Size& rSize );
96 protected:
97 /** init helper
99 @param rCanvas
100 Owning canvas.
102 @param rRefDevice
103 Reference output device. Needed for resolution
104 calculations etc.
106 void implInit( SurfaceProvider& rSurfaceProvider,
107 OutputDevice& rRefDevice );
108 void setSize( const ::basegfx::B2ISize& rSize );
110 private:
111 /** Surface provider
113 Deliberately not a refcounted reference, because of
114 potential circular references for canvas. Provides us with
115 our output surface and associated functionality.
117 SurfaceProvider* mpSurfaceProvider;
119 VclPtr<OutputDevice> mpRefDevice;
120 ::cairo::SurfaceSharedPtr mpSurface;
124 #endif
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */