xref: /trunk/main/canvas/inc/canvas/base/doublebitmapbase.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_CANVAS_DOUBLEBITMAPBASE_HXX
25 #define INCLUDED_CANVAS_DOUBLEBITMAPBASE_HXX
26 
27 #include <com/sun/star/rendering/XIeeeDoubleBitmap.hpp>
28 #include <canvas/bitmapcanvasbase.hxx>
29 
30 
31 namespace canvas
32 {
33     /** Helper template to handle XIeeeDoubleBitmap method forwarding to
34         BitmapCanvasHelper
35 
36         Use this helper to handle the XIeeeDoubleBitmap part of your
37         implementation.
38 
39         @tpl Base
40         Base class to use, most probably one of the
41         WeakComponentImplHelperN templates with the appropriate
42         interfaces. At least XIeeeDoubleBitmap should be among them (why
43         else would you use this template, then?). Base class must have
44         an Base( const Mutex& ) constructor (like the
45         WeakComponentImplHelperN templates have).
46 
47         @tpl CanvasHelper
48         Canvas helper implementation for the backend in question
49 
50         @tpl Mutex
51         Lock strategy to use. Defaults to using the
52         OBaseMutex-provided lock.  Every time one of the methods is
53         entered, an object of type Mutex is created with m_aMutex as
54         the sole parameter, and destroyed again when the method scope
55         is left.
56 
57         @tpl UnambiguousBase
58         Optional unambiguous base class for XInterface of Base. It's
59         sometimes necessary to specify this parameter, e.g. if Base
60         derives from multiple UNO interface (were each provides its
61         own version of XInterface, making the conversion ambiguous)
62 
63         @see CanvasBase for further contractual requirements towards
64         the CanvasHelper type, and some examples.
65      */
66     template< class Base,
67               class CanvasHelper,
68               class Mutex=::osl::MutexGuard,
69               class UnambiguousBase=::com::sun::star::uno::XInterface > class DoubleBitmapBase :
70         public BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >
71     {
72     public:
73         typedef BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase >  BaseType;
74 
75         // XIeeeDoubleBitmap
getData(::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerRectangle2D & rect)76         virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getData( ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout,
77                                                                             const ::com::sun::star::geometry::IntegerRectangle2D&   rect )
78         {
79             verifyInput(rect, this);
80             verifyIndexRange(rect, getSize() );
81 
82             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
83 
84             return BaseType::maCanvasHelper.getData( bitmapLayout,
85                                                      rect );
86         }
87 
setData(const::com::sun::star::uno::Sequence<double> & data,const::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerRectangle2D & rect)88         virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< double >&              data,
89                                        const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout,
90                                        const ::com::sun::star::geometry::IntegerRectangle2D&         rect )
91         {
92             verifyInput(bitmapLayout, rect, this);
93             verifyIndexRange(rect, getSize() );
94 
95             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
96 
97             BaseType::mbSurfaceDirty = true;
98             BaseType::maCanvasHelper.modifying();
99 
100             BaseType::maCanvasHelper.setData( data, bitmapLayout, rect );
101         }
102 
setPixel(const::com::sun::star::uno::Sequence<double> & color,const::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerPoint2D & pos)103         virtual void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< double >&                color,
104                                         const ::com::sun::star::rendering::FloatingPointBitmapLayout&   bitmapLayout,
105                                         const ::com::sun::star::geometry::IntegerPoint2D&               pos )
106         {
107             verifyInput(bitmapLayout, pos, this);
108             verifyIndexRange(pos, getSize() );
109 
110             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
111 
112             BaseType::mbSurfaceDirty = true;
113             BaseType::maCanvasHelper.modifying();
114 
115             BaseType::maCanvasHelper.setPixel( color, bitmapLayout, pos );
116         }
117 
getPixel(::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerPoint2D & pos)118         virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getPixel( ::com::sun::star::rendering::FloatingPointBitmapLayout&    bitmapLayout,
119                                                                              const ::com::sun::star::geometry::IntegerPoint2D&          pos )
120         {
121             verifyInput(pos, this);
122             verifyIndexRange(pos, getSize() );
123 
124             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
125 
126             return BaseType::maCanvasHelper.getPixel( bitmapLayout,
127                                                       pos );
128         }
129 
getMemoryLayout()130         virtual ::com::sun::star::rendering::FloatingPointBitmapLayout SAL_CALL getMemoryLayout(  )
131         {
132             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
133 
134             return BaseType::maCanvasHelper.getMemoryLayout();
135         }
136     };
137 }
138 
139 #endif /* INCLUDED_CANVAS_DOUBLEBITMAPBASE_HXX */
140