fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / canvas / source / cairo / cairo_canvascustomsprite.cxx
blobd7e72c08f73fb8ecd7253f656f6cb3dcdeb3f86d
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 .
20 #include <canvas/debug.hxx>
21 #include <canvas/verbosetrace.hxx>
22 #include <tools/diagnose_ex.h>
24 #include <rtl/logfile.hxx>
25 #include <rtl/math.hxx>
27 #include <canvas/canvastools.hxx>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
30 #include <basegfx/point/b2dpoint.hxx>
32 #include "cairo_canvascustomsprite.hxx"
33 #include "cairo_spritecanvas.hxx"
36 using namespace ::cairo;
37 using namespace ::com::sun::star;
39 namespace cairocanvas
41 CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
42 const SpriteCanvasRef& rRefDevice ) :
43 mpSpriteCanvas( rRefDevice ),
44 maSize( ::canvas::tools::roundUp( rSpriteSize.Width ),
45 ::canvas::tools::roundUp( rSpriteSize.Height ) )
47 ENSURE_OR_THROW( rRefDevice.get(),
48 "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
50 OSL_TRACE("sprite size: %d, %d",
51 ::canvas::tools::roundUp( rSpriteSize.Width ),
52 ::canvas::tools::roundUp( rSpriteSize.Height ));
54 mpBufferSurface = mpSpriteCanvas->createSurface( maSize );
56 maCanvasHelper.init( maSize,
57 *rRefDevice,
58 rRefDevice.get() );
59 maCanvasHelper.setSurface( mpBufferSurface, true );
61 maSpriteHelper.init( rSpriteSize,
62 rRefDevice );
63 maSpriteHelper.setSurface( mpBufferSurface );
65 // clear sprite to 100% transparent
66 maCanvasHelper.clear();
69 void CanvasCustomSprite::disposeThis()
71 ::osl::MutexGuard aGuard( m_aMutex );
73 mpSpriteCanvas.clear();
74 mpBufferSurface.reset();
76 // forward to parent
77 CanvasCustomSpriteBaseT::disposeThis();
80 void CanvasCustomSprite::redraw( const CairoSharedPtr& pCairo,
81 bool bBufferedUpdate ) const
83 ::osl::MutexGuard aGuard( m_aMutex );
85 redraw( pCairo, maSpriteHelper.getPosPixel(), bBufferedUpdate );
88 void CanvasCustomSprite::redraw( const CairoSharedPtr& pCairo,
89 const ::basegfx::B2DPoint& rOrigOutputPos,
90 bool bBufferedUpdate ) const
92 ::osl::MutexGuard aGuard( m_aMutex );
94 maSpriteHelper.redraw( pCairo,
95 rOrigOutputPos,
96 mbSurfaceDirty,
97 bBufferedUpdate );
99 mbSurfaceDirty = false;
102 bool CanvasCustomSprite::repaint( const SurfaceSharedPtr& pSurface,
103 const rendering::ViewState& viewState,
104 const rendering::RenderState& renderState )
106 return maCanvasHelper.repaint( pSurface, viewState, renderState );
109 SurfaceSharedPtr CanvasCustomSprite::getSurface()
111 return mpBufferSurface;
114 SurfaceSharedPtr CanvasCustomSprite::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
116 return mpSpriteCanvas->createSurface(rSize,aContent);
119 SurfaceSharedPtr CanvasCustomSprite::createSurface( ::Bitmap& rBitmap )
121 return mpSpriteCanvas->createSurface(rBitmap);
124 SurfaceSharedPtr CanvasCustomSprite::changeSurface( bool bHasAlpha, bool bCopyContent )
126 if( !bHasAlpha && !bCopyContent )
128 OSL_TRACE("replacing sprite background surface");
130 mpBufferSurface = mpSpriteCanvas->createSurface( maSize, CAIRO_CONTENT_COLOR );
131 maSpriteHelper.setSurface( mpBufferSurface );
133 return mpBufferSurface;
136 return SurfaceSharedPtr();
139 OutputDevice* CanvasCustomSprite::getOutputDevice()
141 return mpSpriteCanvas->getOutputDevice();
144 #define IMPLEMENTATION_NAME "CairoCanvas.CanvasCustomSprite"
145 #define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite"
147 OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException )
149 return OUString( IMPLEMENTATION_NAME );
152 sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const OUString& ServiceName ) throw( uno::RuntimeException )
154 return ServiceName == SERVICE_NAME;
157 uno::Sequence< OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException )
159 uno::Sequence< OUString > aRet(1);
160 aRet[0] = SERVICE_NAME;
162 return aRet;
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */