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 INCLUDED_CANVAS_SOURCE_VCL_CANVASBITMAP_HXX
21 : #define INCLUDED_CANVAS_SOURCE_VCL_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/basemutexhelper.hxx>
36 : #include <canvas/base/integerbitmapbase.hxx>
37 : #include <canvasbitmaphelper.hxx>
38 :
39 : #include "impltools.hxx"
40 : #include "repainttarget.hxx"
41 : #include "spritecanvas.hxx"
42 :
43 :
44 : /* Definition of CanvasBitmap class */
45 :
46 : namespace vclcanvas
47 : {
48 : typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XBitmapCanvas,
49 : ::com::sun::star::rendering::XIntegerBitmap,
50 : ::com::sun::star::lang::XServiceInfo,
51 : ::com::sun::star::beans::XFastPropertySet > CanvasBitmapBase_Base;
52 : typedef ::canvas::IntegerBitmapBase<
53 : canvas::BitmapCanvasBase2<
54 : ::canvas::BaseMutexHelper< CanvasBitmapBase_Base >,
55 : CanvasBitmapHelper,
56 : tools::LocalGuard,
57 : ::cppu::OWeakObject> > CanvasBitmap_Base;
58 :
59 0 : class CanvasBitmap : public CanvasBitmap_Base,
60 : public RepaintTarget
61 : {
62 : public:
63 : /** Must be called with locked Solar mutex
64 :
65 : @param rSize
66 : Size in pixel of the bitmap to generate
67 :
68 : @param bAlphaBitmap
69 : When true, bitmap will have an alpha channel
70 :
71 : @param rDevice
72 : Reference device, with which bitmap should be compatible
73 : */
74 : CanvasBitmap( const ::Size& rSize,
75 : bool bAlphaBitmap,
76 : ::com::sun::star::rendering::XGraphicDevice& rDevice,
77 : const OutDevProviderSharedPtr& rOutDevProvider );
78 :
79 : /// Must be called with locked Solar mutex
80 : CanvasBitmap( const BitmapEx& rBitmap,
81 : ::com::sun::star::rendering::XGraphicDevice& rDevice,
82 : const OutDevProviderSharedPtr& rOutDevProvider );
83 :
84 : // XServiceInfo
85 : virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 :
89 : // RepaintTarget interface
90 : virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
91 : const ::com::sun::star::rendering::ViewState& viewState,
92 : const ::com::sun::star::rendering::RenderState& renderState,
93 : const ::Point& rPt,
94 : const ::Size& rSz,
95 : const GraphicAttr& rAttr ) const SAL_OVERRIDE;
96 :
97 : /// Not threadsafe! Returned object is shared!
98 : BitmapEx getBitmap() const;
99 :
100 : // XFastPropertySet
101 : // used to retrieve BitmapEx pointer or X Pixmap handles for this bitmap
102 : // handle values have these meanings:
103 : // 0 ... get pointer to BitmapEx
104 : // 1 ... get X pixmap handle to rgb content
105 : // 2 ... get X pitmap handle to alpha mask
106 : // returned any contains either BitmapEx pointer or array of three Any value
107 : // 1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
108 : // 2nd the pixmap handle
109 : // 3rd the pixmap depth
110 : virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 0 : virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE {}
112 :
113 : private:
114 : /** MUST hold here, too, since CanvasHelper only contains a
115 : raw pointer (without refcounting)
116 : */
117 : ::com::sun::star::uno::Reference<com::sun::star::rendering::XGraphicDevice> mxDevice;
118 : };
119 : }
120 :
121 : #endif // INCLUDED_CANVAS_SOURCE_VCL_CANVASBITMAP_HXX
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|