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_CANVAS_HXX_ 25cdf0e10cSrcweir #define _CAIROCANVAS_CANVAS_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/XInitialization.hpp> 32cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 33cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp> 34cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp> 35cdf0e10cSrcweir #include <com/sun/star/util/XUpdatable.hpp> 36cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp> 37cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp> 38cdf0e10cSrcweir #include <com/sun/star/rendering/XGraphicDevice.hpp> 39cdf0e10cSrcweir #include <com/sun/star/rendering/XBufferController.hpp> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <cppuhelper/compbase7.hxx> 42cdf0e10cSrcweir #include <comphelper/uno3.hxx> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include <canvas/base/spritecanvasbase.hxx> 45cdf0e10cSrcweir #include <canvas/base/basemutexhelper.hxx> 46cdf0e10cSrcweir #include <canvas/base/bufferedgraphicdevicebase.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include "cairo_devicehelper.hxx" 51cdf0e10cSrcweir #include "cairo_repainttarget.hxx" 52cdf0e10cSrcweir #include "cairo_surfaceprovider.hxx" 53cdf0e10cSrcweir #include "cairo_spritecanvashelper.hxx" 54cdf0e10cSrcweir 55cdf0e10cSrcweir #define CANVAS_SERVICE_NAME "com.sun.star.rendering.Canvas.Cairo" 56cdf0e10cSrcweir #define CANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.Canvas.Cairo" 57cdf0e10cSrcweir 58cdf0e10cSrcweir namespace cairocanvas 59cdf0e10cSrcweir { 60cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas, 61cdf0e10cSrcweir ::com::sun::star::rendering::XIntegerBitmap, 62cdf0e10cSrcweir ::com::sun::star::rendering::XGraphicDevice, 63cdf0e10cSrcweir ::com::sun::star::lang::XMultiServiceFactory, 64cdf0e10cSrcweir ::com::sun::star::util::XUpdatable, 65cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet, 66cdf0e10cSrcweir ::com::sun::star::lang::XServiceName > GraphicDeviceBase_Base; 67cdf0e10cSrcweir typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase_Base >, 68cdf0e10cSrcweir DeviceHelper, 69cdf0e10cSrcweir ::osl::MutexGuard, 70cdf0e10cSrcweir ::cppu::OWeakObject > CanvasBase_Base; 71cdf0e10cSrcweir 72cdf0e10cSrcweir /** Mixin SurfaceProvider 73cdf0e10cSrcweir 74cdf0e10cSrcweir Have to mixin the SurfaceProvider before deriving from 75cdf0e10cSrcweir ::canvas::CanvasBase, as this template should already 76cdf0e10cSrcweir implement some of those interface methods. 77cdf0e10cSrcweir 78cdf0e10cSrcweir The reason why this appears kinda convoluted is the fact that 79cdf0e10cSrcweir we cannot specify non-IDL types as WeakComponentImplHelperN 80cdf0e10cSrcweir template args, and furthermore, don't want to derive 81cdf0e10cSrcweir ::canvas::CanvasBase directly from 82cdf0e10cSrcweir SurfaceProvider (because derivees of 83*6d53c851Smseidel ::canvas::CanvasBase have to explicitly forward the 84cdf0e10cSrcweir XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS) 85cdf0e10cSrcweir anyway). 86cdf0e10cSrcweir */ 87cdf0e10cSrcweir class CanvasBaseSurfaceProvider_Base : public CanvasBase_Base, 88cdf0e10cSrcweir public SurfaceProvider 89cdf0e10cSrcweir { 90cdf0e10cSrcweir }; 91cdf0e10cSrcweir 92cdf0e10cSrcweir typedef ::canvas::IntegerBitmapBase< CanvasBaseSurfaceProvider_Base, 93cdf0e10cSrcweir CanvasHelper, 94cdf0e10cSrcweir ::osl::MutexGuard, 95cdf0e10cSrcweir ::cppu::OWeakObject > CanvasBaseT; 96cdf0e10cSrcweir 97cdf0e10cSrcweir /** Product of this component's factory. 98cdf0e10cSrcweir 99cdf0e10cSrcweir The Canvas object combines the actual Window canvas with 100cdf0e10cSrcweir the XGraphicDevice interface. This is because there's a 101cdf0e10cSrcweir one-to-one relation between them, anyway, since each window 102cdf0e10cSrcweir can have exactly one canvas and one associated 103cdf0e10cSrcweir XGraphicDevice. And to avoid messing around with circular 104cdf0e10cSrcweir references, this is implemented as one single object. 105cdf0e10cSrcweir */ 106cdf0e10cSrcweir class Canvas : public CanvasBaseT, 107cdf0e10cSrcweir public RepaintTarget 108cdf0e10cSrcweir { 109cdf0e10cSrcweir public: 110cdf0e10cSrcweir Canvas( const ::com::sun::star::uno::Sequence< 111cdf0e10cSrcweir ::com::sun::star::uno::Any >& aArguments, 112cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 113cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext >& rxContext ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir void initialize(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir /// For resource tracking 118cdf0e10cSrcweir ~Canvas(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir #if defined __SUNPRO_CC 121cdf0e10cSrcweir using CanvasBaseT::disposing; 122cdf0e10cSrcweir #endif 123cdf0e10cSrcweir 124cdf0e10cSrcweir /// Dispose all internal references 125cdf0e10cSrcweir virtual void SAL_CALL disposing(); 126cdf0e10cSrcweir 127cdf0e10cSrcweir // Forwarding the XComponent implementation to the 128cdf0e10cSrcweir // cppu::ImplHelper templated base 129cdf0e10cSrcweir // Classname Base doing refcounting Base implementing the XComponent interface 130cdf0e10cSrcweir // | | | 131cdf0e10cSrcweir // V V V 132cdf0e10cSrcweir DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( Canvas, GraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase ); 133cdf0e10cSrcweir 134cdf0e10cSrcweir // XServiceName 135cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException); 136cdf0e10cSrcweir 137cdf0e10cSrcweir // RepaintTarget 138cdf0e10cSrcweir virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface, 139cdf0e10cSrcweir const ::com::sun::star::rendering::ViewState& viewState, 140cdf0e10cSrcweir const ::com::sun::star::rendering::RenderState& renderState ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir // SurfaceProvider 143cdf0e10cSrcweir virtual SurfaceSharedPtr getSurface(); 144cdf0e10cSrcweir virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA ); 145cdf0e10cSrcweir virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ); 146cdf0e10cSrcweir virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent ); 147cdf0e10cSrcweir virtual OutputDevice* getOutputDevice(); 148cdf0e10cSrcweir 149cdf0e10cSrcweir private: 150cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > maArguments; 151cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext; 152cdf0e10cSrcweir }; 153cdf0e10cSrcweir 154cdf0e10cSrcweir typedef ::rtl::Reference< Canvas > CanvasRef; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir #endif 158