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 <canvasgraphichelper.hxx>
23 #include <com/sun/star/rendering/XCanvas.hpp>
25 #include <canvas/canvastools.hxx>
26 #include <basegfx/utils/canvastools.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
28 #include <osl/diagnose.h>
32 using namespace ::com::sun::star
;
34 /* Implementation of CanvasGraphicHelper class */
36 namespace cppcanvas::internal
38 CanvasGraphicHelper::CanvasGraphicHelper( CanvasSharedPtr xParentCanvas
) :
39 mpCanvas(std::move( xParentCanvas
))
41 OSL_ENSURE( mpCanvas
&& mpCanvas
->getUNOCanvas().is(),
42 "CanvasGraphicHelper::CanvasGraphicHelper: no valid canvas" );
44 ::canvas::tools::initRenderState( maRenderState
);
47 void CanvasGraphicHelper::setTransformation( const ::basegfx::B2DHomMatrix
& rMatrix
)
49 ::canvas::tools::setRenderStateTransform( maRenderState
, rMatrix
);
52 void CanvasGraphicHelper::setClip( const ::basegfx::B2DPolyPolygon
& rClipPoly
)
54 // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write
55 maClipPolyPolygon
= rClipPoly
;
56 maRenderState
.Clip
.clear();
59 void CanvasGraphicHelper::setClip()
61 maClipPolyPolygon
.reset();
62 maRenderState
.Clip
.clear();
65 const rendering::RenderState
& CanvasGraphicHelper::getRenderState() const
67 if( maClipPolyPolygon
&& !maRenderState
.Clip
.is() )
69 uno::Reference
< rendering::XCanvas
> xCanvas( mpCanvas
->getUNOCanvas() );
73 maRenderState
.Clip
= ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
81 void CanvasGraphicHelper::setCompositeOp( sal_Int8 aOp
)
83 maRenderState
.CompositeOperation
= aOp
;
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */