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 .
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>
29 #include <vcl/bitmapex.hxx>
31 #include <base/bitmapcanvasbase.hxx>
32 #include <base/basemutexhelper.hxx>
33 #include <base/integerbitmapbase.hxx>
34 #include "canvasbitmaphelper.hxx"
36 #include "impltools.hxx"
37 #include "repainttarget.hxx"
40 /* Definition of CanvasBitmap class */
44 typedef ::cppu::WeakComponentImplHelper
< css::rendering::XBitmapCanvas
,
45 css::rendering::XIntegerBitmap
,
46 css::lang::XServiceInfo
,
47 css::beans::XFastPropertySet
> CanvasBitmapBase_Base
;
48 typedef ::canvas::IntegerBitmapBase
<
49 canvas::BitmapCanvasBase2
<
50 ::canvas::BaseMutexHelper
< CanvasBitmapBase_Base
>,
53 ::cppu::OWeakObject
> > CanvasBitmap_Base
;
55 class CanvasBitmap
: public CanvasBitmap_Base
,
59 /** Must be called with locked Solar mutex
62 Size in pixel of the bitmap to generate
65 When true, bitmap will have an alpha channel
68 Reference device, with which bitmap should be compatible
70 CanvasBitmap( const ::Size
& rSize
,
72 css::rendering::XGraphicDevice
& rDevice
,
73 const OutDevProviderSharedPtr
& rOutDevProvider
);
75 /// Must be called with locked Solar mutex
76 CanvasBitmap( const BitmapEx
& rBitmap
,
77 css::rendering::XGraphicDevice
& rDevice
,
78 const OutDevProviderSharedPtr
& rOutDevProvider
);
81 virtual OUString SAL_CALL
getImplementationName( ) override
;
82 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
83 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
85 // RepaintTarget interface
86 virtual bool repaint( const GraphicObjectSharedPtr
& rGrf
,
87 const css::rendering::ViewState
& viewState
,
88 const css::rendering::RenderState
& renderState
,
91 const GraphicAttr
& rAttr
) const override
;
93 /// Not threadsafe! Returned object is shared!
94 BitmapEx
getBitmap() const;
97 // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
98 // handle values have these meanings:
99 // 0 ... get pointer to BitmapEx
100 // 1 ... get X pixmap handle to rgb content
101 // 2 ... get X pixmap handle to alpha mask
102 // returned any contains either BitmapEx pointer or array of three Any value
103 // 1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
104 // 2nd the pixmap handle (sal_Int64)
105 // 3rd the pixmap depth
106 virtual css::uno::Any SAL_CALL
getFastPropertyValue(sal_Int32 nHandle
) override
;
107 virtual void SAL_CALL
setFastPropertyValue(sal_Int32
, const css::uno::Any
&) override
{}
110 /** MUST hold here, too, since CanvasHelper only contains a
111 raw pointer (without refcounting)
113 css::uno::Reference
<css::rendering::XGraphicDevice
> mxDevice
;
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */