191c99ff4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 391c99ff4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 491c99ff4SAndrew Rist * or more contributor license agreements. See the NOTICE file 591c99ff4SAndrew Rist * distributed with this work for additional information 691c99ff4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 791c99ff4SAndrew Rist * to you under the Apache License, Version 2.0 (the 891c99ff4SAndrew Rist * "License"); you may not use this file except in compliance 991c99ff4SAndrew Rist * with the License. You may obtain a copy of the License at 1091c99ff4SAndrew Rist * 1191c99ff4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1291c99ff4SAndrew Rist * 1391c99ff4SAndrew Rist * Unless required by applicable law or agreed to in writing, 1491c99ff4SAndrew Rist * software distributed under the License is distributed on an 1591c99ff4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1691c99ff4SAndrew Rist * KIND, either express or implied. See the License for the 1791c99ff4SAndrew Rist * specific language governing permissions and limitations 1891c99ff4SAndrew Rist * under the License. 1991c99ff4SAndrew Rist * 2091c99ff4SAndrew Rist *************************************************************/ 2191c99ff4SAndrew Rist 2291c99ff4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _CAIROCANVAS_SPRITECANVAS_HXX_ 25cdf0e10cSrcweir #define _CAIROCANVAS_SPRITECANVAS_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 29cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 30cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.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 <basegfx/vector/b2isize.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir #include "cairo_spritedevicehelper.hxx" 49cdf0e10cSrcweir #include "cairo_repainttarget.hxx" 50cdf0e10cSrcweir #include "cairo_surfaceprovider.hxx" 51cdf0e10cSrcweir #include "cairo_spritecanvashelper.hxx" 52cdf0e10cSrcweir 53cdf0e10cSrcweir #define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.Cairo" 54cdf0e10cSrcweir #define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.Cairo" 55cdf0e10cSrcweir 56cdf0e10cSrcweir namespace cairocanvas 57cdf0e10cSrcweir { 58cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas, 59cdf0e10cSrcweir ::com::sun::star::rendering::XIntegerBitmap, 60cdf0e10cSrcweir ::com::sun::star::rendering::XGraphicDevice, 61cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory, 62cdf0e10cSrcweir ::com::sun::star::rendering::XBufferController, 63cdf0e10cSrcweir ::com::sun::star::awt::XWindowListener, 64cdf0e10cSrcweir ::com::sun::star::util::XUpdatable, 65cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet, 66cdf0e10cSrcweir ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base; 67cdf0e10cSrcweir typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >, 68cdf0e10cSrcweir SpriteDeviceHelper, 69cdf0e10cSrcweir ::osl::MutexGuard, 70cdf0e10cSrcweir ::cppu::OWeakObject > SpriteCanvasBase_Base; 71cdf0e10cSrcweir /** Mixin SpriteSurface 72cdf0e10cSrcweir 73cdf0e10cSrcweir Have to mixin the SpriteSurface before deriving from 74cdf0e10cSrcweir ::canvas::SpriteCanvasBase, as this template should already 75cdf0e10cSrcweir implement some of those interface methods. 76cdf0e10cSrcweir 77cdf0e10cSrcweir The reason why this appears kinda convoluted is the fact that 78cdf0e10cSrcweir we cannot specify non-IDL types as WeakComponentImplHelperN 79cdf0e10cSrcweir template args, and furthermore, don't want to derive 80cdf0e10cSrcweir ::canvas::SpriteCanvasBase directly from 81cdf0e10cSrcweir ::canvas::SpriteSurface (because derivees of 82*6d53c851Smseidel ::canvas::SpriteCanvasBase have to explicitly forward the 83cdf0e10cSrcweir XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS) 84cdf0e10cSrcweir anyway). Basically, ::canvas::CanvasCustomSpriteBase should 85cdf0e10cSrcweir remain a base class that provides implementation, not to 86cdf0e10cSrcweir enforce any specific interface on its derivees. 87cdf0e10cSrcweir */ 88cdf0e10cSrcweir class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base, 89cdf0e10cSrcweir public ::canvas::SpriteSurface, 90cdf0e10cSrcweir public SurfaceProvider 91cdf0e10cSrcweir { 92cdf0e10cSrcweir }; 93cdf0e10cSrcweir 94cdf0e10cSrcweir typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base, 95cdf0e10cSrcweir SpriteCanvasHelper, 96cdf0e10cSrcweir ::osl::MutexGuard, 97cdf0e10cSrcweir ::cppu::OWeakObject > SpriteCanvasBaseT; 98cdf0e10cSrcweir 99cdf0e10cSrcweir /** Product of this component's factory. 100cdf0e10cSrcweir 101cdf0e10cSrcweir The SpriteCanvas object combines the actual Window canvas with 102cdf0e10cSrcweir the XGraphicDevice interface. This is because there's a 103cdf0e10cSrcweir one-to-one relation between them, anyway, since each window 104cdf0e10cSrcweir can have exactly one canvas and one associated 105cdf0e10cSrcweir XGraphicDevice. And to avoid messing around with circular 106cdf0e10cSrcweir references, this is implemented as one single object. 107cdf0e10cSrcweir */ 108cdf0e10cSrcweir class SpriteCanvas : public SpriteCanvasBaseT, 109cdf0e10cSrcweir public RepaintTarget 110cdf0e10cSrcweir { 111cdf0e10cSrcweir public: 112cdf0e10cSrcweir SpriteCanvas( const ::com::sun::star::uno::Sequence< 113cdf0e10cSrcweir ::com::sun::star::uno::Any >& aArguments, 114cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 115cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext >& rxContext ); 116cdf0e10cSrcweir 117cdf0e10cSrcweir void initialize(); 118cdf0e10cSrcweir 119cdf0e10cSrcweir #if defined __SUNPRO_CC 120cdf0e10cSrcweir using SpriteCanvasBaseT::disposing; 121cdf0e10cSrcweir #endif 122cdf0e10cSrcweir 123cdf0e10cSrcweir /// Dispose all internal references 124cdf0e10cSrcweir virtual void SAL_CALL disposing(); 125cdf0e10cSrcweir 126cdf0e10cSrcweir // Forwarding the XComponent implementation to the 127cdf0e10cSrcweir // cppu::ImplHelper templated base 128cdf0e10cSrcweir // Classname Base doing refcounting Base implementing the XComponent interface 129cdf0e10cSrcweir // | | | 130cdf0e10cSrcweir // V V V 131cdf0e10cSrcweir DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir // XBufferController (partial) 134cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 135cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 136cdf0e10cSrcweir 137cdf0e10cSrcweir // XSpriteCanvas (partial) 138cdf0e10cSrcweir virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 139cdf0e10cSrcweir 140cdf0e10cSrcweir // XServiceName 141cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException); 142cdf0e10cSrcweir 143cdf0e10cSrcweir // SurfaceProvider 144cdf0e10cSrcweir virtual SurfaceSharedPtr getSurface(); 145cdf0e10cSrcweir virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA ); 146cdf0e10cSrcweir virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ); 147cdf0e10cSrcweir virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent ); 148cdf0e10cSrcweir virtual OutputDevice* getOutputDevice(); 149cdf0e10cSrcweir 150cdf0e10cSrcweir // RepaintTarget 151cdf0e10cSrcweir virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface, 152cdf0e10cSrcweir const ::com::sun::star::rendering::ViewState& viewState, 153cdf0e10cSrcweir const ::com::sun::star::rendering::RenderState& renderState ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir SurfaceSharedPtr getWindowSurface(); 156cdf0e10cSrcweir SurfaceSharedPtr getBufferSurface(); 157cdf0e10cSrcweir 158cdf0e10cSrcweir const ::basegfx::B2ISize& getSizePixel(); 159cdf0e10cSrcweir void setSizePixel( const ::basegfx::B2ISize& rSize ); 160cdf0e10cSrcweir void flush(); 161cdf0e10cSrcweir 162cdf0e10cSrcweir private: 163cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > maArguments; 164cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext; 165cdf0e10cSrcweir }; 166cdf0e10cSrcweir 167cdf0e10cSrcweir typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir #endif 171