LibreOffice Module canvas (master)  1
cairo_canvasbitmap.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 
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
26 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
27 #include <com/sun/star/beans/XFastPropertySet.hpp>
28 #include <comphelper/uno3.hxx>
29 
31 #include <base/basemutexhelper.hxx>
33 
34 #include "cairo_canvashelper.hxx"
35 #include "cairo_repainttarget.hxx"
36 
37 
38 /* Definition of CanvasBitmap class */
39 
40 namespace cairocanvas
41 {
42  typedef ::cppu::WeakComponentImplHelper< css::rendering::XBitmapCanvas,
43  css::rendering::XIntegerBitmap,
44  css::lang::XServiceInfo,
45  css::beans::XFastPropertySet > CanvasBitmapBase_Base;
47  public ::canvas::BaseMutexHelper<CanvasBitmapBase_Base>,
48  public SurfaceProvider
49  {
50  };
51 
52  typedef ::canvas::IntegerBitmapBase<
56  ::osl::MutexGuard,
58 
59  class CanvasBitmap : public CanvasBitmap_Base,
60  public RepaintTarget
61  {
62  public:
71  CanvasBitmap( const ::basegfx::B2ISize& rSize,
72  const SurfaceProviderRef& rDevice,
73  css::rendering::XGraphicDevice* pDevice,
74  bool bHasAlpha );
75 
77  virtual void disposeThis() override;
78 
79  // Forwarding the XComponent implementation to the
80  // cppu::ImplHelper templated base
81  // Classname Base doing refcounting Base implementing the XComponent interface
82  // | | |
83  // V V V
84  DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasBitmap, CanvasBitmapBase_Base, ::cppu::WeakComponentImplHelperBase )
85 
86  // XServiceInfo
87  virtual OUString SAL_CALL getImplementationName( ) override;
88  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
89  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
90 
91  // SurfaceProvider
92  virtual ::cairo::SurfaceSharedPtr getSurface() override;
93  virtual ::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, int aContent ) override;
94  virtual ::cairo::SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ) override;
95  virtual ::cairo::SurfaceSharedPtr changeSurface() override;
96  virtual OutputDevice* getOutputDevice() override;
97 
98  // RepaintTarget
99  virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
100  const css::rendering::ViewState& viewState,
101  const css::rendering::RenderState& renderState ) override;
102 
103  // XFastPropertySet
104  // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
105  // handle values have these meanings:
106  // 0 ... get pointer to BitmapEx
107  // 1 ... get X pixmap handle to rgb content
108  // 2 ... FIXME: leftover? ever called with this? always returns nothing (empty Any)
109  // returned any contains either BitmapEx pointer or array of three Any value
110  // 1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
111  // 2nd the pixmap handle
112  // 3rd the pixmap depth
113  virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override;
114  virtual void SAL_CALL setFastPropertyValue(sal_Int32, const css::uno::Any&) override {}
115 
116  private:
120 
121  const ::basegfx::B2ISize maSize;
122  const bool mbHasAlpha;
123  };
124 }
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Target interface for XCachedPrimitive implementations.
virtual void disposeThis() override
Dispose all internal references.
const ::basegfx::B2ISize maSize
Target interface for XCachedPrimitive implementations.
virtual OUString SAL_CALL getImplementationName() override
#define DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS(classname, baseclass, implhelper)
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override
::canvas::IntegerBitmapBase< canvas::BitmapCanvasBase2< CanvasBitmapSpriteSurface_Base, CanvasHelper,::osl::MutexGuard,::cppu::OWeakObject > > CanvasBitmap_Base
std::shared_ptr< cairo_t > CairoSharedPtr
Base class, initializing its own baseclass with m_aMutex.
virtual ::cairo::SurfaceSharedPtr getSurface() override
virtual ::cairo::SurfaceSharedPtr createSurface(const ::basegfx::B2ISize &rSize, int aContent) override
CanvasBitmap(const ::basegfx::B2ISize &rSize, const SurfaceProviderRef &rDevice, css::rendering::XGraphicDevice *pDevice, bool bHasAlpha)
Create a canvas bitmap for the given surface.
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
sal_Int32 nHandle
std::shared_ptr< Surface > SurfaceSharedPtr
virtual bool repaint(const ::cairo::SurfaceSharedPtr &pSurface, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState) override
unsigned char sal_Bool
::cairo::SurfaceSharedPtr mpBufferSurface
SurfaceProviderRef mpSurfaceProvider
::cppu::WeakComponentImplHelper< css::rendering::XBitmapCanvas, css::rendering::XIntegerBitmap, css::lang::XServiceInfo, css::beans::XFastPropertySet > CanvasBitmapBase_Base
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ::cairo::SurfaceSharedPtr changeSurface() override
virtual OutputDevice * getOutputDevice() override
virtual void SAL_CALL setFastPropertyValue(sal_Int32, const css::uno::Any &) override
::cairo::CairoSharedPtr mpBufferCairo