Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _VCLCANVAS_CANVASBITMAP_HXX
21 : #define _VCLCANVAS_CANVASBITMAP_HXX
22 :
23 : #include <cppuhelper/compbase4.hxx>
24 :
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 :
30 : #include <vcl/virdev.hxx>
31 : #include <vcl/bitmapex.hxx>
32 :
33 : #include <canvas/vclwrapper.hxx>
34 :
35 : #include <canvas/base/integerbitmapbase.hxx>
36 : #include <canvasbitmaphelper.hxx>
37 :
38 : #include "impltools.hxx"
39 : #include "repainttarget.hxx"
40 : #include "spritecanvas.hxx"
41 :
42 :
43 : /* Definition of CanvasBitmap class */
44 :
45 : namespace vclcanvas
46 : {
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 : typedef ::canvas::IntegerBitmapBase< ::canvas::DisambiguationHelper< CanvasBitmapBase_Base >,
52 : CanvasBitmapHelper,
53 : tools::LocalGuard,
54 : ::cppu::OWeakObject > CanvasBitmap_Base;
55 :
56 0 : class CanvasBitmap : public CanvasBitmap_Base,
57 : public RepaintTarget
58 : {
59 : public:
60 : /** Must be called with locked Solar mutex
61 :
62 : @param rSize
63 : Size in pixel of the bitmap to generate
64 :
65 : @param bAlphaBitmap
66 : When true, bitmap will have an alpha channel
67 :
68 : @param rDevice
69 : Reference device, with which bitmap should be compatible
70 : */
71 : CanvasBitmap( const ::Size& rSize,
72 : bool bAlphaBitmap,
73 : ::com::sun::star::rendering::XGraphicDevice& rDevice,
74 : const OutDevProviderSharedPtr& rOutDevProvider );
75 :
76 : /// Must be called with locked Solar mutex
77 : CanvasBitmap( const BitmapEx& rBitmap,
78 : ::com::sun::star::rendering::XGraphicDevice& rDevice,
79 : const OutDevProviderSharedPtr& rOutDevProvider );
80 :
81 : // XServiceInfo
82 : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
83 : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
84 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
85 :
86 : // RepaintTarget interface
87 : virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
88 : const ::com::sun::star::rendering::ViewState& viewState,
89 : const ::com::sun::star::rendering::RenderState& renderState,
90 : const ::Point& rPt,
91 : const ::Size& rSz,
92 : const GraphicAttr& rAttr ) const;
93 :
94 : /// Not threadsafe! Returned object is shared!
95 : BitmapEx getBitmap() const;
96 :
97 : // XFastPropertySet
98 : // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
99 : // handle values have these meanings:
100 : // 0 ... get pointer to BitmapEx
101 : // 1 ... get X pixmap handle to rgb content
102 : // 2 ... get X pitmap handle to alpha mask
103 : // returned any contains either BitmapEx pointer or array of three Any value
104 : // 1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
105 : // 2nd the pixmap handle
106 : // 3rd the pixmap depth
107 : virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) throw (::com::sun::star::uno::RuntimeException);
108 0 : virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException) {}
109 :
110 : private:
111 : /** MUST hold here, too, since CanvasHelper only contains a
112 : raw pointer (without refcounting)
113 : */
114 : ::com::sun::star::uno::Reference<com::sun::star::rendering::XGraphicDevice> mxDevice;
115 : };
116 : }
117 :
118 : #endif /* _VCLCANVAS_CANVASBITMAP_HXX */
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|