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_FLOATBITMAPBASE_HXX 25 #define INCLUDED_CANVAS_FLOATBITMAPBASE_HXX 26 27 #include <com/sun/star/rendering/XIeeeFloatBitmap.hpp> 28 #include <canvas/bitmapcanvasbase.hxx> 29 30 31 namespace canvas 32 { 33 /** Helper template to handle XIeeeFloatBitmap method forwarding to 34 BitmapCanvasHelper 35 36 Use this helper to handle the XIeeeFloatBitmap 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 XIeeeFloatBitmap 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 FloatBitmapBase : 70 public BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > 71 { 72 public: 73 typedef BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType; 74 75 // XIeeeFloatBitmap getData(::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerRectangle2D & rect)76 virtual ::com::sun::star::uno::Sequence< float > SAL_CALL getData( ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, 77 const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IndexOutOfBoundsException, 78 ::com::sun::star::rendering::VolatileContentDestroyedException, 79 ::com::sun::star::uno::RuntimeException) 80 { 81 verifyInput(rect, 82 static_cast< typename BaseType::UnambiguousBaseType* >(this)); 83 verifyIndexRange(rect, getSize() ); 84 85 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 86 87 return BaseType::maCanvasHelper.getData( bitmapLayout, 88 rect ); 89 } 90 setData(const::com::sun::star::uno::Sequence<float> & data,const::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerRectangle2D & rect)91 virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< float >& data, 92 const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, 93 const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IllegalArgumentException, 94 ::com::sun::star::lang::IndexOutOfBoundsException, 95 ::com::sun::star::uno::RuntimeException) 96 { 97 verifyInput(bitmapLayout, rect, 98 static_cast< typename BaseType::UnambiguousBaseType* >(this)); 99 verifyIndexRange(rect, getSize() ); 100 101 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 102 103 BaseType::mbSurfaceDirty = true; 104 BaseType::maCanvasHelper.modifying(); 105 106 BaseType::maCanvasHelper.setData( data, bitmapLayout, rect ); 107 } 108 setPixel(const::com::sun::star::uno::Sequence<float> & color,const::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerPoint2D & pos)109 virtual void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< float >& color, 110 const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, 111 const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IllegalArgumentException, 112 ::com::sun::star::lang::IndexOutOfBoundsException, 113 ::com::sun::star::uno::RuntimeException) 114 { 115 verifyInput(bitmapLayout, pos, 116 static_cast< typename BaseType::UnambiguousBaseType* >(this)); 117 verifyIndexRange(pos, getSize() ); 118 119 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 120 121 BaseType::mbSurfaceDirty = true; 122 BaseType::maCanvasHelper.modifying(); 123 124 BaseType::maCanvasHelper.setPixel( color, bitmapLayout, pos ); 125 } 126 getPixel(::com::sun::star::rendering::FloatingPointBitmapLayout & bitmapLayout,const::com::sun::star::geometry::IntegerPoint2D & pos)127 virtual ::com::sun::star::uno::Sequence< float > SAL_CALL getPixel( ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, 128 const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IndexOutOfBoundsException, 129 ::com::sun::star::rendering::VolatileContentDestroyedException, 130 ::com::sun::star::uno::RuntimeException) 131 { 132 verifyInput(pos, 133 static_cast< typename BaseType::UnambiguousBaseType* >(this)); 134 verifyIndexRange(pos, getSize() ); 135 136 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 137 138 return BaseType::maCanvasHelper.getPixel( bitmapLayout, 139 pos ); 140 } 141 getMemoryLayout()142 virtual ::com::sun::star::rendering::FloatingPointBitmapLayout SAL_CALL getMemoryLayout( ) throw (::com::sun::star::uno::RuntimeException) 143 { 144 typename BaseType::MutexType aGuard( BaseType::m_aMutex ); 145 146 return BaseType::maCanvasHelper.getMemoryLayout(); 147 } 148 }; 149 } 150 151 #endif /* INCLUDED_CANVAS_FLOATBITMAPBASE_HXX */ 152