LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/effects/gradients - Sk4fGradientBase.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 7 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2016 Google Inc.
       3             :  *
       4             :  * Use of this source code is governed by a BSD-style license that can be
       5             :  * found in the LICENSE file.
       6             :  */
       7             : 
       8             : #ifndef Sk4fGradientBase_DEFINED
       9             : #define Sk4fGradientBase_DEFINED
      10             : 
      11             : #include "Sk4fGradientPriv.h"
      12             : #include "SkColor.h"
      13             : #include "SkGradientShaderPriv.h"
      14             : #include "SkMatrix.h"
      15             : #include "SkNx.h"
      16             : #include "SkPM4f.h"
      17             : #include "SkShader.h"
      18             : #include "SkTArray.h"
      19             : 
      20             : struct Sk4fGradientInterval {
      21             :     Sk4fGradientInterval(const Sk4f& c0, SkScalar t0,
      22             :                          const Sk4f& c1, SkScalar t1);
      23             : 
      24           0 :     bool contains(SkScalar t) const {
      25             :         // True if t is in [p0,p1].  Note: this helper assumes a
      26             :         // natural/increasing interval - so it's not usable in Sk4fLinearGradient.
      27           0 :         SkASSERT(fT0 < fT1);
      28           0 :         return t >= fT0 && t <= fT1;
      29             :     }
      30             : 
      31             :     // Color bias and color gradient, such that for a t in this interval
      32             :     //
      33             :     //   C = fCb + t * fCg;
      34             :     SkPM4f   fCb, fCg;
      35             :     SkScalar fT0, fT1;
      36             :     bool     fZeroRamp;
      37             : };
      38             : 
      39           0 : class Sk4fGradientIntervalBuffer {
      40             : public:
      41             :     void init(const SkColor colors[], const SkScalar pos[], int count,
      42             :               SkShader::TileMode tileMode, bool premulColors, SkScalar alpha, bool reverse);
      43             : 
      44             :     const Sk4fGradientInterval* find(SkScalar t) const;
      45             :     const Sk4fGradientInterval* findNext(SkScalar t, const Sk4fGradientInterval* prev,
      46             :                                          bool increasing) const;
      47             : 
      48             :     using BufferType = SkSTArray<8, Sk4fGradientInterval, true>;
      49             : 
      50           0 :     const BufferType* operator->() const { return &fIntervals; }
      51             : 
      52             : private:
      53             :     BufferType fIntervals;
      54             : };
      55             : 
      56             : class SkGradientShaderBase::
      57           0 : GradientShaderBase4fContext : public SkShader::Context {
      58             : public:
      59             :     GradientShaderBase4fContext(const SkGradientShaderBase&,
      60             :                                 const ContextRec&);
      61             : 
      62           0 :     uint32_t getFlags() const override { return fFlags; }
      63             : 
      64             :     void shadeSpan(int x, int y, SkPMColor dst[], int count) override;
      65             :     void shadeSpan4f(int x, int y, SkPM4f dst[], int count) override;
      66             : 
      67             :     bool isValid() const;
      68             : 
      69             : protected:
      70             :     virtual void mapTs(int x, int y, SkScalar ts[], int count) const = 0;
      71             : 
      72             :     Sk4fGradientIntervalBuffer fIntervals;
      73             :     SkMatrix                   fDstToPos;
      74             :     SkMatrix::MapXYProc        fDstToPosProc;
      75             :     uint8_t                    fDstToPosClass;
      76             :     uint8_t                    fFlags;
      77             :     bool                       fDither;
      78             :     bool                       fColorsArePremul;
      79             : 
      80             : private:
      81             :     using INHERITED = SkShader::Context;
      82             : 
      83             :     void addMirrorIntervals(const SkGradientShaderBase&,
      84             :                             const Sk4f& componentScale, bool reverse);
      85             : 
      86             :     template<DstType, ApplyPremul, SkShader::TileMode tileMode>
      87             :     class TSampler;
      88             : 
      89             :     template <DstType dstType, ApplyPremul premul>
      90             :     void shadePremulSpan(int x, int y, typename DstTraits<dstType, premul>::Type[],
      91             :                          int count) const;
      92             : 
      93             :     template <DstType dstType, ApplyPremul premul, SkShader::TileMode tileMode>
      94             :     void shadeSpanInternal(int x, int y, typename DstTraits<dstType, premul>::Type[],
      95             :                            int count) const;
      96             : };
      97             : 
      98             : #endif // Sk4fGradientBase_DEFINED

Generated by: LCOV version 1.13