1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include <canvas/debug.hxx>
21 #include <cppuhelper/supportsservice.hxx>
22 #include <tools/diagnose_ex.h>
23 #include "canvasbitmap.hxx"
25 #include <vcl/bmpacc.hxx>
27 using namespace ::com::sun::star
;
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
,
37 rendering::XGraphicDevice
& rDevice
,
38 const OutDevProviderSharedPtr
& rOutDevProvider
)
40 // create bitmap for given reference device
41 // ========================================
42 const sal_uInt16
nBitCount( (sal_uInt16
)24U );
43 const BitmapPalette
* pPalette
= NULL
;
45 Bitmap
aBitmap( rSize
, nBitCount
, pPalette
);
47 // only create alpha channel bitmap, if factory requested
48 // that. Providing alpha-channeled bitmaps by default has,
49 // especially under VCL, a huge performance penalty (have to
50 // use alpha VDev, then).
53 AlphaMask
aAlpha ( rSize
);
55 maCanvasHelper
.init( BitmapEx( aBitmap
, aAlpha
),
61 maCanvasHelper
.init( BitmapEx( aBitmap
),
67 CanvasBitmap::CanvasBitmap( const BitmapEx
& rBitmap
,
68 rendering::XGraphicDevice
& rDevice
,
69 const OutDevProviderSharedPtr
& rOutDevProvider
)
71 maCanvasHelper
.init( rBitmap
, rDevice
, rOutDevProvider
);
75 OUString SAL_CALL
CanvasBitmap::getImplementationName( ) throw (uno::RuntimeException
, std::exception
)
77 return OUString( "VCLCanvas.CanvasBitmap" );
80 sal_Bool SAL_CALL
CanvasBitmap::supportsService( const OUString
& ServiceName
) throw (uno::RuntimeException
, std::exception
)
82 return cppu::supportsService( this, ServiceName
);
85 uno::Sequence
< OUString
> SAL_CALL
CanvasBitmap::getSupportedServiceNames( ) throw (uno::RuntimeException
, std::exception
)
87 uno::Sequence
< OUString
> aRet(1);
88 aRet
[0] = "com.sun.star.rendering.CanvasBitmap";
93 BitmapEx
CanvasBitmap::getBitmap() const
95 SolarMutexGuard aGuard
;
97 // TODO(T3): Rework to use shared_ptr all over the place for
98 // BmpEx. This is highly un-threadsafe
99 return maCanvasHelper
.getBitmap();
102 bool CanvasBitmap::repaint( const GraphicObjectSharedPtr
& rGrf
,
103 const rendering::ViewState
& viewState
,
104 const rendering::RenderState
& renderState
,
107 const GraphicAttr
& rAttr
) const
109 SolarMutexGuard aGuard
;
111 mbSurfaceDirty
= true;
113 return maCanvasHelper
.repaint( rGrf
, viewState
, renderState
, rPt
, rSz
, rAttr
);
116 uno::Any SAL_CALL
CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle
) throw (uno::RuntimeException
, std::exception
)
119 BitmapEx
* pBitmapEx
= new BitmapEx( getBitmap() );
121 return uno::Any( reinterpret_cast<sal_Int64
>( pBitmapEx
) );
124 return uno::Any( sal_Int64(0) );
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */