Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <rtl/logfile.hxx>
31 : :
32 : : #include <com/sun/star/rendering/RepaintResult.hpp>
33 : :
34 : : #include <basegfx/matrix/b2dhommatrix.hxx>
35 : : #include <canvas/canvastools.hxx>
36 : : #include <cppcanvas/canvas.hxx>
37 : :
38 : : #include "cachedprimitivebase.hxx"
39 : :
40 : : using namespace ::com::sun::star;
41 : :
42 : : namespace cppcanvas
43 : : {
44 : : namespace internal
45 : : {
46 : 0 : CachedPrimitiveBase::CachedPrimitiveBase( const CanvasSharedPtr& rCanvas,
47 : : bool bOnlyRedrawWithSameTransform ) :
48 : : mpCanvas( rCanvas ),
49 : : mxCachedPrimitive(),
50 : : maLastTransformation(),
51 [ # # ][ # # ]: 0 : mbOnlyRedrawWithSameTransform( bOnlyRedrawWithSameTransform )
52 : : {
53 : : // TODO(F2): also store last view transform, and refuse to
54 : : // redraw if changed.
55 : 0 : }
56 : :
57 : 0 : bool CachedPrimitiveBase::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
58 : : {
59 : : RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::CachedPrimitiveBase::render()" );
60 : : RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::CachedPrimitiveBase: 0x%X", this );
61 : :
62 [ # # ]: 0 : const rendering::ViewState& rViewState( mpCanvas->getViewState() );
63 [ # # ]: 0 : ::basegfx::B2DHomMatrix aTotalTransform;
64 : :
65 : : ::canvas::tools::getViewStateTransform( aTotalTransform,
66 [ # # ]: 0 : rViewState );
67 [ # # ]: 0 : aTotalTransform *= rTransformation;
68 : :
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 [ # # ][ # # ]: 0 : if( mxCachedPrimitive.is() &&
[ # # ][ # # ]
74 : 0 : (!mbOnlyRedrawWithSameTransform ||
75 [ # # ]: 0 : maLastTransformation == aTotalTransform) )
76 : : {
77 [ # # ][ # # ]: 0 : if( mxCachedPrimitive->redraw( rViewState ) ==
[ # # ]
78 : : rendering::RepaintResult::REDRAWN )
79 : : {
80 : : // cached repaint succeeded, done.
81 : 0 : return true;
82 : : }
83 : : }
84 : :
85 [ # # ]: 0 : maLastTransformation = aTotalTransform;
86 : :
87 : : // delegate rendering to derived classes
88 : : return renderPrimitive( mxCachedPrimitive,
89 [ # # ][ # # ]: 0 : rTransformation );
[ # # ]
90 : : }
91 : : }
92 : : }
93 : :
94 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|