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

          Line data    Source code
       1             : /*
       2             :  * Copyright 2015 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 GrColorProcessor_DEFINED
       9             : #define GrColorProcessor_DEFINED
      10             : 
      11             : #include "GrFragmentProcessor.h"
      12             : 
      13             : /**
      14             :  * This is a simple GrFragmentProcessor that outputs a constant color. It may do one of the
      15             :  * following with its input color: ignore it, or multiply it by the constant color, multiply its
      16             :  * alpha by the constant color and ignore the input color's r, g, and b.
      17             :  */
      18           0 : class GrConstColorProcessor : public GrFragmentProcessor {
      19             : public:
      20             :     enum InputMode {
      21             :         kIgnore_InputMode,
      22             :         kModulateRGBA_InputMode,
      23             :         kModulateA_InputMode,
      24             : 
      25             :         kLastInputMode = kModulateA_InputMode
      26             :     };
      27             :     static const int kInputModeCnt = kLastInputMode + 1;
      28             : 
      29           0 :     static sk_sp<GrFragmentProcessor> Make(GrColor4f color, InputMode mode) {
      30           0 :         return sk_sp<GrFragmentProcessor>(new GrConstColorProcessor(color, mode));
      31             :     }
      32             : 
      33           0 :     const char* name() const override { return "Color"; }
      34             : 
      35           0 :     SkString dumpInfo() const override {
      36           0 :         SkString str;
      37           0 :         str.appendf("Color: 0x%08x", fColor.toGrColor());
      38           0 :         return str;
      39             :     }
      40             : 
      41           0 :     GrColor4f color() const { return fColor; }
      42             : 
      43           0 :     InputMode inputMode() const { return fMode; }
      44             : 
      45             : private:
      46           0 :     static OptimizationFlags OptFlags(GrColor4f color, InputMode mode) {
      47           0 :         OptimizationFlags flags = kConstantOutputForConstantInput_OptimizationFlag;
      48           0 :         if (mode != kIgnore_InputMode) {
      49           0 :             flags |= kCompatibleWithCoverageAsAlpha_OptimizationFlag;
      50             :         }
      51           0 :         if (color.isOpaque()) {
      52           0 :             flags |= kPreservesOpaqueInput_OptimizationFlag;
      53             :         }
      54           0 :         return flags;
      55             :     }
      56             : 
      57           0 :     GrConstColorProcessor(GrColor4f color, InputMode mode)
      58           0 :             : INHERITED(OptFlags(color, mode)), fColor(color), fMode(mode) {
      59           0 :         this->initClassID<GrConstColorProcessor>();
      60           0 :     }
      61             : 
      62             :     GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
      63             : 
      64             :     void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
      65             : 
      66             :     bool onIsEqual(const GrFragmentProcessor&) const override;
      67             : 
      68             :     GrColor4f constantOutputForConstantInput(GrColor4f input) const override;
      69             : 
      70             :     GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
      71             : 
      72             :     GrColor4f   fColor;
      73             :     InputMode   fMode;
      74             : 
      75             :     typedef GrFragmentProcessor INHERITED;
      76             : };
      77             : 
      78             : #endif

Generated by: LCOV version 1.13