/src/libreoffice/canvas/source/vcl/spritecanvas.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <rtl/ref.hxx> |
23 | | |
24 | | #include <com/sun/star/uno/XComponentContext.hpp> |
25 | | #include <com/sun/star/beans/XPropertySet.hpp> |
26 | | #include <com/sun/star/lang/XServiceInfo.hpp> |
27 | | #include <com/sun/star/lang/XServiceName.hpp> |
28 | | #include <com/sun/star/awt/XWindowListener.hpp> |
29 | | #include <com/sun/star/util/XUpdatable.hpp> |
30 | | #include <com/sun/star/rendering/XSpriteCanvas.hpp> |
31 | | #include <com/sun/star/rendering/XIntegerBitmap.hpp> |
32 | | #include <com/sun/star/rendering/XGraphicDevice.hpp> |
33 | | #include <com/sun/star/rendering/XBufferController.hpp> |
34 | | |
35 | | #include <cppuhelper/compbase.hxx> |
36 | | #include <comphelper/uno3.hxx> |
37 | | |
38 | | #include <base/spritecanvasbase.hxx> |
39 | | #include <base/spritesurface.hxx> |
40 | | #include <base/disambiguationhelper.hxx> |
41 | | #include <base/bufferedgraphicdevicebase.hxx> |
42 | | |
43 | | #include "spritecanvashelper.hxx" |
44 | | #include "impltools.hxx" |
45 | | #include "spritedevicehelper.hxx" |
46 | | #include "repainttarget.hxx" |
47 | | |
48 | | |
49 | | namespace vclcanvas |
50 | | { |
51 | | typedef ::cppu::WeakComponentImplHelper< css::rendering::XSpriteCanvas, |
52 | | css::rendering::XIntegerBitmap, |
53 | | css::rendering::XGraphicDevice, |
54 | | css::lang::XMultiServiceFactory, |
55 | | css::rendering::XBufferController, |
56 | | css::awt::XWindowListener, |
57 | | css::util::XUpdatable, |
58 | | css::beans::XPropertySet, |
59 | | css::lang::XServiceName, |
60 | | css::lang::XServiceInfo > WindowGraphicDeviceBase_Base; |
61 | | typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::DisambiguationHelper< WindowGraphicDeviceBase_Base >, |
62 | | SpriteDeviceHelper, |
63 | | vclcanvastools::LocalGuard, |
64 | | ::cppu::OWeakObject > SpriteCanvasBase_Base; |
65 | | |
66 | | /** Mixin SpriteSurface |
67 | | |
68 | | Have to mixin the SpriteSurface before deriving from |
69 | | ::canvas::SpriteCanvasBase, as this template should already |
70 | | implement some of those interface methods. |
71 | | |
72 | | The reason why this appears kinda convoluted is the fact that |
73 | | we cannot specify non-IDL types as WeakComponentImplHelper |
74 | | template args, and furthermore, don't want to derive |
75 | | ::canvas::SpriteCanvasBase directly from |
76 | | ::canvas::SpriteSurface (because derivees of |
77 | | ::canvas::SpriteCanvasBase have to explicitly forward the |
78 | | XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS) |
79 | | anyway). Basically, ::canvas::CanvasCustomSpriteBase should |
80 | | remain a base class that provides implementation, not to |
81 | | enforce any specific interface on its derivees. |
82 | | */ |
83 | | class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base, |
84 | | public ::canvas::SpriteSurface |
85 | | { |
86 | | }; |
87 | | |
88 | | typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base, |
89 | | SpriteCanvasHelper, |
90 | | vclcanvastools::LocalGuard, |
91 | | ::cppu::OWeakObject > SpriteCanvasBaseT; |
92 | | |
93 | | /** Product of this component's factory. |
94 | | |
95 | | The SpriteCanvas object combines the actual Window canvas with |
96 | | the XGraphicDevice interface. This is because there's a |
97 | | one-to-one relation between them, anyway, since each window |
98 | | can have exactly one canvas and one associated |
99 | | XGraphicDevice. And to avoid messing around with circular |
100 | | references, this is implemented as one single object. |
101 | | */ |
102 | | class SpriteCanvas : public SpriteCanvasBaseT, |
103 | | public RepaintTarget |
104 | | { |
105 | | public: |
106 | | SpriteCanvas( const css::uno::Sequence< |
107 | | css::uno::Any >& aArguments, |
108 | | const css::uno::Reference< |
109 | | css::uno::XComponentContext >& rxContext ); |
110 | | |
111 | | void initialize(); |
112 | | |
113 | | /// For resource tracking |
114 | | virtual ~SpriteCanvas() override; |
115 | | |
116 | | /// Dispose all internal references |
117 | | virtual void disposeThis() override; |
118 | | |
119 | | // Forwarding the XComponent implementation to the |
120 | | // cppu::ImplHelper templated base |
121 | | // Classname Base doing refcounting Base implementing the XComponent interface |
122 | | // | | | |
123 | | // V V V |
124 | | DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase ) |
125 | | |
126 | | // XBufferController (partial) |
127 | | virtual sal_Bool SAL_CALL showBuffer( sal_Bool bUpdateAll ) override; |
128 | | virtual sal_Bool SAL_CALL switchBuffer( sal_Bool bUpdateAll ) override; |
129 | | |
130 | | // XSpriteCanvas (partial) |
131 | | virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) override; |
132 | | |
133 | | // XServiceName |
134 | | virtual OUString SAL_CALL getServiceName( ) override; |
135 | | |
136 | | // XServiceInfo |
137 | | virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; |
138 | | virtual OUString SAL_CALL getImplementationName() override; |
139 | | virtual sal_Bool SAL_CALL supportsService(const OUString&) override; |
140 | | |
141 | | // RepaintTarget |
142 | | virtual bool repaint( const GraphicObjectSharedPtr& rGrf, |
143 | | const css::rendering::ViewState& viewState, |
144 | | const css::rendering::RenderState& renderState, |
145 | | const ::Point& rPt, |
146 | | const ::Size& rSz, |
147 | | const GraphicAttr& rAttr ) const override; |
148 | | |
149 | | /// Get backbuffer for this canvas |
150 | 0 | OutDevProviderSharedPtr const & getFrontBuffer() const { return maDeviceHelper.getOutDev(); } |
151 | | /// Get window for this canvas |
152 | 0 | BackBufferSharedPtr const & getBackBuffer() const { return maDeviceHelper.getBackBuffer(); } |
153 | | |
154 | | private: |
155 | | css::uno::Sequence< css::uno::Any > maArguments; |
156 | | }; |
157 | | |
158 | | typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef; |
159 | | typedef ::rtl::Reference< SpriteCanvas > DeviceRef; |
160 | | |
161 | | } |
162 | | |
163 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |