Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <canvas/debug.hxx>
31 : : #include <tools/diagnose_ex.h>
32 : : #include "canvasbitmap.hxx"
33 : :
34 : : #include <vcl/bmpacc.hxx>
35 : :
36 : : using namespace ::com::sun::star;
37 : :
38 : :
39 : : namespace vclcanvas
40 : : {
41 : : // Currently, the only way to generate an XBitmap is from
42 : : // XGraphicDevice.getCompatibleBitmap(). Therefore, we don't even
43 : : // take a bitmap here, but a VDev directly.
44 : 0 : CanvasBitmap::CanvasBitmap( const ::Size& rSize,
45 : : bool bAlphaBitmap,
46 : : rendering::XGraphicDevice& rDevice,
47 : 0 : const OutDevProviderSharedPtr& rOutDevProvider )
48 : : {
49 : : // create bitmap for given reference device
50 : : // ========================================
51 : 0 : const sal_uInt16 nBitCount( (sal_uInt16)24U );
52 : 0 : const BitmapPalette* pPalette = NULL;
53 : :
54 : 0 : Bitmap aBitmap( rSize, nBitCount, pPalette );
55 : :
56 : : // only create alpha channel bitmap, if factory requested
57 : : // that. Providing alpha-channeled bitmaps by default has,
58 : : // especially under VCL, a huge performance penalty (have to
59 : : // use alpha VDev, then).
60 : 0 : if( bAlphaBitmap )
61 : : {
62 : 0 : AlphaMask aAlpha ( rSize );
63 : :
64 : : maCanvasHelper.init( BitmapEx( aBitmap, aAlpha ),
65 : : rDevice,
66 : 0 : rOutDevProvider );
67 : : }
68 : : else
69 : : {
70 : : maCanvasHelper.init( BitmapEx( aBitmap ),
71 : : rDevice,
72 : 0 : rOutDevProvider );
73 : 0 : }
74 : 0 : }
75 : :
76 : 0 : CanvasBitmap::CanvasBitmap( const BitmapEx& rBitmap,
77 : : rendering::XGraphicDevice& rDevice,
78 : 0 : const OutDevProviderSharedPtr& rOutDevProvider )
79 : : {
80 : 0 : maCanvasHelper.init( rBitmap, rDevice, rOutDevProvider );
81 : 0 : }
82 : :
83 : : #define IMPLEMENTATION_NAME "VCLCanvas.CanvasBitmap"
84 : : #define SERVICE_NAME "com.sun.star.rendering.CanvasBitmap"
85 : :
86 : 0 : ::rtl::OUString SAL_CALL CanvasBitmap::getImplementationName( ) throw (uno::RuntimeException)
87 : : {
88 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
89 : : }
90 : :
91 : 0 : sal_Bool SAL_CALL CanvasBitmap::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
92 : : {
93 : 0 : return ServiceName == SERVICE_NAME;
94 : : }
95 : :
96 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames( ) throw (uno::RuntimeException)
97 : : {
98 : 0 : uno::Sequence< ::rtl::OUString > aRet(1);
99 : 0 : aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
100 : :
101 : 0 : return aRet;
102 : : }
103 : :
104 : 0 : BitmapEx CanvasBitmap::getBitmap() const
105 : : {
106 : 0 : SolarMutexGuard aGuard;
107 : :
108 : : // TODO(T3): Rework to use shared_ptr all over the place for
109 : : // BmpEx. This is highly un-threadsafe
110 : 0 : return maCanvasHelper.getBitmap();
111 : : }
112 : :
113 : 0 : bool CanvasBitmap::repaint( const GraphicObjectSharedPtr& rGrf,
114 : : const rendering::ViewState& viewState,
115 : : const rendering::RenderState& renderState,
116 : : const ::Point& rPt,
117 : : const ::Size& rSz,
118 : : const GraphicAttr& rAttr ) const
119 : : {
120 : 0 : SolarMutexGuard aGuard;
121 : :
122 : 0 : mbSurfaceDirty = true;
123 : :
124 : 0 : return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
125 : : }
126 : :
127 : 0 : uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle ) throw (uno::RuntimeException)
128 : : {
129 : 0 : if( nHandle == 0 ) {
130 : 0 : BitmapEx* pBitmapEx = new BitmapEx( getBitmap() );
131 : :
132 : 0 : return uno::Any( reinterpret_cast<sal_Int64>( pBitmapEx ) );
133 : : }
134 : :
135 : 0 : return uno::Any( sal_Int64(0) );
136 : : }
137 : 0 : }
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|