1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
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
,
40 bool polarity
> class ConstantColorBlendSetterAccessorAdapter
43 typedef AlphaType alpha_type
;
44 typedef AlphaType value_type
;
45 typedef typename
WrappedAccessor::value_type color_type
;
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
;
55 ConstantColorBlendSetterAccessorAdapter() :
62 template< class T
> explicit ConstantColorBlendSetterAccessorAdapter( T acc
) :
69 template< class T
> ConstantColorBlendSetterAccessorAdapter( T acc
,
77 template< class T
> ConstantColorBlendSetterAccessorAdapter( T acc
,
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
119 vigra::detail::RequiresExplicitCast
<alpha_type
>::cast(value
),
125 template< typename V
, typename IteratorType
, class Difference
>
126 void set(V
const& value
, IteratorType
const& i
, Difference
const& diff
) const
130 vigra::detail::RequiresExplicitCast
<alpha_type
>::cast(value
),
138 } // namespace basebmp
140 #endif /* INCLUDED_BASEBMP_COLORBLENDACCESSORADAPTER_HXX */
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */