1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CANVASBITMAP_HXX
21 #define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CANVASBITMAP_HXX
23 #include <cppuhelper/compbase4.hxx>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
27 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
28 #include <com/sun/star/beans/XFastPropertySet.hpp>
29 #include <comphelper/uno3.hxx>
31 #include <basegfx/vector/b2isize.hxx>
33 #include <boost/shared_ptr.hpp>
35 #include <canvas/base/basemutexhelper.hxx>
36 #include <canvas/base/integerbitmapbase.hxx>
38 #include "cairo_canvashelper.hxx"
39 #include "cairo_repainttarget.hxx"
40 #include "cairo_spritecanvas.hxx"
43 /* Definition of CanvasBitmap class */
47 typedef ::cppu::WeakComponentImplHelper4
< ::com::sun::star::rendering::XBitmapCanvas
,
48 ::com::sun::star::rendering::XIntegerBitmap
,
49 ::com::sun::star::lang::XServiceInfo
,
50 ::com::sun::star::beans::XFastPropertySet
> CanvasBitmapBase_Base
;
51 class CanvasBitmapSpriteSurface_Base
:
52 public ::canvas::BaseMutexHelper
<CanvasBitmapBase_Base
>,
53 public SurfaceProvider
57 typedef ::canvas::IntegerBitmapBase
<
58 canvas::BitmapCanvasBase2
<
59 CanvasBitmapSpriteSurface_Base
,
62 ::cppu::OWeakObject
> > CanvasBitmap_Base
;
64 class CanvasBitmap
: public CanvasBitmap_Base
,
68 /** Create a canvas bitmap for the given surface
74 Reference device, with which bitmap should be compatible
76 CanvasBitmap( const ::basegfx::B2ISize
& rSize
,
77 const SurfaceProviderRef
& rDevice
,
78 ::com::sun::star::rendering::XGraphicDevice
* pDevice
,
81 /// Dispose all internal references
82 virtual void disposeThis() SAL_OVERRIDE
;
84 // Forwarding the XComponent implementation to the
85 // cppu::ImplHelper templated base
86 // Classname Base doing refcounting Base implementing the XComponent interface
89 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasBitmap
, CanvasBitmapBase_Base
, ::cppu::WeakComponentImplHelperBase
)
92 virtual OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
93 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
94 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
97 virtual ::cairo::SurfaceSharedPtr
getSurface() SAL_OVERRIDE
;
98 virtual ::cairo::SurfaceSharedPtr
createSurface( const ::basegfx::B2ISize
& rSize
, int aContent
= CAIRO_CONTENT_COLOR_ALPHA
) SAL_OVERRIDE
;
99 virtual ::cairo::SurfaceSharedPtr
createSurface( ::Bitmap
& rBitmap
) SAL_OVERRIDE
;
100 virtual ::cairo::SurfaceSharedPtr
changeSurface( bool bHasAlpha
, bool bCopyContent
) SAL_OVERRIDE
;
101 virtual OutputDevice
* getOutputDevice() SAL_OVERRIDE
;
104 virtual bool repaint( const ::cairo::SurfaceSharedPtr
& pSurface
,
105 const ::com::sun::star::rendering::ViewState
& viewState
,
106 const ::com::sun::star::rendering::RenderState
& renderState
) SAL_OVERRIDE
;
109 // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
110 // handle values have these meanings:
111 // 0 ... get pointer to BitmapEx
112 // 1 ... get X pixmap handle to rgb content
113 // 2 ... get X pitmap handle to alpha mask
114 // returned any contains either BitmapEx pointer or array of three Any value
115 // 1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
116 // 2nd the pixmap handle
117 // 3rd the pixmap depth
118 virtual ::com::sun::star::uno::Any SAL_CALL
getFastPropertyValue(sal_Int32 nHandle
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
119 virtual void SAL_CALL
setFastPropertyValue(sal_Int32
, const ::com::sun::star::uno::Any
&) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
{}
122 SurfaceProviderRef mpSurfaceProvider
;
123 ::cairo::SurfaceSharedPtr mpBufferSurface
;
124 ::cairo::CairoSharedPtr mpBufferCairo
;
126 const ::basegfx::B2ISize maSize
;
127 const bool mbHasAlpha
;
131 #endif // INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CANVASBITMAP_HXX
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */