Branch libreoffice-5-0-4
[LibreOffice.git] / canvas / source / vcl / cachedbitmap.cxx
blobbdbbcab799965ef4f8bb70af91911eb54cac49e5
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 <canvas/debug.hxx>
22 #include <tools/diagnose_ex.h>
24 #include "cachedbitmap.hxx"
25 #include "repainttarget.hxx"
27 #include <com/sun/star/rendering/RepaintResult.hpp>
28 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
30 #include <basegfx/matrix/b2dhommatrix.hxx>
31 #include <basegfx/tools/canvastools.hxx>
34 using namespace ::com::sun::star;
36 namespace vclcanvas
38 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 maAttributes( rAttr )
54 void SAL_CALL CachedBitmap::disposing()
56 ::osl::MutexGuard aGuard( m_aMutex );
58 mpGraphicObject.reset();
60 CachedPrimitiveBase::disposing();
63 ::sal_Int8 CachedBitmap::doRedraw( const rendering::ViewState& rNewState,
64 const rendering::ViewState& rOldState,
65 const uno::Reference< rendering::XCanvas >& rTargetCanvas,
66 bool bSameViewTransform )
68 ENSURE_OR_THROW( bSameViewTransform,
69 "CachedBitmap::doRedraw(): base called with changed view transform "
70 "(told otherwise during construction)" );
72 // TODO(P1): Could adapt to modified clips as well
73 if( rNewState.Clip != rOldState.Clip )
74 return rendering::RepaintResult::FAILED;
76 RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get());
78 ENSURE_OR_THROW( pTarget,
79 "CachedBitmap::redraw(): cannot cast target to RepaintTarget" );
81 if( !pTarget->repaint( mpGraphicObject,
82 rNewState,
83 maRenderState,
84 maPoint,
85 maSize,
86 maAttributes ) )
88 // target failed to repaint
89 return rendering::RepaintResult::FAILED;
92 return rendering::RepaintResult::REDRAWN;
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */