1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX 25*b1cdbd2cSJim Jagielski #define _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <cppuhelper/compbase4.hxx> 28*b1cdbd2cSJim Jagielski #include <comphelper/uno3.hxx> 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XServiceInfo.hpp> 31*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XComponent.hpp> 32*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XCustomSprite.hpp> 33*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XIntegerBitmap.hpp> 34*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XPolyPolygon2D.hpp> 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski #include <basegfx/point/b2dpoint.hxx> 37*b1cdbd2cSJim Jagielski #include <basegfx/vector/b2isize.hxx> 38*b1cdbd2cSJim Jagielski #include <basegfx/matrix/b2dhommatrix.hxx> 39*b1cdbd2cSJim Jagielski 40*b1cdbd2cSJim Jagielski #include <canvas/base/basemutexhelper.hxx> 41*b1cdbd2cSJim Jagielski #include <canvas/base/canvascustomspritebase.hxx> 42*b1cdbd2cSJim Jagielski 43*b1cdbd2cSJim Jagielski #include "cairo_sprite.hxx" 44*b1cdbd2cSJim Jagielski #include "cairo_cairo.hxx" 45*b1cdbd2cSJim Jagielski #include "cairo_canvashelper.hxx" 46*b1cdbd2cSJim Jagielski #include "cairo_repainttarget.hxx" 47*b1cdbd2cSJim Jagielski #include "cairo_spritehelper.hxx" 48*b1cdbd2cSJim Jagielski #include "cairo_spritecanvas.hxx" 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski 51*b1cdbd2cSJim Jagielski namespace cairocanvas 52*b1cdbd2cSJim Jagielski { 53*b1cdbd2cSJim Jagielski typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XCustomSprite, 54*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XBitmapCanvas, 55*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XIntegerBitmap, 56*b1cdbd2cSJim Jagielski ::com::sun::star::lang::XServiceInfo > CanvasCustomSpriteBase_Base; 57*b1cdbd2cSJim Jagielski /** Mixin Sprite 58*b1cdbd2cSJim Jagielski 59*b1cdbd2cSJim Jagielski Have to mixin the Sprite interface before deriving from 60*b1cdbd2cSJim Jagielski ::canvas::CanvasCustomSpriteBase, as this template should 61*b1cdbd2cSJim Jagielski already implement some of those interface methods. 62*b1cdbd2cSJim Jagielski 63*b1cdbd2cSJim Jagielski The reason why this appears kinda convoluted is the fact that 64*b1cdbd2cSJim Jagielski we cannot specify non-IDL types as WeakComponentImplHelperN 65*b1cdbd2cSJim Jagielski template args, and furthermore, don't want to derive 66*b1cdbd2cSJim Jagielski ::canvas::CanvasCustomSpriteBase directly from 67*b1cdbd2cSJim Jagielski ::canvas::Sprite (because derivees of 68*b1cdbd2cSJim Jagielski ::canvas::CanvasCustomSpriteBase have to explicitely forward 69*b1cdbd2cSJim Jagielski the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS) 70*b1cdbd2cSJim Jagielski anyway). Basically, ::canvas::CanvasCustomSpriteBase should 71*b1cdbd2cSJim Jagielski remain a base class that provides implementation, not to 72*b1cdbd2cSJim Jagielski enforce any specific interface on its derivees. 73*b1cdbd2cSJim Jagielski */ 74*b1cdbd2cSJim Jagielski class CanvasCustomSpriteSpriteBase_Base : public ::canvas::BaseMutexHelper< CanvasCustomSpriteBase_Base >, 75*b1cdbd2cSJim Jagielski public Sprite, 76*b1cdbd2cSJim Jagielski public SurfaceProvider 77*b1cdbd2cSJim Jagielski { 78*b1cdbd2cSJim Jagielski }; 79*b1cdbd2cSJim Jagielski 80*b1cdbd2cSJim Jagielski typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base, 81*b1cdbd2cSJim Jagielski SpriteHelper, 82*b1cdbd2cSJim Jagielski CanvasHelper, 83*b1cdbd2cSJim Jagielski ::osl::MutexGuard, 84*b1cdbd2cSJim Jagielski ::cppu::OWeakObject > CanvasCustomSpriteBaseT; 85*b1cdbd2cSJim Jagielski 86*b1cdbd2cSJim Jagielski /* Definition of CanvasCustomSprite class */ 87*b1cdbd2cSJim Jagielski 88*b1cdbd2cSJim Jagielski class CanvasCustomSprite : public CanvasCustomSpriteBaseT, 89*b1cdbd2cSJim Jagielski public RepaintTarget 90*b1cdbd2cSJim Jagielski { 91*b1cdbd2cSJim Jagielski public: 92*b1cdbd2cSJim Jagielski /** Create a custom sprite 93*b1cdbd2cSJim Jagielski 94*b1cdbd2cSJim Jagielski @param rSpriteSize 95*b1cdbd2cSJim Jagielski Size of the sprite in pixel 96*b1cdbd2cSJim Jagielski 97*b1cdbd2cSJim Jagielski @param rRefDevice 98*b1cdbd2cSJim Jagielski Associated output device 99*b1cdbd2cSJim Jagielski 100*b1cdbd2cSJim Jagielski @param rSpriteCanvas 101*b1cdbd2cSJim Jagielski Target canvas 102*b1cdbd2cSJim Jagielski 103*b1cdbd2cSJim Jagielski @param rDevice 104*b1cdbd2cSJim Jagielski Target DX device 105*b1cdbd2cSJim Jagielski */ 106*b1cdbd2cSJim Jagielski CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize, 107*b1cdbd2cSJim Jagielski const SpriteCanvasRef& rRefDevice ); 108*b1cdbd2cSJim Jagielski 109*b1cdbd2cSJim Jagielski virtual void SAL_CALL disposing(); 110*b1cdbd2cSJim Jagielski 111*b1cdbd2cSJim Jagielski // Forwarding the XComponent implementation to the 112*b1cdbd2cSJim Jagielski // cppu::ImplHelper templated base 113*b1cdbd2cSJim Jagielski // Classname Base doing refcount Base implementing the XComponent interface 114*b1cdbd2cSJim Jagielski // | | | 115*b1cdbd2cSJim Jagielski // V V V 116*b1cdbd2cSJim Jagielski DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase ); 117*b1cdbd2cSJim Jagielski 118*b1cdbd2cSJim Jagielski // XServiceInfo 119*b1cdbd2cSJim Jagielski virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 120*b1cdbd2cSJim Jagielski virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException ); 121*b1cdbd2cSJim Jagielski virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 122*b1cdbd2cSJim Jagielski 123*b1cdbd2cSJim Jagielski // Sprite 124*b1cdbd2cSJim Jagielski virtual void redraw( const ::cairo::CairoSharedPtr& pCairo, 125*b1cdbd2cSJim Jagielski bool bBufferedUpdate ) const; 126*b1cdbd2cSJim Jagielski virtual void redraw( const ::cairo::CairoSharedPtr& pCairo, 127*b1cdbd2cSJim Jagielski const ::basegfx::B2DPoint& rOrigOutputPos, 128*b1cdbd2cSJim Jagielski bool bBufferedUpdate ) const; 129*b1cdbd2cSJim Jagielski 130*b1cdbd2cSJim Jagielski // RepaintTarget 131*b1cdbd2cSJim Jagielski virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface, 132*b1cdbd2cSJim Jagielski const ::com::sun::star::rendering::ViewState& viewState, 133*b1cdbd2cSJim Jagielski const ::com::sun::star::rendering::RenderState& renderState ); 134*b1cdbd2cSJim Jagielski 135*b1cdbd2cSJim Jagielski // SurfaceProvider 136*b1cdbd2cSJim Jagielski virtual SurfaceSharedPtr getSurface(); 137*b1cdbd2cSJim Jagielski virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA ); 138*b1cdbd2cSJim Jagielski virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap ); 139*b1cdbd2cSJim Jagielski virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent ); 140*b1cdbd2cSJim Jagielski virtual OutputDevice* getOutputDevice(); 141*b1cdbd2cSJim Jagielski 142*b1cdbd2cSJim Jagielski private: 143*b1cdbd2cSJim Jagielski /** MUST hold here, too, since CanvasHelper only contains a 144*b1cdbd2cSJim Jagielski raw pointer (without refcounting) 145*b1cdbd2cSJim Jagielski */ 146*b1cdbd2cSJim Jagielski SpriteCanvasRef mpSpriteCanvas; 147*b1cdbd2cSJim Jagielski ::cairo::SurfaceSharedPtr mpBufferSurface; 148*b1cdbd2cSJim Jagielski ::basegfx::B2ISize maSize; 149*b1cdbd2cSJim Jagielski }; 150*b1cdbd2cSJim Jagielski } 151*b1cdbd2cSJim Jagielski 152*b1cdbd2cSJim Jagielski #endif /* _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX */ 153