LibreOffice Module canvas (master) 1
cairo_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>
26
29
30
31using namespace ::cairo;
32using namespace ::com::sun::star;
33
34namespace cairocanvas
35{
37 const rendering::ViewState& rUsedViewState,
38 rendering::RenderState aUsedRenderState,
39 const uno::Reference< rendering::XCanvas >& rTarget ) :
40 CachedPrimitiveBase( rUsedViewState, rTarget ),
41 mpSurface(std::move( pSurface )),
42 maRenderState(std::move( aUsedRenderState ))
43 {}
44
46 {
47 ::osl::MutexGuard aGuard( m_aMutex );
48
49 mpSurface.reset();
50 CachedPrimitiveBase::disposing();
51 }
52
53 ::sal_Int8 CachedBitmap::doRedraw( const rendering::ViewState& rNewState,
54 const rendering::ViewState& /*rOldState*/,
55 const uno::Reference< rendering::XCanvas >& rTargetCanvas,
56 bool bSameViewTransform )
57 {
58 ENSURE_OR_THROW( bSameViewTransform,
59 "CachedBitmap::doRedraw(): base called with changed view transform "
60 "(told otherwise during construction)" );
61
62 RepaintTarget* pTarget = dynamic_cast< RepaintTarget* >(rTargetCanvas.get());
63
64 ENSURE_OR_THROW( pTarget,
65 "CachedBitmap::redraw(): cannot cast target to RepaintTarget" );
66
67 if( !pTarget->repaint( mpSurface,
68 rNewState,
70 {
71 // target failed to repaint
72 return rendering::RepaintResult::FAILED;
73 }
74
75 return rendering::RepaintResult::REDRAWN;
76 }
77}
78
79/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL disposing() override
Dispose all internal references.
::cairo::SurfaceSharedPtr mpSurface
const css::rendering::RenderState maRenderState
CachedBitmap(::cairo::SurfaceSharedPtr pSurface, const css::rendering::ViewState &rUsedViewState, css::rendering::RenderState aUsedRenderState, const css::uno::Reference< css::rendering::XCanvas > &rTarget)
Create an XCachedPrimitive for given GraphicObject.
virtual ::sal_Int8 doRedraw(const css::rendering::ViewState &rNewState, const css::rendering::ViewState &rOldState, const css::uno::Reference< css::rendering::XCanvas > &rTargetCanvas, bool bSameViewTransform) override
Actually perform the requested redraw.
mutable::osl::Mutex m_aMutex
#define ENSURE_OR_THROW(c, m)
sal::systools::COMReference< surface_type > mpSurface
FilterGroup & rTarget
std::shared_ptr< Surface > SurfaceSharedPtr
signed char sal_Int8