1*91c99ff4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*91c99ff4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*91c99ff4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*91c99ff4SAndrew Rist * distributed with this work for additional information 6*91c99ff4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*91c99ff4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*91c99ff4SAndrew Rist * "License"); you may not use this file except in compliance 9*91c99ff4SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*91c99ff4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*91c99ff4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*91c99ff4SAndrew Rist * software distributed under the License is distributed on an 15*91c99ff4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*91c99ff4SAndrew Rist * KIND, either express or implied. See the License for the 17*91c99ff4SAndrew Rist * specific language governing permissions and limitations 18*91c99ff4SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*91c99ff4SAndrew Rist *************************************************************/ 21*91c99ff4SAndrew Rist 22*91c99ff4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DXCANVAS_SPRITECANVAS_HXX_ 25cdf0e10cSrcweir #define _DXCANVAS_SPRITECANVAS_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <rtl/ref.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp> 32cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp> 33cdf0e10cSrcweir #include <com/sun/star/util/XUpdatable.hpp> 34cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp> 35cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp> 36cdf0e10cSrcweir #include <com/sun/star/rendering/XGraphicDevice.hpp> 37cdf0e10cSrcweir #include <com/sun/star/rendering/XBufferController.hpp> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <cppuhelper/compbase9.hxx> 40cdf0e10cSrcweir #include <comphelper/uno3.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <canvas/base/spritecanvasbase.hxx> 43cdf0e10cSrcweir #include <canvas/base/basemutexhelper.hxx> 44cdf0e10cSrcweir #include <canvas/base/bufferedgraphicdevicebase.hxx> 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include "dx_bitmapprovider.hxx" 47cdf0e10cSrcweir #include "dx_spritecanvashelper.hxx" 48cdf0e10cSrcweir #include "dx_surfacebitmap.hxx" 49cdf0e10cSrcweir #include "dx_impltools.hxx" 50cdf0e10cSrcweir #include "dx_spritedevicehelper.hxx" 51cdf0e10cSrcweir 52cdf0e10cSrcweir 53cdf0e10cSrcweir namespace dxcanvas 54cdf0e10cSrcweir { 55cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas, 56cdf0e10cSrcweir ::com::sun::star::rendering::XIntegerBitmap, 57cdf0e10cSrcweir ::com::sun::star::rendering::XGraphicDevice, 58cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory, 59cdf0e10cSrcweir ::com::sun::star::rendering::XBufferController, 60cdf0e10cSrcweir ::com::sun::star::awt::XWindowListener, 61cdf0e10cSrcweir ::com::sun::star::util::XUpdatable, 62cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet, 63cdf0e10cSrcweir ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base; 64cdf0e10cSrcweir typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >, 65cdf0e10cSrcweir SpriteDeviceHelper, 66cdf0e10cSrcweir ::osl::MutexGuard, 67cdf0e10cSrcweir ::cppu::OWeakObject > SpriteCanvasBase_Base; 68cdf0e10cSrcweir /** Mixin SpriteSurface 69cdf0e10cSrcweir 70cdf0e10cSrcweir Have to mixin the SpriteSurface before deriving from 71cdf0e10cSrcweir ::canvas::SpriteCanvasBase, as this template should already 72cdf0e10cSrcweir implement some of those interface methods. 73cdf0e10cSrcweir 74cdf0e10cSrcweir The reason why this appears kinda convoluted is the fact that 75cdf0e10cSrcweir we cannot specify non-IDL types as WeakComponentImplHelperN 76cdf0e10cSrcweir template args, and furthermore, don't want to derive 77cdf0e10cSrcweir ::canvas::SpriteCanvasBase directly from 78cdf0e10cSrcweir ::canvas::SpriteSurface (because derivees of 79cdf0e10cSrcweir ::canvas::SpriteCanvasBase have to explicitely forward the 80cdf0e10cSrcweir XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS) 81cdf0e10cSrcweir anyway). Basically, ::canvas::CanvasCustomSpriteBase should 82cdf0e10cSrcweir remain a base class that provides implementation, not to 83cdf0e10cSrcweir enforce any specific interface on its derivees. 84cdf0e10cSrcweir */ 85cdf0e10cSrcweir class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base, 86cdf0e10cSrcweir public ::canvas::SpriteSurface 87cdf0e10cSrcweir { 88cdf0e10cSrcweir }; 89cdf0e10cSrcweir 90cdf0e10cSrcweir typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base, 91cdf0e10cSrcweir SpriteCanvasHelper, 92cdf0e10cSrcweir ::osl::MutexGuard, 93cdf0e10cSrcweir ::cppu::OWeakObject > SpriteCanvasBaseT; 94cdf0e10cSrcweir 95cdf0e10cSrcweir /** Product of this component's factory. 96cdf0e10cSrcweir 97cdf0e10cSrcweir The SpriteCanvas object combines the actual Window canvas with 98cdf0e10cSrcweir the XGraphicDevice interface. This is because there's a 99cdf0e10cSrcweir one-to-one relation between them, anyway, since each window 100cdf0e10cSrcweir can have exactly one canvas and one associated 101cdf0e10cSrcweir XGraphicDevice. And to avoid messing around with circular 102cdf0e10cSrcweir references, this is implemented as one single object. 103cdf0e10cSrcweir */ 104cdf0e10cSrcweir class SpriteCanvas : public SpriteCanvasBaseT, public BitmapProvider 105cdf0e10cSrcweir { 106cdf0e10cSrcweir public: 107cdf0e10cSrcweir SpriteCanvas( const ::com::sun::star::uno::Sequence< 108cdf0e10cSrcweir ::com::sun::star::uno::Any >& aArguments, 109cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 110cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext >& rxContext ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir void initialize(); 113cdf0e10cSrcweir 114cdf0e10cSrcweir /// Dispose all internal references 115cdf0e10cSrcweir virtual void SAL_CALL disposing(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir // Forwarding the XComponent implementation to the 118cdf0e10cSrcweir // cppu::ImplHelper templated base 119cdf0e10cSrcweir // Classname Base doing refcounting Base implementing the XComponent interface 120cdf0e10cSrcweir // | | | 121cdf0e10cSrcweir // V V V 122cdf0e10cSrcweir DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase ); 123cdf0e10cSrcweir 124cdf0e10cSrcweir // XBufferController (partial) 125cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 126cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // XSpriteCanvas (partial) 129cdf0e10cSrcweir virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 130cdf0e10cSrcweir 131cdf0e10cSrcweir // XServiceName 132cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException); 133cdf0e10cSrcweir 134cdf0e10cSrcweir /// Retrieve rendermodule object for this Canvas 135cdf0e10cSrcweir const IDXRenderModuleSharedPtr& getRenderModule() const; 136cdf0e10cSrcweir 137cdf0e10cSrcweir /// Get backbuffer for this canvas 138cdf0e10cSrcweir const DXSurfaceBitmapSharedPtr& getBackBuffer() const; 139cdf0e10cSrcweir 140cdf0e10cSrcweir // BitmapProvider 141cdf0e10cSrcweir virtual IBitmapSharedPtr getBitmap() const; 142cdf0e10cSrcweir 143cdf0e10cSrcweir private: 144cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > maArguments; 145cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext; 146cdf0e10cSrcweir }; 147cdf0e10cSrcweir 148cdf0e10cSrcweir typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir #endif 152