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