LCOV - code coverage report
Current view: top level - include/basebmp - colorblendaccessoradapter.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 10 10 100.0 %
Date: 2014-11-03 Functions: 23 108 21.3 %
Legend: Lines: hit not hit

          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_BASEBMP_COLORBLENDACCESSORADAPTER_HXX
      21             : #define INCLUDED_BASEBMP_COLORBLENDACCESSORADAPTER_HXX
      22             : 
      23             : #include <basebmp/colortraits.hxx>
      24             : 
      25             : namespace basebmp
      26             : {
      27             : 
      28             : /** Accessor adapter that blends input value against fixed color value
      29             : 
      30             :     Used to blend an alpha mask 'through' a fixed color value into the
      31             :     destination.
      32             : 
      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.
      37             :  */
      38             : template< class    WrappedAccessor,
      39             :           typename AlphaType,
      40             :           bool     polarity > class ConstantColorBlendSetterAccessorAdapter
      41             : {
      42             : public:
      43             :     typedef AlphaType                            alpha_type;
      44             :     typedef AlphaType                            value_type;
      45             :     typedef typename WrappedAccessor::value_type color_type;
      46             : 
      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;
      53             : 
      54             : public:
      55             :     ConstantColorBlendSetterAccessorAdapter() :
      56             :         maFunctor(),
      57             :         maWrappee(),
      58             :         maBlendColor(),
      59             :         maGetterValue()
      60             :     {}
      61             : 
      62     3660944 :     template< class T > explicit ConstantColorBlendSetterAccessorAdapter( T acc ) :
      63             :         maFunctor(),
      64             :         maWrappee(acc),
      65             :         maBlendColor(),
      66     3660944 :         maGetterValue()
      67     3660944 :     {}
      68             : 
      69             :     template< class T > ConstantColorBlendSetterAccessorAdapter( T          acc,
      70             :                                                                  color_type col ) :
      71             :         maFunctor(),
      72             :         maWrappee(acc),
      73             :         maBlendColor(col),
      74             :         maGetterValue()
      75             :     {}
      76             : 
      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)
      84             :     {}
      85             : 
      86             : 
      87             : 
      88     2293658 :     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; }
      92             : 
      93             : 
      94             : 
      95             :     WrappedAccessor const& getWrappedAccessor() const { return maWrappee; }
      96             :     WrappedAccessor&       getWrappedAccessor() { return maWrappee; }
      97             : 
      98             : 
      99             : 
     100             :     /// @return constant value, regardless of iterator content
     101       47088 :     template< typename IteratorType > value_type operator()(SAL_UNUSED_PARAMETER IteratorType const& ) const
     102             :     {
     103       47088 :         return maGetterValue;
     104             :     }
     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
     108             :     {
     109             :         return maGetterValue;
     110             :     }
     111             : 
     112             : 
     113             : 
     114             :     template< typename V, typename IteratorType >
     115   149891363 :     void set(V const& value, IteratorType const& i) const
     116             :     {
     117   299782726 :         maWrappee.set(
     118             :             maFunctor(
     119   149891363 :                 vigra::detail::RequiresExplicitCast<alpha_type>::cast(value),
     120             :                 maWrappee(i),
     121             :                 maBlendColor),
     122             :             i );
     123   149891363 :     }
     124             : 
     125             :     template< typename V, typename IteratorType, class Difference >
     126             :     void set(V const& value, IteratorType const& i, Difference const& diff) const
     127             :     {
     128             :         maWrappee.set(
     129             :             maFunctor(
     130             :                 vigra::detail::RequiresExplicitCast<alpha_type>::cast(value),
     131             :                 maWrappee(i,diff),
     132             :                 maBlendColor),
     133             :             i,
     134             :             diff );
     135             :     }
     136             : };
     137             : 
     138             : } // namespace basebmp
     139             : 
     140             : #endif /* INCLUDED_BASEBMP_COLORBLENDACCESSORADAPTER_HXX */
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10