bump product version to 6.3.0.0.beta1
[LibreOffice.git] / cppcanvas / source / tools / canvasgraphichelper.cxx
blob592179f423647786134c68ad06dc576186fb5e95
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 <canvasgraphichelper.hxx>
23 #include <com/sun/star/rendering/XGraphicDevice.hpp>
24 #include <com/sun/star/rendering/XCanvas.hpp>
25 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
27 #include <canvas/canvastools.hxx>
28 #include <basegfx/utils/canvastools.hxx>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
31 #include <cppcanvas/polypolygon.hxx>
32 #include <tools.hxx>
35 using namespace ::com::sun::star;
37 /* Implementation of CanvasGraphicHelper class */
39 namespace cppcanvas
42 namespace internal
44 CanvasGraphicHelper::CanvasGraphicHelper( const CanvasSharedPtr& rParentCanvas ) :
45 maClipPolyPolygon(),
46 mpCanvas( rParentCanvas )
48 OSL_ENSURE( mpCanvas.get() != nullptr &&
49 mpCanvas->getUNOCanvas().is(),
50 "CanvasGraphicHelper::CanvasGraphicHelper: no valid canvas" );
52 ::canvas::tools::initRenderState( maRenderState );
55 void CanvasGraphicHelper::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
57 ::canvas::tools::setRenderStateTransform( maRenderState, rMatrix );
60 void CanvasGraphicHelper::setClip( const ::basegfx::B2DPolyPolygon& rClipPoly )
62 // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write
63 maClipPolyPolygon.reset( rClipPoly );
64 maRenderState.Clip.clear();
67 void CanvasGraphicHelper::setClip()
69 maClipPolyPolygon.reset();
70 maRenderState.Clip.clear();
73 const rendering::RenderState& CanvasGraphicHelper::getRenderState() const
75 if( maClipPolyPolygon && !maRenderState.Clip.is() )
77 uno::Reference< rendering::XCanvas > xCanvas( mpCanvas->getUNOCanvas() );
78 if( !xCanvas.is() )
79 return maRenderState;
81 maRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
82 xCanvas->getDevice(),
83 *maClipPolyPolygon );
86 return maRenderState;
89 void CanvasGraphicHelper::setCompositeOp( sal_Int8 aOp )
91 maRenderState.CompositeOperation = aOp;
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */