Update git submodules
[LibreOffice.git] / canvas / source / cairo / cairo_canvasbitmap.hxx
blobf2371821023f9ad9c253276da041c5459083740d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #pragma once
22 #include <cppuhelper/compbase.hxx>
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>
30 #include <base/bitmapcanvasbase.hxx>
31 #include <base/basemutexhelper.hxx>
32 #include <base/integerbitmapbase.hxx>
34 #include "cairo_canvashelper.hxx"
35 #include "cairo_repainttarget.hxx"
38 /* Definition of CanvasBitmap class */
40 namespace cairocanvas
42 typedef ::cppu::WeakComponentImplHelper< css::rendering::XBitmapCanvas,
43 css::rendering::XIntegerBitmap,
44 css::lang::XServiceInfo,
45 css::beans::XFastPropertySet > CanvasBitmapBase_Base;
46 class CanvasBitmapSpriteSurface_Base :
47 public ::canvas::BaseMutexHelper<CanvasBitmapBase_Base>,
48 public SurfaceProvider
52 typedef ::canvas::IntegerBitmapBase<
53 canvas::BitmapCanvasBase2<
54 CanvasBitmapSpriteSurface_Base,
55 CanvasHelper,
56 ::osl::MutexGuard,
57 ::cppu::OWeakObject> > CanvasBitmap_Base;
59 class CanvasBitmap : public CanvasBitmap_Base,
60 public RepaintTarget
62 public:
63 /** Create a canvas bitmap for the given surface
65 @param rSize
66 Size of the bitmap
68 @param rDevice
69 Reference device, with which bitmap should be compatible
71 CanvasBitmap( const ::basegfx::B2ISize& rSize,
72 SurfaceProviderRef rDevice,
73 css::rendering::XGraphicDevice* pDevice,
74 bool bHasAlpha );
76 /// Dispose all internal references
77 virtual void disposeThis() override;
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 )
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;
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;
98 // RepaintTarget
99 virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
100 const css::rendering::ViewState& viewState,
101 const css::rendering::RenderState& renderState ) override;
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 two 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 (sal_Int64)
112 virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override;
113 virtual void SAL_CALL setFastPropertyValue(sal_Int32, const css::uno::Any&) override {}
115 private:
116 SurfaceProviderRef mpSurfaceProvider;
117 ::cairo::SurfaceSharedPtr mpBufferSurface;
118 ::cairo::CairoSharedPtr mpBufferCairo;
120 const ::basegfx::B2ISize maSize;
121 const bool mbHasAlpha;
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */