LibreOffice Module canvas (master)  1
cachedbitmap.cxx
Go to the documentation of this file.
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 #include <sal/config.h>
21 
22 #include <com/sun/star/rendering/XCanvas.hpp>
23 #include <com/sun/star/rendering/RepaintResult.hpp>
24 #include <tools/diagnose_ex.h>
25 
26 #include "cachedbitmap.hxx"
27 #include "repainttarget.hxx"
28 
29 
30 using namespace ::com::sun::star;
31 
32 namespace vclcanvas
33 {
35  const ::Point& rPoint,
36  const ::Size& rSize,
37  const GraphicAttr& rAttr,
38  const rendering::ViewState& rUsedViewState,
39  const rendering::RenderState& rUsedRenderState,
40  const uno::Reference< rendering::XCanvas >& rTarget ) :
41  CachedPrimitiveBase( rUsedViewState, rTarget ),
42  mpGraphicObject( rGraphicObject ),
43  maRenderState(rUsedRenderState),
44  maPoint( rPoint ),
45  maSize( rSize ),
46  maAttributes( rAttr )
47  {
48  }
49 
50  void SAL_CALL CachedBitmap::disposing()
51  {
52  ::osl::MutexGuard aGuard( m_aMutex );
53 
54  mpGraphicObject.reset();
55 
57  }
58 
59  ::sal_Int8 CachedBitmap::doRedraw( const rendering::ViewState& rNewState,
60  const rendering::ViewState& rOldState,
61  const uno::Reference< rendering::XCanvas >& rTargetCanvas,
62  bool bSameViewTransform )
63  {
64  ENSURE_OR_THROW( bSameViewTransform,
65  "CachedBitmap::doRedraw(): base called with changed view transform "
66  "(told otherwise during construction)" );
67 
68  // TODO(P1): Could adapt to modified clips as well
69  if( rNewState.Clip != rOldState.Clip )
70  return rendering::RepaintResult::FAILED;
71 
72  RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get());
73 
74  ENSURE_OR_THROW( pTarget,
75  "CachedBitmap::redraw(): cannot cast target to RepaintTarget" );
76 
77  if( !pTarget->repaint( mpGraphicObject,
78  rNewState,
79  maRenderState,
80  maPoint,
81  maSize,
82  maAttributes ) )
83  {
84  // target failed to repaint
85  return rendering::RepaintResult::FAILED;
86  }
87 
88  return rendering::RepaintResult::REDRAWN;
89  }
90 }
91 
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
osl::Mutex m_aMutex
signed char sal_Int8
virtual bool repaint(const GraphicObjectSharedPtr &rGrf, const css::rendering::ViewState &viewState, const css::rendering::RenderState &renderState, const ::Point &rPt, const ::Size &rSz, const GraphicAttr &rAttr) const =0
std::shared_ptr< GraphicObject > GraphicObjectSharedPtr
Target interface for XCachedPrimitive implementations.
#define ENSURE_OR_THROW(c, m)
B2DPoint maPoint
CachedBitmap(const GraphicObjectSharedPtr &rGraphicObject, const ::Point &rPoint, const ::Size &rSize, const GraphicAttr &rAttr, const css::rendering::ViewState &rUsedViewState, const css::rendering::RenderState &rUsedRenderState, const css::uno::Reference< css::rendering::XCanvas > &rTarget)
Create an XCachedPrimitive for given GraphicObject.
virtual void SAL_CALL disposing() override
Dispose all internal references.
::basegfx::B2IVector maSize
Definition: dx_9rm.cxx:116