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 #ifndef INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_SPRITECANVAS_HXX
21 #define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_SPRITECANVAS_HXX
22 
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/lang/XServiceName.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 #define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.Cairo"
47 #define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.Cairo"
48 
49 namespace cairocanvas
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 > WindowGraphicDeviceBase_Base;
60  typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::DisambiguationHelper< WindowGraphicDeviceBase_Base >,
62  ::osl::MutexGuard,
81  class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base,
83  public SurfaceProvider
84  {
85  };
86 
87  typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base,
89  ::osl::MutexGuard,
91 
101  class SpriteCanvas : public SpriteCanvasBaseT,
102  public RepaintTarget
103  {
104  public:
105  SpriteCanvas( const css::uno::Sequence< css::uno::Any >& aArguments,
106  const css::uno::Reference< css::uno::XComponentContext >& rxContext );
107 
108  void initialize();
109 
111  virtual void disposeThis() override;
112 
113  // Forwarding the XComponent implementation to the
114  // cppu::ImplHelper templated base
115  // Classname Base doing refcounting Base implementing the XComponent interface
116  // | | |
117  // V V V
118  DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase )
119 
120  // XBufferController (partial)
121  virtual sal_Bool SAL_CALL showBuffer( sal_Bool bUpdateAll ) override;
122  virtual sal_Bool SAL_CALL switchBuffer( sal_Bool bUpdateAll ) override;
123 
124  // XSpriteCanvas (partial)
125  virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) override;
126 
127  // XServiceName
128  virtual OUString SAL_CALL getServiceName( ) override;
129 
130  // SurfaceProvider
131  virtual ::cairo::SurfaceSharedPtr getSurface() override;
132  virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent ) override;
133  virtual ::cairo::SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ) override;
134  virtual ::cairo::SurfaceSharedPtr changeSurface() override;
135  virtual OutputDevice* getOutputDevice() override;
136 
137  // RepaintTarget
138  virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
139  const css::rendering::ViewState& viewState,
140  const css::rendering::RenderState& renderState ) override;
141 
144 
145  const ::basegfx::B2ISize& getSizePixel() const;
146  void setSizePixel( const ::basegfx::B2ISize& rSize );
147  void flush();
148 
149  private:
150  css::uno::Sequence< css::uno::Any > maArguments;
151  };
152 
153  typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
154 }
155 
156 #endif
157 
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Canvas surface containing sprites.
Target interface for XCachedPrimitive implementations.
::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 > WindowGraphicDeviceBase_Base
virtual void disposeThis() override
Dispose all internal references.
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 ::cairo::SurfaceSharedPtr createSurface(const ::basegfx::B2ISize &rSize, int aContent) override
virtual ::cairo::SurfaceSharedPtr getSurface() override
Sequence< PropertyValue > aArguments
::rtl::Reference< SpriteCanvas > SpriteCanvasRef
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 OutputDevice * getOutputDevice() override
::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