Bump for 3.6-28
[LibreOffice.git] / cppcanvas / source / mtfrenderer / cachedprimitivebase.cxx
blob19e8badfbec31558c78c8dc600d97356cf814aad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <rtl/logfile.hxx>
32 #include <com/sun/star/rendering/RepaintResult.hpp>
34 #include <basegfx/matrix/b2dhommatrix.hxx>
35 #include <canvas/canvastools.hxx>
36 #include <cppcanvas/canvas.hxx>
38 #include "cachedprimitivebase.hxx"
40 using namespace ::com::sun::star;
42 namespace cppcanvas
44 namespace internal
46 CachedPrimitiveBase::CachedPrimitiveBase( const CanvasSharedPtr& rCanvas,
47 bool bOnlyRedrawWithSameTransform ) :
48 mpCanvas( rCanvas ),
49 mxCachedPrimitive(),
50 maLastTransformation(),
51 mbOnlyRedrawWithSameTransform( bOnlyRedrawWithSameTransform )
53 // TODO(F2): also store last view transform, and refuse to
54 // redraw if changed.
57 bool CachedPrimitiveBase::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
59 RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::CachedPrimitiveBase::render()" );
60 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::CachedPrimitiveBase: 0x%X", this );
62 const rendering::ViewState& rViewState( mpCanvas->getViewState() );
63 ::basegfx::B2DHomMatrix aTotalTransform;
65 ::canvas::tools::getViewStateTransform( aTotalTransform,
66 rViewState );
67 aTotalTransform *= rTransformation;
69 // can we use the cached primitive? For that, it must be
70 // present in the first place, and, if
71 // mbOnlyRedrawWithSameTransform is true, the overall
72 // transformation must be the same.
73 if( mxCachedPrimitive.is() &&
74 (!mbOnlyRedrawWithSameTransform ||
75 maLastTransformation == aTotalTransform) )
77 if( mxCachedPrimitive->redraw( rViewState ) ==
78 rendering::RepaintResult::REDRAWN )
80 // cached repaint succeeded, done.
81 return true;
85 maLastTransformation = aTotalTransform;
87 // delegate rendering to derived classes
88 return renderPrimitive( mxCachedPrimitive,
89 rTransformation );
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */