LibreOffice Module canvas (master)  1
cairo_canvascustomsprite.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 <cppuhelper/compbase.hxx>
23 #include <comphelper/uno3.hxx>
24 
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
27 #include <com/sun/star/rendering/XCustomSprite.hpp>
28 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
29 
31 
32 #include <base/basemutexhelper.hxx>
34 
35 #include <vcl/cairo.hxx>
36 
37 #include "cairo_sprite.hxx"
38 #include "cairo_canvashelper.hxx"
39 #include "cairo_repainttarget.hxx"
40 #include "cairo_spritehelper.hxx"
41 #include "cairo_spritecanvas.hxx"
42 
43 
44 namespace cairocanvas
45 {
46  typedef ::cppu::WeakComponentImplHelper< css::rendering::XCustomSprite,
47  css::rendering::XBitmapCanvas,
48  css::rendering::XIntegerBitmap,
49  css::lang::XServiceInfo > CanvasCustomSpriteBase_Base;
67  class CanvasCustomSpriteSpriteBase_Base : public ::canvas::BaseMutexHelper< CanvasCustomSpriteBase_Base >,
68  public Sprite,
69  public SurfaceProvider
70  {
71  };
72 
73  typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base,
76  ::osl::MutexGuard,
78 
79  /* Definition of CanvasCustomSprite class */
80 
81  class CanvasCustomSprite : public CanvasCustomSpriteBaseT,
82  public RepaintTarget
83  {
84  public:
99  CanvasCustomSprite( const css::geometry::RealSize2D& rSpriteSize,
100  const SpriteCanvasRef& rRefDevice );
101 
102  virtual void disposeThis() override;
103 
104  // Forwarding the XComponent implementation to the
105  // cppu::ImplHelper templated base
106  // Classname Base doing refcount Base implementing the XComponent interface
107  // | | |
108  // V V V
109  DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase )
110 
111  // XServiceInfo
112  virtual OUString SAL_CALL getImplementationName() override;
113  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
114  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
115 
116  // Sprite
117  virtual void redraw( const ::cairo::CairoSharedPtr& pCairo,
118  bool bBufferedUpdate ) const override;
119  virtual void redraw( const ::cairo::CairoSharedPtr& pCairo,
120  const ::basegfx::B2DPoint& rOrigOutputPos,
121  bool bBufferedUpdate ) const override;
122 
123  // RepaintTarget
124  virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
125  const css::rendering::ViewState& viewState,
126  const css::rendering::RenderState& renderState ) override;
127 
128  // SurfaceProvider
129  virtual ::cairo::SurfaceSharedPtr getSurface() override;
130  virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent ) override;
131  virtual ::cairo::SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ) override;
132  virtual ::cairo::SurfaceSharedPtr changeSurface() override;
133  virtual OutputDevice* getOutputDevice() override;
134 
135  private:
142  };
143 }
144 
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Target interface for XCachedPrimitive implementations.
SpriteCanvasRef mpSpriteCanvas
MUST hold here, too, since CanvasHelper only contains a raw pointer (without refcounting) ...
CanvasCustomSprite(const css::geometry::RealSize2D &rSpriteSize, const SpriteCanvasRef &rRefDevice)
Create a custom sprite.
Target interface for XCachedPrimitive implementations.
#define DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS(classname, baseclass, implhelper)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Base class, initializing its own baseclass with m_aMutex.
::cppu::WeakComponentImplHelper< css::rendering::XCustomSprite, css::rendering::XBitmapCanvas, css::rendering::XIntegerBitmap, css::lang::XServiceInfo > CanvasCustomSpriteBase_Base
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Helper class for canvas sprites.
std::shared_ptr< Surface > SurfaceSharedPtr
virtual OutputDevice * getOutputDevice() override
Specialization of canvas::Sprite interface, to also provide redraw methods.
::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base, SpriteHelper, CanvasHelper,::osl::MutexGuard,::cppu::OWeakObject > CanvasCustomSpriteBaseT
unsigned char sal_Bool
virtual OUString SAL_CALL getImplementationName() override
virtual void disposeThis() override
Object is being disposed.
virtual bool repaint(const ::cairo::SurfaceSharedPtr &pSurface, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState) override
virtual ::cairo::SurfaceSharedPtr changeSurface() override
virtual ::cairo::SurfaceSharedPtr createSurface(const ::basegfx::B2ISize &rSize, int aContent) override
virtual void redraw(const ::cairo::CairoSharedPtr &pCairo, bool bBufferedUpdate) const override
virtual ::cairo::SurfaceSharedPtr getSurface() override