2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2007-11-01 16:53:33 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 08:06:37 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2007-11-01 16:53:33 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2007-11-01 16:53:33 +00:00
|
|
|
*
|
2008-04-11 08:06:37 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2007-11-01 16:53:33 +00:00
|
|
|
*
|
2008-04-11 08:06:37 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2007-11-01 16:53:33 +00:00
|
|
|
*
|
2008-04-11 08:06:37 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2007-11-01 16:53:33 +00:00
|
|
|
*
|
2008-04-11 08:06:37 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2007-11-01 16:53:33 +00:00
|
|
|
*
|
2008-04-11 08:06:37 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2007-11-01 16:53:33 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2008-06-24 09:32:11 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_canvas.hxx"
|
|
|
|
|
2007-11-01 16:53:33 +00:00
|
|
|
#include <ctype.h> // don't ask. msdev breaks otherwise...
|
|
|
|
#include <canvas/debug.hxx>
|
|
|
|
#include <canvas/verbosetrace.hxx>
|
2008-06-24 09:32:11 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2007-11-01 16:53:33 +00:00
|
|
|
|
|
|
|
#include <rtl/logfile.hxx>
|
|
|
|
#include <rtl/math.hxx>
|
|
|
|
|
|
|
|
#include <canvas/canvastools.hxx>
|
|
|
|
|
|
|
|
#include <basegfx/matrix/b2dhommatrix.hxx>
|
|
|
|
#include <basegfx/point/b2dpoint.hxx>
|
|
|
|
|
|
|
|
#include "dx_canvascustomsprite.hxx"
|
|
|
|
#include "dx_spritecanvas.hxx"
|
|
|
|
#include "dx_impltools.hxx"
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
namespace dxcanvas
|
|
|
|
{
|
|
|
|
CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
|
|
|
|
const SpriteCanvasRef& rRefDevice,
|
|
|
|
const IDXRenderModuleSharedPtr& rRenderModule,
|
|
|
|
const ::canvas::ISurfaceProxyManagerSharedPtr& rSurfaceProxy,
|
|
|
|
bool bShowSpriteBounds ) :
|
2008-06-24 09:32:11 +00:00
|
|
|
mpSpriteCanvas( rRefDevice ),
|
|
|
|
mpSurface()
|
2007-11-01 16:53:33 +00:00
|
|
|
{
|
2008-06-24 09:32:11 +00:00
|
|
|
ENSURE_OR_THROW( rRefDevice.get(),
|
|
|
|
"CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
|
2007-11-01 16:53:33 +00:00
|
|
|
|
2008-06-24 09:32:11 +00:00
|
|
|
mpSurface.reset(
|
|
|
|
new DXSurfaceBitmap(
|
2007-11-01 16:53:33 +00:00
|
|
|
::basegfx::B2IVector(
|
|
|
|
::canvas::tools::roundUp( rSpriteSize.Width ),
|
|
|
|
::canvas::tools::roundUp( rSpriteSize.Height )),
|
|
|
|
rSurfaceProxy,
|
|
|
|
rRenderModule,
|
|
|
|
true));
|
|
|
|
|
|
|
|
maCanvasHelper.setDevice( *rRefDevice.get() );
|
2008-06-24 09:32:11 +00:00
|
|
|
maCanvasHelper.setTarget( mpSurface );
|
2007-11-01 16:53:33 +00:00
|
|
|
|
|
|
|
maSpriteHelper.init( rSpriteSize,
|
|
|
|
rRefDevice,
|
|
|
|
rRenderModule,
|
2008-06-24 09:32:11 +00:00
|
|
|
mpSurface,
|
2007-11-01 16:53:33 +00:00
|
|
|
bShowSpriteBounds );
|
|
|
|
|
|
|
|
// clear sprite to 100% transparent
|
|
|
|
maCanvasHelper.clear();
|
|
|
|
}
|
|
|
|
|
2011-04-08 16:44:28 +02:00
|
|
|
void CanvasCustomSprite::disposeThis()
|
2007-11-01 16:53:33 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
2008-06-24 09:32:11 +00:00
|
|
|
mpSurface.reset();
|
2007-11-01 16:53:33 +00:00
|
|
|
mpSpriteCanvas.clear();
|
|
|
|
|
|
|
|
// forward to parent
|
2011-04-08 16:44:28 +02:00
|
|
|
CanvasCustomSpriteBaseT::disposeThis();
|
2007-11-01 16:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define IMPLEMENTATION_NAME "DXCanvas.CanvasCustomSprite"
|
|
|
|
#define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite"
|
|
|
|
|
|
|
|
::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException )
|
|
|
|
{
|
|
|
|
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
|
|
|
|
{
|
|
|
|
return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException )
|
|
|
|
{
|
|
|
|
uno::Sequence< ::rtl::OUString > aRet(1);
|
|
|
|
aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CanvasCustomSprite::redraw() const
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
|
|
|
|
maSpriteHelper.redraw( mbSurfaceDirty );
|
|
|
|
}
|
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|