LibreOffice Module canvas (master) 1
canvasbitmap.cxx
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#include <sal/config.h>
21
23
24#include "canvasbitmap.hxx"
25
26
27using namespace ::com::sun::star;
28
29
30namespace vclcanvas
31{
32 // Currently, the only way to generate an XBitmap is from
33 // XGraphicDevice.getCompatibleBitmap(). Therefore, we don't even
34 // take a bitmap here, but a VDev directly.
35 CanvasBitmap::CanvasBitmap( const ::Size& rSize,
36 bool bAlphaBitmap,
37 rendering::XGraphicDevice& rDevice,
38 const OutDevProviderSharedPtr& rOutDevProvider )
39 {
40 // create bitmap for given reference device
41 // ========================================
42 Bitmap aBitmap(rSize, vcl::PixelFormat::N24_BPP);
43
44 // only create alpha channel bitmap, if factory requested
45 // that. Providing alpha-channeled bitmaps by default has,
46 // especially under VCL, a huge performance penalty (have to
47 // use alpha VDev, then).
48 if( bAlphaBitmap )
49 {
50 AlphaMask aAlpha ( rSize );
51
52 maCanvasHelper.init( BitmapEx( aBitmap, aAlpha ),
53 rDevice,
54 rOutDevProvider );
55 }
56 else
57 {
58 maCanvasHelper.init( BitmapEx( aBitmap ),
59 rDevice,
60 rOutDevProvider );
61 }
62 }
63
65 rendering::XGraphicDevice& rDevice,
66 const OutDevProviderSharedPtr& rOutDevProvider )
67 {
68 maCanvasHelper.init( rBitmap, rDevice, rOutDevProvider );
69 }
70
71
73 {
74 return "VCLCanvas.CanvasBitmap";
75 }
76
77 sal_Bool SAL_CALL CanvasBitmap::supportsService( const OUString& ServiceName )
78 {
79 return cppu::supportsService( this, ServiceName );
80 }
81
82 uno::Sequence< OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames( )
83 {
84 return { "com.sun.star.rendering.CanvasBitmap" };
85 }
86
88 {
89 SolarMutexGuard aGuard;
90
91 // TODO(T3): Rework to use shared_ptr all over the place for
92 // BmpEx. This is highly un-threadsafe
93 return maCanvasHelper.getBitmap();
94 }
95
97 const rendering::ViewState& viewState,
98 const rendering::RenderState& renderState,
99 const ::Point& rPt,
100 const ::Size& rSz,
101 const GraphicAttr& rAttr ) const
102 {
103 SolarMutexGuard aGuard;
104
105 mbSurfaceDirty = true;
106
107 return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
108 }
109
110 uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle )
111 {
112 if( nHandle == 0 ) {
113 BitmapEx* pBitmapEx = new BitmapEx( getBitmap() );
114
115 return uno::Any( reinterpret_cast<sal_Int64>( pBitmapEx ) );
116 }
117
118 return uno::Any( sal_Int64(0) );
119 }
120}
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
BitmapEx getBitmap() const
Not threadsafe! Returned object is shared!
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual bool repaint(const GraphicObjectSharedPtr &rGrf, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const ::Point &rPt, const ::Size &rSz, const GraphicAttr &rAttr) const override
CanvasBitmap(const ::Size &rSize, bool bAlphaBitmap, css::rendering::XGraphicDevice &rDevice, const OutDevProviderSharedPtr &rOutDevProvider)
Must be called with locked Solar mutex.
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString SAL_CALL getImplementationName() override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::shared_ptr< OutDevProvider > OutDevProviderSharedPtr
std::shared_ptr< GraphicObject > GraphicObjectSharedPtr
sal_Int32 nHandle
unsigned char sal_Bool