android: Update app-specific/MIME type icons
[LibreOffice.git] / cppcanvas / source / mtfrenderer / cachedprimitivebase.cxx
blobe5664cabfc1da014b0aadbd1e5e59111e115835a
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 <com/sun/star/rendering/RepaintResult.hpp>
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <canvas/canvastools.hxx>
25 #include <cppcanvas/canvas.hxx>
27 #include "cachedprimitivebase.hxx"
28 #include <sal/log.hxx>
29 #include <utility>
31 using namespace ::com::sun::star;
33 namespace cppcanvas::internal
35 CachedPrimitiveBase::CachedPrimitiveBase( CanvasSharedPtr xCanvas,
36 bool bOnlyRedrawWithSameTransform ) :
37 mpCanvas(std::move( xCanvas )),
38 mbOnlyRedrawWithSameTransform( bOnlyRedrawWithSameTransform )
40 // TODO(F2): also store last view transform, and refuse to
41 // redraw if changed.
44 bool CachedPrimitiveBase::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
46 SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::CachedPrimitiveBase::render()" );
47 SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::CachedPrimitiveBase: 0x" << std::hex << this );
49 const rendering::ViewState& rViewState( mpCanvas->getViewState() );
50 ::basegfx::B2DHomMatrix aTotalTransform;
52 ::canvas::tools::getViewStateTransform( aTotalTransform,
53 rViewState );
54 aTotalTransform *= rTransformation;
56 // can we use the cached primitive? For that, it must be
57 // present in the first place, and, if
58 // mbOnlyRedrawWithSameTransform is true, the overall
59 // transformation must be the same.
60 if( mxCachedPrimitive.is() &&
61 (!mbOnlyRedrawWithSameTransform ||
62 maLastTransformation == aTotalTransform) )
64 if( mxCachedPrimitive->redraw( rViewState ) ==
65 rendering::RepaintResult::REDRAWN )
67 // cached repaint succeeded, done.
68 return true;
72 maLastTransformation = aTotalTransform;
74 // delegate rendering to derived classes
75 return renderPrimitive( mxCachedPrimitive,
76 rTransformation );
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */