fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / canvas / source / vcl / canvasbitmap.cxx
bloba469e448ed414e5e3c00e0ea1ee72ef14d46dbf4
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 .
21 #include <canvas/debug.hxx>
22 #include <tools/diagnose_ex.h>
23 #include "canvasbitmap.hxx"
25 #include <vcl/bmpacc.hxx>
27 using namespace ::com::sun::star;
30 namespace vclcanvas
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 )
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).
51 if( bAlphaBitmap )
53 AlphaMask aAlpha ( rSize );
55 maCanvasHelper.init( BitmapEx( aBitmap, aAlpha ),
56 rDevice,
57 rOutDevProvider );
59 else
61 maCanvasHelper.init( BitmapEx( aBitmap ),
62 rDevice,
63 rOutDevProvider );
67 CanvasBitmap::CanvasBitmap( const BitmapEx& rBitmap,
68 rendering::XGraphicDevice& rDevice,
69 const OutDevProviderSharedPtr& rOutDevProvider )
71 maCanvasHelper.init( rBitmap, rDevice, rOutDevProvider );
74 #define IMPLEMENTATION_NAME "VCLCanvas.CanvasBitmap"
75 #define SERVICE_NAME "com.sun.star.rendering.CanvasBitmap"
77 OUString SAL_CALL CanvasBitmap::getImplementationName( ) throw (uno::RuntimeException)
79 return OUString( IMPLEMENTATION_NAME );
82 sal_Bool SAL_CALL CanvasBitmap::supportsService( const OUString& ServiceName ) throw (uno::RuntimeException)
84 return ServiceName == SERVICE_NAME;
87 uno::Sequence< OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames( ) throw (uno::RuntimeException)
89 uno::Sequence< OUString > aRet(1);
90 aRet[0] = OUString( SERVICE_NAME );
92 return aRet;
95 BitmapEx CanvasBitmap::getBitmap() const
97 SolarMutexGuard aGuard;
99 // TODO(T3): Rework to use shared_ptr all over the place for
100 // BmpEx. This is highly un-threadsafe
101 return maCanvasHelper.getBitmap();
104 bool CanvasBitmap::repaint( const GraphicObjectSharedPtr& rGrf,
105 const rendering::ViewState& viewState,
106 const rendering::RenderState& renderState,
107 const ::Point& rPt,
108 const ::Size& rSz,
109 const GraphicAttr& rAttr ) const
111 SolarMutexGuard aGuard;
113 mbSurfaceDirty = true;
115 return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
118 uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle ) throw (uno::RuntimeException)
120 if( nHandle == 0 ) {
121 BitmapEx* pBitmapEx = new BitmapEx( getBitmap() );
123 return uno::Any( reinterpret_cast<sal_Int64>( pBitmapEx ) );
126 return uno::Any( sal_Int64(0) );
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */