1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <com/sun/star/uno/XComponentContext.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/lang/XServiceName.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/awt/XWindowListener.hpp>
27 #include <com/sun/star/util/XUpdatable.hpp>
28 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
29 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
30 #include <com/sun/star/rendering/XGraphicDevice.hpp>
31 #include <com/sun/star/rendering/XBufferController.hpp>
33 #include <cppuhelper/compbase.hxx>
34 #include <comphelper/uno3.hxx>
36 #include <base/spritecanvasbase.hxx>
37 #include <base/spritesurface.hxx>
38 #include <base/disambiguationhelper.hxx>
39 #include <base/bufferedgraphicdevicebase.hxx>
41 #include "cairo_spritedevicehelper.hxx"
42 #include "cairo_repainttarget.hxx"
43 #include "cairo_surfaceprovider.hxx"
44 #include "cairo_spritecanvashelper.hxx"
48 typedef ::cppu::WeakComponentImplHelper
< css::rendering::XSpriteCanvas
,
49 css::rendering::XIntegerBitmap
,
50 css::rendering::XGraphicDevice
,
51 css::lang::XMultiServiceFactory
,
52 css::rendering::XBufferController
,
53 css::awt::XWindowListener
,
54 css::util::XUpdatable
,
55 css::beans::XPropertySet
,
56 css::lang::XServiceName
,
57 css::lang::XServiceInfo
> WindowGraphicDeviceBase_Base
;
58 typedef ::canvas::BufferedGraphicDeviceBase
< ::canvas::DisambiguationHelper
< WindowGraphicDeviceBase_Base
>,
61 ::cppu::OWeakObject
> SpriteCanvasBase_Base
;
62 /** Mixin SpriteSurface
64 Have to mixin the SpriteSurface before deriving from
65 ::canvas::SpriteCanvasBase, as this template should already
66 implement some of those interface methods.
68 The reason why this appears kinda convoluted is the fact that
69 we cannot specify non-IDL types as WeakComponentImplHelper
70 template args, and furthermore, don't want to derive
71 ::canvas::SpriteCanvasBase directly from
72 ::canvas::SpriteSurface (because derivees of
73 ::canvas::SpriteCanvasBase have to explicitly forward the
74 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
75 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
76 remain a base class that provides implementation, not to
77 enforce any specific interface on its derivees.
79 class SpriteCanvasBaseSpriteSurface_Base
: public SpriteCanvasBase_Base
,
80 public ::canvas::SpriteSurface
,
81 public SurfaceProvider
85 typedef ::canvas::SpriteCanvasBase
< SpriteCanvasBaseSpriteSurface_Base
,
88 ::cppu::OWeakObject
> SpriteCanvasBaseT
;
90 /** Product of this component's factory.
92 The SpriteCanvas object combines the actual Window canvas with
93 the XGraphicDevice interface. This is because there's a
94 one-to-one relation between them, anyway, since each window
95 can have exactly one canvas and one associated
96 XGraphicDevice. And to avoid messing around with circular
97 references, this is implemented as one single object.
99 class SpriteCanvas
: public SpriteCanvasBaseT
,
103 SpriteCanvas( const css::uno::Sequence
< css::uno::Any
>& aArguments
,
104 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
108 /// Dispose all internal references
109 virtual void disposeThis() override
;
111 // Forwarding the XComponent implementation to the
112 // cppu::ImplHelper templated base
113 // Classname Base doing refcounting Base implementing the XComponent interface
116 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas
, WindowGraphicDeviceBase_Base
, ::cppu::WeakComponentImplHelperBase
)
118 // XBufferController (partial)
119 virtual sal_Bool SAL_CALL
showBuffer( sal_Bool bUpdateAll
) override
;
120 virtual sal_Bool SAL_CALL
switchBuffer( sal_Bool bUpdateAll
) override
;
122 // XSpriteCanvas (partial)
123 virtual sal_Bool SAL_CALL
updateScreen( sal_Bool bUpdateAll
) override
;
126 virtual OUString SAL_CALL
getServiceName( ) override
;
129 virtual sal_Bool SAL_CALL
supportsService(const OUString
& sServiceName
) override
;
130 virtual OUString SAL_CALL
getImplementationName() override
;
131 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
134 virtual ::cairo::SurfaceSharedPtr
getSurface() override
;
135 virtual ::cairo::SurfaceSharedPtr
createSurface( const ::basegfx::B2ISize
& rSize
, int aContent
) override
;
136 virtual ::cairo::SurfaceSharedPtr
createSurface( ::Bitmap
& rBitmap
) override
;
137 virtual ::cairo::SurfaceSharedPtr
changeSurface() override
;
138 virtual OutputDevice
* getOutputDevice() override
;
141 virtual bool repaint( const ::cairo::SurfaceSharedPtr
& pSurface
,
142 const css::rendering::ViewState
& viewState
,
143 const css::rendering::RenderState
& renderState
) override
;
145 ::cairo::SurfaceSharedPtr
const & getWindowSurface() const;
146 ::cairo::SurfaceSharedPtr
const & getBufferSurface() const;
148 const ::basegfx::B2ISize
& getSizePixel() const;
149 void setSizePixel( const ::basegfx::B2ISize
& rSize
);
153 css::uno::Sequence
< css::uno::Any
> maArguments
;
156 typedef ::rtl::Reference
< SpriteCanvas
> SpriteCanvasRef
;
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */