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
;
46 CachedPrimitiveBase::CachedPrimitiveBase( const CanvasSharedPtr
& rCanvas
,
47 bool bOnlyRedrawWithSameTransform
) :
50 maLastTransformation(),
51 mbOnlyRedrawWithSameTransform( bOnlyRedrawWithSameTransform
)
53 // TODO(F2): also store last view transform, and refuse to
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
,
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.
85 maLastTransformation
= aTotalTransform
;
87 // delegate rendering to derived classes
88 return renderPrimitive( mxCachedPrimitive
,
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */