LCOV - code coverage report
Current view: top level - gfx/2d - FilterProcessing.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 6 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef _MOZILLA_GFX_FILTERPROCESSING_H_
       7             : #define _MOZILLA_GFX_FILTERPROCESSING_H_
       8             : 
       9             : #include "2D.h"
      10             : #include "Filters.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace gfx {
      14             : 
      15             : const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_B = 0;
      16             : const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_G = 1;
      17             : const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_R = 2;
      18             : const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_A = 3;
      19             : 
      20             : class FilterProcessing
      21             : {
      22             : public:
      23             : 
      24             :   // Fast approximate division by 255. It has the property that
      25             :   // for all 0 <= v <= 255*255, FastDivideBy255(v) == v/255.
      26             :   // But it only uses two adds and two shifts instead of an
      27             :   // integer division (which is expensive on many processors).
      28             :   template<class B, class A>
      29           0 :   static B FastDivideBy255(A v)
      30             :   {
      31           0 :     return ((v << 8) + v + 255) >> 16;
      32             :   }
      33             : 
      34             :   static already_AddRefed<DataSourceSurface> ExtractAlpha(DataSourceSurface* aSource);
      35             :   static already_AddRefed<DataSourceSurface> ConvertToB8G8R8A8(SourceSurface* aSurface);
      36             :   static already_AddRefed<DataSourceSurface> ApplyBlending(DataSourceSurface* aInput1, DataSourceSurface* aInput2, BlendMode aBlendMode);
      37             :   static void ApplyMorphologyHorizontal(uint8_t* aSourceData, int32_t aSourceStride,
      38             :                                           uint8_t* aDestData, int32_t aDestStride,
      39             :                                           const IntRect& aDestRect, int32_t aRadius,
      40             :                                           MorphologyOperator aOperator);
      41             :   static void ApplyMorphologyVertical(uint8_t* aSourceData, int32_t aSourceStride,
      42             :                                           uint8_t* aDestData, int32_t aDestStride,
      43             :                                           const IntRect& aDestRect, int32_t aRadius,
      44             :                                           MorphologyOperator aOperator);
      45             :   static already_AddRefed<DataSourceSurface> ApplyColorMatrix(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
      46             :   static void ApplyComposition(DataSourceSurface* aSource, DataSourceSurface* aDest, CompositeOperator aOperator);
      47             :   static void SeparateColorChannels(DataSourceSurface* aSource,
      48             :                                     RefPtr<DataSourceSurface>& aChannel0,
      49             :                                     RefPtr<DataSourceSurface>& aChannel1,
      50             :                                     RefPtr<DataSourceSurface>& aChannel2,
      51             :                                     RefPtr<DataSourceSurface>& aChannel3);
      52             :   static already_AddRefed<DataSourceSurface>
      53             :     CombineColorChannels(DataSourceSurface* aChannel0, DataSourceSurface* aChannel1,
      54             :                          DataSourceSurface* aChannel2, DataSourceSurface* aChannel3);
      55             :   static void DoPremultiplicationCalculation(const IntSize& aSize,
      56             :                                         uint8_t* aTargetData, int32_t aTargetStride,
      57             :                                         uint8_t* aSourceData, int32_t aSourceStride);
      58             :   static void DoUnpremultiplicationCalculation(const IntSize& aSize,
      59             :                                                uint8_t* aTargetData, int32_t aTargetStride,
      60             :                                                uint8_t* aSourceData, int32_t aSourceStride);
      61             :   static already_AddRefed<DataSourceSurface>
      62             :     RenderTurbulence(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
      63             :                      int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect);
      64             :   static already_AddRefed<DataSourceSurface>
      65             :     ApplyArithmeticCombine(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4);
      66             : 
      67             : protected:
      68             :   static void ExtractAlpha_Scalar(const IntSize& size, uint8_t* sourceData, int32_t sourceStride, uint8_t* alphaData, int32_t alphaStride);
      69             :   static already_AddRefed<DataSourceSurface> ConvertToB8G8R8A8_Scalar(SourceSurface* aSurface);
      70             :   static void ApplyMorphologyHorizontal_Scalar(uint8_t* aSourceData, int32_t aSourceStride,
      71             :                                                uint8_t* aDestData, int32_t aDestStride,
      72             :                                                const IntRect& aDestRect, int32_t aRadius,
      73             :                                                MorphologyOperator aOperator);
      74             :   static void ApplyMorphologyVertical_Scalar(uint8_t* aSourceData, int32_t aSourceStride,
      75             :                                                uint8_t* aDestData, int32_t aDestStride,
      76             :                                                const IntRect& aDestRect, int32_t aRadius,
      77             :                                                MorphologyOperator aOperator);
      78             :   static already_AddRefed<DataSourceSurface> ApplyColorMatrix_Scalar(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
      79             :   static void ApplyComposition_Scalar(DataSourceSurface* aSource, DataSourceSurface* aDest, CompositeOperator aOperator);
      80             : 
      81             :   static void SeparateColorChannels_Scalar(const IntSize &size, uint8_t* sourceData, int32_t sourceStride, uint8_t* channel0Data, uint8_t* channel1Data, uint8_t* channel2Data, uint8_t* channel3Data, int32_t channelStride);
      82             :   static void CombineColorChannels_Scalar(const IntSize &size, int32_t resultStride, uint8_t* resultData, int32_t channelStride, uint8_t* channel0Data, uint8_t* channel1Data, uint8_t* channel2Data, uint8_t* channel3Data);
      83             :   static void DoPremultiplicationCalculation_Scalar(const IntSize& aSize,
      84             :                                         uint8_t* aTargetData, int32_t aTargetStride,
      85             :                                         uint8_t* aSourceData, int32_t aSourceStride);
      86             :   static void DoUnpremultiplicationCalculation_Scalar(const IntSize& aSize,
      87             :                                                uint8_t* aTargetData, int32_t aTargetStride,
      88             :                                                uint8_t* aSourceData, int32_t aSourceStride);
      89             :   static already_AddRefed<DataSourceSurface>
      90             :     RenderTurbulence_Scalar(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
      91             :                             int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect);
      92             :   static already_AddRefed<DataSourceSurface>
      93             :     ApplyArithmeticCombine_Scalar(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4);
      94             : 
      95             : #ifdef USE_SSE2
      96             :   static void ExtractAlpha_SSE2(const IntSize& size, uint8_t* sourceData, int32_t sourceStride, uint8_t* alphaData, int32_t alphaStride);
      97             :   static already_AddRefed<DataSourceSurface> ConvertToB8G8R8A8_SSE2(SourceSurface* aSurface);
      98             :   static already_AddRefed<DataSourceSurface> ApplyBlending_SSE2(DataSourceSurface* aInput1, DataSourceSurface* aInput2, BlendMode aBlendMode);
      99             :   static void ApplyMorphologyHorizontal_SSE2(uint8_t* aSourceData, int32_t aSourceStride,
     100             :                                              uint8_t* aDestData, int32_t aDestStride,
     101             :                                              const IntRect& aDestRect, int32_t aRadius,
     102             :                                              MorphologyOperator aOperator);
     103             :   static void ApplyMorphologyVertical_SSE2(uint8_t* aSourceData, int32_t aSourceStride,
     104             :                                              uint8_t* aDestData, int32_t aDestStride,
     105             :                                              const IntRect& aDestRect, int32_t aRadius,
     106             :                                              MorphologyOperator aOperator);
     107             :   static already_AddRefed<DataSourceSurface> ApplyColorMatrix_SSE2(DataSourceSurface* aInput, const Matrix5x4 &aMatrix);
     108             :   static void ApplyComposition_SSE2(DataSourceSurface* aSource, DataSourceSurface* aDest, CompositeOperator aOperator);
     109             :   static void SeparateColorChannels_SSE2(const IntSize &size, uint8_t* sourceData, int32_t sourceStride, uint8_t* channel0Data, uint8_t* channel1Data, uint8_t* channel2Data, uint8_t* channel3Data, int32_t channelStride);
     110             :   static void CombineColorChannels_SSE2(const IntSize &size, int32_t resultStride, uint8_t* resultData, int32_t channelStride, uint8_t* channel0Data, uint8_t* channel1Data, uint8_t* channel2Data, uint8_t* channel3Data);
     111             :   static void DoPremultiplicationCalculation_SSE2(const IntSize& aSize,
     112             :                                         uint8_t* aTargetData, int32_t aTargetStride,
     113             :                                         uint8_t* aSourceData, int32_t aSourceStride);
     114             :   static void DoUnpremultiplicationCalculation_SSE2(const IntSize& aSize,
     115             :                                                uint8_t* aTargetData, int32_t aTargetStride,
     116             :                                                uint8_t* aSourceData, int32_t aSourceStride);
     117             :   static already_AddRefed<DataSourceSurface>
     118             :     RenderTurbulence_SSE2(const IntSize &aSize, const Point &aOffset, const Size &aBaseFrequency,
     119             :                           int32_t aSeed, int aNumOctaves, TurbulenceType aType, bool aStitch, const Rect &aTileRect);
     120             :   static already_AddRefed<DataSourceSurface>
     121             :     ApplyArithmeticCombine_SSE2(DataSourceSurface* aInput1, DataSourceSurface* aInput2, Float aK1, Float aK2, Float aK3, Float aK4);
     122             : #endif
     123             : };
     124             : 
     125             : // Constant-time max and min functions for unsigned arguments
     126             : static inline unsigned
     127           0 : umax(unsigned a, unsigned b)
     128             : {
     129           0 :   return a - ((a - b) & -(a < b));
     130             : }
     131             : 
     132             : static inline unsigned
     133           0 : umin(unsigned a, unsigned b)
     134             : {
     135           0 :   return a - ((a - b) & -(a > b));
     136             : }
     137             : 
     138             : } // namespace gfx
     139             : } // namespace mozilla
     140             : 
     141             : #endif // _MOZILLA_GFX_FILTERPROCESSING_H_

Generated by: LCOV version 1.13