Files
libreoffice/canvas/source/vcl/spritecanvas.cxx

162 lines
6.0 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <algorithm>
#include <basegfx/tools/canvastools.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <tools/diagnose_ex.h>
#include <vcl/bitmapex.hxx>
INTEGRATION: CWS presentationengine01 (1.2.2); FILE MERGED 2004/11/17 17:00:33 thb 1.2.2.13: #118514# Canvas module reorg 2004/09/29 23:36:05 thb 1.2.2.12: #110496# Making the new modules Wall clean 2004/09/29 08:31:23 thb 1.2.2.11: #110496# Removed extraneous trace outputs 2004/09/28 17:43:53 thb 1.2.2.10: #110496# Perform reinterpretative casting more carefully. The old version yielded wrong results for UltraSparc platform, possibly due to violated alignment requirements 2004/09/08 16:34:45 dbo 1.2.2.9: #110496# separate service names for all kinds of canvas implementations Issue number: Submitted by: Reviewed by: 2004/08/27 18:46:18 thb 1.2.2.8: #110496# Adapted to recent canvas API changes (XSpriteCanvas::updateScreen and sprite clip semantics 2004/08/02 17:51:00 thb 1.2.2.7: #110496# Adapted to recent XCanvas API changes, streamlined and factored out common code with directxcanvas 2004/07/22 18:40:43 thb 1.2.2.6: #110496# Overhauled sprite redraw algo, to also respect overlapping sprites 2004/07/20 19:23:57 thb 1.2.2.5: #110496# Removed self-references to various interface implementations, along the lines, factored out common base implementation for all c++ canvases 2004/05/27 20:51:25 thb 1.2.2.4: #110496# Added classification code to all TODO/HACK/FIXME comments. There are four categories: - code quality (C) - performance (P) - missing functionality (F) - and missing/incomplete error handling (E) Furthermore, every category has a severity number between 1 and 3 associated, where 1 is lowest and 3 highest severity 2004/05/27 14:36:53 thb 1.2.2.3: #110496# verbose tracing is now guarded also with DBG_UTIL. Unified verbose trace output between directx and VCL canvas 2004/04/12 15:12:25 thb 1.2.2.2: #110496# Adaptions after canvas01 merge 2004/04/05 15:58:00 thb 1.2.2.1: Resync with canvas01 changes
2004-11-26 16:15:27 +00:00
#include <vcl/canvastools.hxx>
#include <vcl/outdev.hxx>
#include <vcl/window.hxx>
#include <canvas/canvastools.hxx>
#include "spritecanvas.hxx"
#include "windowoutdevholder.hxx"
using namespace ::com::sun::star;
INTEGRATION: CWS presentationengine01 (1.2.2); FILE MERGED 2004/11/17 17:00:33 thb 1.2.2.13: #118514# Canvas module reorg 2004/09/29 23:36:05 thb 1.2.2.12: #110496# Making the new modules Wall clean 2004/09/29 08:31:23 thb 1.2.2.11: #110496# Removed extraneous trace outputs 2004/09/28 17:43:53 thb 1.2.2.10: #110496# Perform reinterpretative casting more carefully. The old version yielded wrong results for UltraSparc platform, possibly due to violated alignment requirements 2004/09/08 16:34:45 dbo 1.2.2.9: #110496# separate service names for all kinds of canvas implementations Issue number: Submitted by: Reviewed by: 2004/08/27 18:46:18 thb 1.2.2.8: #110496# Adapted to recent canvas API changes (XSpriteCanvas::updateScreen and sprite clip semantics 2004/08/02 17:51:00 thb 1.2.2.7: #110496# Adapted to recent XCanvas API changes, streamlined and factored out common code with directxcanvas 2004/07/22 18:40:43 thb 1.2.2.6: #110496# Overhauled sprite redraw algo, to also respect overlapping sprites 2004/07/20 19:23:57 thb 1.2.2.5: #110496# Removed self-references to various interface implementations, along the lines, factored out common base implementation for all c++ canvases 2004/05/27 20:51:25 thb 1.2.2.4: #110496# Added classification code to all TODO/HACK/FIXME comments. There are four categories: - code quality (C) - performance (P) - missing functionality (F) - and missing/incomplete error handling (E) Furthermore, every category has a severity number between 1 and 3 associated, where 1 is lowest and 3 highest severity 2004/05/27 14:36:53 thb 1.2.2.3: #110496# verbose tracing is now guarded also with DBG_UTIL. Unified verbose trace output between directx and VCL canvas 2004/04/12 15:12:25 thb 1.2.2.2: #110496# Adaptions after canvas01 merge 2004/04/05 15:58:00 thb 1.2.2.1: Resync with canvas01 changes
2004-11-26 16:15:27 +00:00
namespace vclcanvas
{
SpriteCanvas::SpriteCanvas( const uno::Sequence< uno::Any >& aArguments,
const uno::Reference< uno::XComponentContext >& rxContext ) :
maArguments(aArguments),
mxComponentContext( rxContext )
{
}
void SpriteCanvas::initialize()
{
SolarMutexGuard aGuard;
// #i64742# Only call initialize when not in probe mode
if( maArguments.getLength() == 0 )
return;
SAL_INFO("canvas.vcl", "SpriteCanvas created" );
// add our own property to GraphicDevice
maPropHelper.addProperties(
::canvas::PropertySetHelper::MakeMap
("UnsafeScrolling",
[this]() { return this->maCanvasHelper.isUnsafeScrolling(); },
[this](css::uno::Any const& aAny) mutable { this->maCanvasHelper.enableUnsafeScrolling(aAny); } )
("SpriteBounds",
[this]() { return this->maCanvasHelper.isSpriteBounds(); },
[this](css::uno::Any const& aAny) mutable { this->maCanvasHelper.enableSpriteBounds(aAny); } ));
SAL_INFO("canvas.vcl", "VCLSpriteCanvas::initialize called" );
ENSURE_ARG_OR_THROW( maArguments.getLength() >= 1,
"VCLSpriteCanvas::initialize: wrong number of arguments" );
/* maArguments:
0: ptr to creating instance (Window or VirtualDevice)
1: SystemEnvData as a streamed Any (or empty for VirtualDevice)
2: current bounds of creating instance
3: bool, denoting always on top state for Window (always false for VirtualDevice)
4: XWindow for creating Window (or empty for VirtualDevice)
5: SystemGraphicsData as a streamed Any
*/
ENSURE_ARG_OR_THROW( maArguments.getLength() >= 4 &&
maArguments[0].getValueTypeClass() == uno::TypeClass_HYPER &&
maArguments[4].getValueTypeClass() == uno::TypeClass_INTERFACE,
"VCLSpriteCanvas::initialize: wrong number of arguments, or wrong types" );
uno::Reference< awt::XWindow > xParentWindow;
maArguments[4] >>= xParentWindow;
OutDevProviderSharedPtr pOutDev( new WindowOutDevHolder(xParentWindow) );
// setup helper
maDeviceHelper.init( pOutDev );
setWindow(uno::Reference<awt::XWindow2>(xParentWindow, uno::UNO_QUERY_THROW));
maCanvasHelper.init( maDeviceHelper.getBackBuffer(),
*this,
maRedrawManager,
false, // no OutDev state preservation
false ); // no alpha on surface
maArguments.realloc(0);
}
SpriteCanvas::~SpriteCanvas()
{
SAL_INFO("canvas.vcl", "SpriteCanvas destroyed" );
}
void SpriteCanvas::disposeThis()
{
SolarMutexGuard aGuard;
mxComponentContext.clear();
INTEGRATION: CWS presentationengine01 (1.2.2); FILE MERGED 2004/11/17 17:00:33 thb 1.2.2.13: #118514# Canvas module reorg 2004/09/29 23:36:05 thb 1.2.2.12: #110496# Making the new modules Wall clean 2004/09/29 08:31:23 thb 1.2.2.11: #110496# Removed extraneous trace outputs 2004/09/28 17:43:53 thb 1.2.2.10: #110496# Perform reinterpretative casting more carefully. The old version yielded wrong results for UltraSparc platform, possibly due to violated alignment requirements 2004/09/08 16:34:45 dbo 1.2.2.9: #110496# separate service names for all kinds of canvas implementations Issue number: Submitted by: Reviewed by: 2004/08/27 18:46:18 thb 1.2.2.8: #110496# Adapted to recent canvas API changes (XSpriteCanvas::updateScreen and sprite clip semantics 2004/08/02 17:51:00 thb 1.2.2.7: #110496# Adapted to recent XCanvas API changes, streamlined and factored out common code with directxcanvas 2004/07/22 18:40:43 thb 1.2.2.6: #110496# Overhauled sprite redraw algo, to also respect overlapping sprites 2004/07/20 19:23:57 thb 1.2.2.5: #110496# Removed self-references to various interface implementations, along the lines, factored out common base implementation for all c++ canvases 2004/05/27 20:51:25 thb 1.2.2.4: #110496# Added classification code to all TODO/HACK/FIXME comments. There are four categories: - code quality (C) - performance (P) - missing functionality (F) - and missing/incomplete error handling (E) Furthermore, every category has a severity number between 1 and 3 associated, where 1 is lowest and 3 highest severity 2004/05/27 14:36:53 thb 1.2.2.3: #110496# verbose tracing is now guarded also with DBG_UTIL. Unified verbose trace output between directx and VCL canvas 2004/04/12 15:12:25 thb 1.2.2.2: #110496# Adaptions after canvas01 merge 2004/04/05 15:58:00 thb 1.2.2.1: Resync with canvas01 changes
2004-11-26 16:15:27 +00:00
// forward to parent
SpriteCanvasBaseT::disposeThis();
}
sal_Bool SAL_CALL SpriteCanvas::showBuffer( sal_Bool bUpdateAll ) throw (uno::RuntimeException, std::exception)
{
return updateScreen( bUpdateAll );
}
sal_Bool SAL_CALL SpriteCanvas::switchBuffer( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
{
return updateScreen( bUpdateAll );
}
sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
// avoid repaints on hidden window (hidden: not mapped to
// screen). Return failure, since the screen really has _not_
// been updated (caller should try again later)
return mbIsVisible && maCanvasHelper.updateScreen(bUpdateAll,
mbSurfaceDirty);
}
OUString SAL_CALL SpriteCanvas::getServiceName( ) throw (css::uno::RuntimeException, std::exception)
{
return OUString( SPRITECANVAS_SERVICE_NAME );
}
bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf,
const rendering::ViewState& viewState,
const rendering::RenderState& renderState,
const ::Point& rPt,
const ::Size& rSz,
const GraphicAttr& rAttr ) const
{
SolarMutexGuard aGuard;
return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */