bump product version to 4.2.0.1
[LibreOffice.git] / include / basebmp / colorblendaccessoradapter.hxx
blobc4511c709844f50eac8c2e0f2a9b368a6bbfec5d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_BASEBMP_COLORBLENDACCESSORADAPTER_HXX
21 #define INCLUDED_BASEBMP_COLORBLENDACCESSORADAPTER_HXX
23 #include <basebmp/colortraits.hxx>
25 namespace basebmp
28 /** Accessor adapter that blends input value against fixed color value
30 Used to blend an alpha mask 'through' a fixed color value into the
31 destination.
33 The getter functors return a constant value (usually the zero of
34 the value type, this preserves the original destination content
35 when blitting through a mask) - there really isn't no other
36 sensible default behaviour for these methods.
38 template< class WrappedAccessor,
39 typename AlphaType,
40 bool polarity > class ConstantColorBlendSetterAccessorAdapter
42 public:
43 typedef AlphaType alpha_type;
44 typedef AlphaType value_type;
45 typedef typename WrappedAccessor::value_type color_type;
47 private:
48 typename ColorTraits< color_type >::
49 template blend_functor<alpha_type,polarity>::type maFunctor;
50 WrappedAccessor maWrappee;
51 color_type maBlendColor;
52 value_type maGetterValue;
54 public:
55 ConstantColorBlendSetterAccessorAdapter() :
56 maFunctor(),
57 maWrappee(),
58 maBlendColor(),
59 maGetterValue()
62 template< class T > explicit ConstantColorBlendSetterAccessorAdapter( T acc ) :
63 maFunctor(),
64 maWrappee(acc),
65 maBlendColor(),
66 maGetterValue()
69 template< class T > ConstantColorBlendSetterAccessorAdapter( T acc,
70 color_type col ) :
71 maFunctor(),
72 maWrappee(acc),
73 maBlendColor(col),
74 maGetterValue()
77 template< class T > ConstantColorBlendSetterAccessorAdapter( T acc,
78 color_type col,
79 value_type val ) :
80 maFunctor(),
81 maWrappee(acc),
82 maBlendColor(col),
83 maGetterValue(val)
86 // -------------------------------------------------------
88 void setColor( color_type col ) { maBlendColor=col; }
89 color_type getColor() { return maBlendColor; }
90 void setGetterValue( value_type val ) { maGetterValue=val; }
91 value_type getGetterValue() { return maGetterValue; }
93 // -------------------------------------------------------
95 WrappedAccessor const& getWrappedAccessor() const { return maWrappee; }
96 WrappedAccessor& getWrappedAccessor() { return maWrappee; }
98 // -------------------------------------------------------
100 /// @return constant value, regardless of iterator content
101 template< typename IteratorType > value_type operator()(SAL_UNUSED_PARAMETER IteratorType const& ) const
103 return maGetterValue;
105 /// @return constant value, regardless of iterator content
106 template< typename IteratorType, class Difference >
107 value_type operator()(SAL_UNUSED_PARAMETER IteratorType const& , SAL_UNUSED_PARAMETER Difference const& ) const
109 return maGetterValue;
112 // -------------------------------------------------------
114 template< typename V, typename IteratorType >
115 void set(V const& value, IteratorType const& i) const
117 maWrappee.set(
118 maFunctor(
119 vigra::detail::RequiresExplicitCast<alpha_type>::cast(value),
120 maWrappee(i),
121 maBlendColor),
122 i );
125 template< typename V, typename IteratorType, class Difference >
126 void set(V const& value, IteratorType const& i, Difference const& diff) const
128 maWrappee.set(
129 maFunctor(
130 vigra::detail::RequiresExplicitCast<alpha_type>::cast(value),
131 maWrappee(i,diff),
132 maBlendColor),
134 diff );
138 } // namespace basebmp
140 #endif /* INCLUDED_BASEBMP_COLORBLENDACCESSORADAPTER_HXX */
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */