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 _CAIROCANVAS_DEVICEHELPER_HXX
21 : #define _CAIROCANVAS_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_cairo.hxx"
33 : #include "cairo_surfaceprovider.hxx"
34 :
35 : /* Definition of DeviceHelper class */
36 :
37 : namespace cairocanvas
38 : {
39 0 : class DeviceHelper : private ::boost::noncopyable
40 : {
41 : public:
42 : DeviceHelper();
43 :
44 : /** init helper
45 :
46 : @param rCanvas
47 : Owning canvas.
48 :
49 : @param rRefDevice
50 : Reference output device. Needed for resolution
51 : calculations etc.
52 : */
53 : void init( SurfaceProvider& rSurfaceProvider,
54 : OutputDevice& rRefDevice );
55 :
56 : /// Dispose all internal references
57 : void disposing();
58 :
59 : // XWindowGraphicDevice
60 : ::com::sun::star::geometry::RealSize2D getPhysicalResolution();
61 : ::com::sun::star::geometry::RealSize2D getPhysicalSize();
62 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XLinePolyPolygon2D > createCompatibleLinePolyPolygon(
63 : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
64 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points );
65 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBezierPolyPolygon2D > createCompatibleBezierPolyPolygon(
66 : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
67 : const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points );
68 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleBitmap(
69 : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
70 : const ::com::sun::star::geometry::IntegerSize2D& size );
71 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileBitmap(
72 : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
73 : const ::com::sun::star::geometry::IntegerSize2D& size );
74 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > createCompatibleAlphaBitmap(
75 : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
76 : const ::com::sun::star::geometry::IntegerSize2D& size );
77 : ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > createVolatileAlphaBitmap(
78 : const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
79 : const ::com::sun::star::geometry::IntegerSize2D& size );
80 : sal_Bool hasFullScreenMode( );
81 : sal_Bool enterFullScreenMode( sal_Bool bEnter );
82 :
83 : ::com::sun::star::uno::Any isAccelerated() const;
84 : ::com::sun::star::uno::Any getDeviceHandle() const;
85 : ::com::sun::star::uno::Any getSurfaceHandle() const;
86 : ::com::sun::star::uno::Reference<
87 : ::com::sun::star::rendering::XColorSpace > getColorSpace() const;
88 :
89 : /** called when DumpScreenContent property is enabled on
90 : XGraphicDevice, and writes out bitmaps of current screen.
91 : */
92 : void dumpScreenContent() const;
93 :
94 0 : OutputDevice* getOutputDevice() const { return mpRefDevice; }
95 : const void* getSysData() { return mpSysData; }
96 : ::cairo::SurfaceSharedPtr getSurface();
97 : ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, ::cairo::Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
98 : ::cairo::SurfaceSharedPtr createSurface( BitmapSystemData& rData, const Size& rSize );
99 :
100 : protected:
101 : /** init helper
102 :
103 : @param rCanvas
104 : Owning canvas.
105 :
106 : @param rRefDevice
107 : Reference output device. Needed for resolution
108 : calculations etc.
109 : */
110 : void implInit( SurfaceProvider& rSurfaceProvider,
111 : OutputDevice& rRefDevice );
112 : void setSize( const ::basegfx::B2ISize& rSize );
113 :
114 : private:
115 : /** Surface provider
116 :
117 : Deliberately not a refcounted reference, because of
118 : potential circular references for canvas. Provides us with
119 : our output surface and associated functionality.
120 : */
121 : SurfaceProvider* mpSurfaceProvider;
122 :
123 : OutputDevice* mpRefDevice;
124 : const void* mpSysData;
125 : ::cairo::SurfaceSharedPtr mpSurface;
126 : };
127 : }
128 :
129 : #endif
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|