cid#1607171 Data race condition
[LibreOffice.git] / canvas / source / cairo / cairo_devicehelper.hxx
blobeede77844d3ae061d0d9550b86f31032b2a0c603
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 #pragma once
22 #include <com/sun/star/rendering/XGraphicDevice.hpp>
24 #include <vcl/outdev.hxx>
26 #include "cairo_surfaceprovider.hxx"
28 /* Definition of DeviceHelper class */
30 namespace cairocanvas
32 class DeviceHelper
34 public:
35 /// make noncopyable
36 DeviceHelper(const DeviceHelper&) = delete;
37 const DeviceHelper& operator=(const DeviceHelper&) = delete;
39 DeviceHelper();
41 /** init helper
43 @param rCanvas
44 Owning canvas.
46 @param rRefDevice
47 Reference output device. Needed for resolution
48 calculations etc.
50 void init( SurfaceProvider& rSurfaceProvider,
51 OutputDevice& rRefDevice );
53 /// Dispose all internal references
54 void disposing();
56 // XWindowGraphicDevice
57 css::geometry::RealSize2D getPhysicalResolution();
58 css::geometry::RealSize2D getPhysicalSize();
59 css::uno::Reference< css::rendering::XLinePolyPolygon2D > createCompatibleLinePolyPolygon(
60 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
61 const css::uno::Sequence< css::uno::Sequence< css::geometry::RealPoint2D > >& points );
62 css::uno::Reference< css::rendering::XBezierPolyPolygon2D > createCompatibleBezierPolyPolygon(
63 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
64 const css::uno::Sequence< css::uno::Sequence< css::geometry::RealBezierSegment2D > >& points );
65 css::uno::Reference< css::rendering::XBitmap > createCompatibleBitmap(
66 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
67 const css::geometry::IntegerSize2D& size );
68 css::uno::Reference< css::rendering::XVolatileBitmap > createVolatileBitmap(
69 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
70 const css::geometry::IntegerSize2D& size );
71 css::uno::Reference< css::rendering::XBitmap > createCompatibleAlphaBitmap(
72 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
73 const css::geometry::IntegerSize2D& size );
74 css::uno::Reference< css::rendering::XVolatileBitmap > createVolatileAlphaBitmap(
75 const css::uno::Reference< css::rendering::XGraphicDevice >& rDevice,
76 const css::geometry::IntegerSize2D& size );
78 css::uno::Any isAccelerated() const;
79 css::uno::Any getDeviceHandle() const;
80 css::uno::Any getSurfaceHandle() const;
81 css::uno::Reference<
82 css::rendering::XColorSpace > const & getColorSpace() const;
84 /** called when DumpScreenContent property is enabled on
85 XGraphicDevice, and writes out bitmaps of current screen.
87 void dumpScreenContent() const;
89 OutputDevice* getOutputDevice() const { return mpRefDevice; }
90 const ::cairo::SurfaceSharedPtr& getSurface() const { return mpSurface; }
91 ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent );
92 ::cairo::SurfaceSharedPtr createSurface( BitmapSystemData const & rData, const Size& rSize );
94 protected:
95 /** init helper
97 @param rCanvas
98 Owning canvas.
100 @param rRefDevice
101 Reference output device. Needed for resolution
102 calculations etc.
104 void implInit( SurfaceProvider& rSurfaceProvider,
105 OutputDevice& rRefDevice );
106 void setSize( const ::basegfx::B2ISize& rSize );
108 private:
109 /** Surface provider
111 Deliberately not a refcounted reference, because of
112 potential circular references for canvas. Provides us with
113 our output surface and associated functionality.
115 SurfaceProvider* mpSurfaceProvider;
117 VclPtr<OutputDevice> mpRefDevice;
118 ::cairo::SurfaceSharedPtr mpSurface;
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */