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