LibreOffice Module canvas (master)  1
cairo_spritecanvas.hxx
Go to the documentation of this file.
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 <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>
32 
33 #include <cppuhelper/compbase.hxx>
34 #include <comphelper/uno3.hxx>
35 
37 #include <base/spritesurface.hxx>
40 
42 #include "cairo_repainttarget.hxx"
45 
46 namespace cairocanvas
47 {
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 >,
60  ::osl::MutexGuard,
79  class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base,
81  public SurfaceProvider
82  {
83  };
84 
85  typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base,
87  ::osl::MutexGuard,
89 
99  class SpriteCanvas : public SpriteCanvasBaseT,
100  public RepaintTarget
101  {
102  public:
103  SpriteCanvas( const css::uno::Sequence< css::uno::Any >& aArguments,
104  const css::uno::Reference< css::uno::XComponentContext >& rxContext );
105 
106  void initialize();
107 
109  virtual void disposeThis() override;
110 
111  // Forwarding the XComponent implementation to the
112  // cppu::ImplHelper templated base
113  // Classname Base doing refcounting Base implementing the XComponent interface
114  // | | |
115  // V V V
116  DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase )
117 
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;
121 
122  // XSpriteCanvas (partial)
123  virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) override;
124 
125  // XServiceName
126  virtual OUString SAL_CALL getServiceName( ) override;
127 
128  // XServiceInfo
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;
132 
133  // SurfaceProvider
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;
139 
140  // RepaintTarget
141  virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
142  const css::rendering::ViewState& viewState,
143  const css::rendering::RenderState& renderState ) override;
144 
147 
148  const ::basegfx::B2ISize& getSizePixel() const;
149  void setSizePixel( const ::basegfx::B2ISize& rSize );
150  void flush();
151 
152  private:
153  css::uno::Sequence< css::uno::Any > maArguments;
154  };
155 
156  typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
157 }
158 
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Canvas surface containing sprites.
Target interface for XCachedPrimitive implementations.
virtual void disposeThis() override
Dispose all internal references.
::cppu::WeakComponentImplHelper< css::rendering::XSpriteCanvas, css::rendering::XIntegerBitmap, css::rendering::XGraphicDevice, css::lang::XMultiServiceFactory, css::rendering::XBufferController, css::awt::XWindowListener, css::util::XUpdatable, css::beans::XPropertySet, css::lang::XServiceName, css::lang::XServiceInfo > WindowGraphicDeviceBase_Base
Target interface for XCachedPrimitive implementations.
const ::basegfx::B2ISize & getSizePixel() const
#define DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS(classname, baseclass, implhelper)
SpriteCanvas(const css::uno::Sequence< css::uno::Any > &aArguments, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
::canvas::BufferedGraphicDeviceBase< ::canvas::DisambiguationHelper< WindowGraphicDeviceBase_Base >, SpriteDeviceHelper,::osl::MutexGuard,::cppu::OWeakObject > SpriteCanvasBase_Base
virtual OUString SAL_CALL getImplementationName() override
virtual ::cairo::SurfaceSharedPtr createSurface(const ::basegfx::B2ISize &rSize, int aContent) override
virtual ::cairo::SurfaceSharedPtr getSurface() override
Sequence< PropertyValue > aArguments
::rtl::Reference< SpriteCanvas > SpriteCanvasRef
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
virtual ::cairo::SurfaceSharedPtr changeSurface() override
css::uno::Sequence< css::uno::Any > maArguments
virtual sal_Bool SAL_CALL showBuffer(sal_Bool bUpdateAll) override
std::shared_ptr< Surface > SurfaceSharedPtr
virtual OUString SAL_CALL getServiceName() override
virtual bool repaint(const ::cairo::SurfaceSharedPtr &pSurface, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState) override
virtual sal_Bool SAL_CALL switchBuffer(sal_Bool bUpdateAll) override
unsigned char sal_Bool
::cairo::SurfaceSharedPtr const & getWindowSurface() const
Product of this component's factory.
void setSizePixel(const ::basegfx::B2ISize &rSize)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OutputDevice * getOutputDevice() override
const char sServiceName[]
::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base, SpriteCanvasHelper,::osl::MutexGuard,::cppu::OWeakObject > SpriteCanvasBaseT
::cairo::SurfaceSharedPtr const & getBufferSurface() const
virtual sal_Bool SAL_CALL updateScreen(sal_Bool bUpdateAll) override