Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : :
21 : : #include <canvas/debug.hxx>
22 : : #include <tools/diagnose_ex.h>
23 : :
24 : : #include "cachedbitmap.hxx"
25 : : #include "repainttarget.hxx"
26 : :
27 : : #include <com/sun/star/rendering/RepaintResult.hpp>
28 : : #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
29 : :
30 : : #include <basegfx/matrix/b2dhommatrix.hxx>
31 : : #include <basegfx/tools/canvastools.hxx>
32 : :
33 : :
34 : : using namespace ::com::sun::star;
35 : :
36 : : namespace vclcanvas
37 : : {
38 : 0 : CachedBitmap::CachedBitmap( const GraphicObjectSharedPtr& rGraphicObject,
39 : : const ::Point& rPoint,
40 : : const ::Size& rSize,
41 : : const GraphicAttr& rAttr,
42 : : const rendering::ViewState& rUsedViewState,
43 : : const rendering::RenderState& rUsedRenderState,
44 : : const uno::Reference< rendering::XCanvas >& rTarget ) :
45 : : CachedPrimitiveBase( rUsedViewState, rTarget, true ),
46 : : mpGraphicObject( rGraphicObject ),
47 : : maRenderState(rUsedRenderState),
48 : : maPoint( rPoint ),
49 : : maSize( rSize ),
50 : 0 : maAttributes( rAttr )
51 : : {
52 : 0 : }
53 : :
54 : 0 : void SAL_CALL CachedBitmap::disposing()
55 : : {
56 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
57 : :
58 : 0 : mpGraphicObject.reset();
59 : :
60 : 0 : CachedPrimitiveBase::disposing();
61 : 0 : }
62 : :
63 : 0 : ::sal_Int8 CachedBitmap::doRedraw( const rendering::ViewState& rNewState,
64 : : const rendering::ViewState& rOldState,
65 : : const uno::Reference< rendering::XCanvas >& rTargetCanvas,
66 : : bool bSameViewTransform )
67 : : {
68 : 0 : ENSURE_OR_THROW( bSameViewTransform,
69 : : "CachedBitmap::doRedraw(): base called with changed view transform "
70 : : "(told otherwise during construction)" );
71 : :
72 : : // TODO(P1): Could adapt to modified clips as well
73 : 0 : if( rNewState.Clip != rOldState.Clip )
74 : 0 : return rendering::RepaintResult::FAILED;
75 : :
76 : 0 : RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get());
77 : :
78 : 0 : ENSURE_OR_THROW( pTarget,
79 : : "CachedBitmap::redraw(): cannot cast target to RepaintTarget" );
80 : :
81 : 0 : if( !pTarget->repaint( mpGraphicObject,
82 : : rNewState,
83 : : maRenderState,
84 : : maPoint,
85 : : maSize,
86 : 0 : maAttributes ) )
87 : : {
88 : : // target failed to repaint
89 : 0 : return rendering::RepaintResult::FAILED;
90 : : }
91 : :
92 : 0 : return rendering::RepaintResult::REDRAWN;
93 : : }
94 : : }
95 : :
96 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|