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 .
21 #include "implbitmap.hxx"
22 #include "implbitmapcanvas.hxx"
24 #include <osl/diagnose.h>
27 using namespace ::com::sun::star
;
29 namespace cppcanvas::internal
32 ImplBitmap::ImplBitmap( const CanvasSharedPtr
& rParentCanvas
,
33 const uno::Reference
< rendering::XBitmap
>& rBitmap
) :
34 CanvasGraphicHelper( rParentCanvas
),
37 OSL_ENSURE( mxBitmap
.is(), "ImplBitmap::ImplBitmap: no valid bitmap" );
39 uno::Reference
< rendering::XBitmapCanvas
> xBitmapCanvas( rBitmap
,
41 if( xBitmapCanvas
.is() )
42 mpBitmapCanvas
= std::make_shared
<ImplBitmapCanvas
>(
43 uno::Reference
< rendering::XBitmapCanvas
>(rBitmap
,
47 ImplBitmap::~ImplBitmap()
51 bool ImplBitmap::draw() const
53 CanvasSharedPtr
pCanvas( getCanvas() );
55 OSL_ENSURE( pCanvas
&& pCanvas
->getUNOCanvas().is(),
56 "ImplBitmap::draw: invalid canvas" );
59 !pCanvas
->getUNOCanvas().is() )
64 // TODO(P1): implement caching
65 pCanvas
->getUNOCanvas()->drawBitmap( mxBitmap
,
66 pCanvas
->getViewState(),
72 void ImplBitmap::drawAlphaModulated( double nAlphaModulation
) const
74 CanvasSharedPtr
pCanvas( getCanvas() );
76 OSL_ENSURE( pCanvas
&& pCanvas
->getUNOCanvas().is(),
77 "ImplBitmap::drawAlphaModulated(): invalid canvas" );
80 !pCanvas
->getUNOCanvas().is() )
85 rendering::RenderState
aLocalState( getRenderState() );
86 uno::Sequence
<rendering::ARGBColor
> aCol
{ { nAlphaModulation
, 1.0, 1.0, 1.0 } };
87 aLocalState
.DeviceColor
=
88 pCanvas
->getUNOCanvas()->getDevice()->getDeviceColorSpace()->convertFromARGB(aCol
);
90 // TODO(P1): implement caching
91 pCanvas
->getUNOCanvas()->drawBitmapModulated( mxBitmap
,
92 pCanvas
->getViewState(),
96 BitmapCanvasSharedPtr
ImplBitmap::getBitmapCanvas() const
98 return mpBitmapCanvas
;
101 uno::Reference
< rendering::XBitmap
> ImplBitmap::getUNOBitmap() const
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */