1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <sal/config.h>
24 #include <basegfx/matrix/b2dhommatrix.hxx>
25 #include <basegfx/point/b2dpoint.hxx>
26 #include <cppuhelper/supportsservice.hxx>
27 #include <rtl/math.hxx>
28 #include <comphelper/diagnose_ex.hxx>
30 #include <canvas/canvastools.hxx>
32 #include "dx_canvascustomsprite.hxx"
33 #include "dx_impltools.hxx"
34 #include "dx_spritecanvas.hxx"
36 using namespace ::com::sun::star
;
40 CanvasCustomSprite::CanvasCustomSprite( const css::geometry::RealSize2D
& rSpriteSize
,
41 const SpriteCanvasRef
& rRefDevice
,
42 const IDXRenderModuleSharedPtr
& rRenderModule
,
43 const std::shared_ptr
<canvas::ISurfaceProxyManager
>& rSurfaceProxy
,
44 bool bShowSpriteBounds
) :
45 mpSpriteCanvas( rRefDevice
),
48 ENSURE_OR_THROW( rRefDevice
,
49 "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
51 mpSurface
= std::make_shared
<DXSurfaceBitmap
>(
53 ::canvas::tools::roundUp( rSpriteSize
.Width
),
54 ::canvas::tools::roundUp( rSpriteSize
.Height
)),
59 maCanvasHelper
.setDevice( *rRefDevice
);
60 maCanvasHelper
.setTarget( mpSurface
);
62 maSpriteHelper
.init( rSpriteSize
,
68 // clear sprite to 100% transparent
69 maCanvasHelper
.clear();
72 void CanvasCustomSprite::disposeThis()
74 ::osl::MutexGuard
aGuard( m_aMutex
);
77 mpSpriteCanvas
.clear();
80 CanvasCustomSpriteBaseT::disposeThis();
83 OUString SAL_CALL
CanvasCustomSprite::getImplementationName()
85 return "DXCanvas.CanvasCustomSprite";
88 sal_Bool SAL_CALL
CanvasCustomSprite::supportsService( const OUString
& ServiceName
)
90 return cppu::supportsService( this, ServiceName
);
93 uno::Sequence
< OUString
> SAL_CALL
CanvasCustomSprite::getSupportedServiceNames()
95 return { "com.sun.star.rendering.CanvasCustomSprite" };
98 void CanvasCustomSprite::redraw() const
100 ::osl::MutexGuard
aGuard( m_aMutex
);
102 maSpriteHelper
.redraw( mbSurfaceDirty
);
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */