Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_DEVICEHELPER_HXX
21 : #define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_DEVICEHELPER_HXX
22 :
23 : #include <com/sun/star/awt/Rectangle.hpp>
24 : #include <com/sun/star/rendering/XGraphicDevice.hpp>
25 : #include <com/sun/star/rendering/XBufferController.hpp>
26 :
27 : #include <boost/utility.hpp>
28 :
29 : #include <vcl/window.hxx>
30 : #include <vcl/bitmap.hxx>
31 :
32 : #include "cairo_surfaceprovider.hxx"
33 :
34 : /* Definition of DeviceHelper class */
35 :
36 : namespace cairocanvas
37 : {
38 3 : class DeviceHelper : private ::boost::noncopyable
39 : {
40 : public:
41 : DeviceHelper();
42 :
43 : /** init helper
44 :
45 : @param rCanvas
46 : Owning canvas.
47 :
48 : @param rRefDevice
49 : Reference output device. Needed for resolution
50 : calculations etc.
51 : */
52 : void init( SurfaceProvider& rSurfaceProvider,
53 : OutputDevice& rRefDevice );
54 :
55 : /// Dispose all internal references
56 : void disposing();
57 :
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 );
79 :
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;
85 :
86 : /** called when DumpScreenContent property is enabled on
87 : XGraphicDevice, and writes out bitmaps of current screen.
88 : */
89 : void dumpScreenContent() const;
90 :
91 4 : OutputDevice* getOutputDevice() const { return mpRefDevice; }
92 2 : ::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 );
95 :
96 : protected:
97 : /** init helper
98 :
99 : @param rCanvas
100 : Owning canvas.
101 :
102 : @param rRefDevice
103 : Reference output device. Needed for resolution
104 : calculations etc.
105 : */
106 : void implInit( SurfaceProvider& rSurfaceProvider,
107 : OutputDevice& rRefDevice );
108 : void setSize( const ::basegfx::B2ISize& rSize );
109 :
110 : private:
111 : /** Surface provider
112 :
113 : Deliberately not a refcounted reference, because of
114 : potential circular references for canvas. Provides us with
115 : our output surface and associated functionality.
116 : */
117 : SurfaceProvider* mpSurfaceProvider;
118 :
119 : VclPtr<OutputDevice> mpRefDevice;
120 : ::cairo::SurfaceSharedPtr mpSurface;
121 : };
122 : }
123 :
124 : #endif
125 :
126 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|