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

          Line data    Source code
       1             : /*
       2             :  * Copyright 2013 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 GrPrimitiveProcessor_DEFINED
       9             : #define GrPrimitiveProcessor_DEFINED
      10             : 
      11             : #include "GrColor.h"
      12             : #include "GrProcessor.h"
      13             : #include "GrShaderVar.h"
      14             : 
      15             : /*
      16             :  * The GrPrimitiveProcessor represents some kind of geometric primitive.  This includes the shape
      17             :  * of the primitive and the inherent color of the primitive.  The GrPrimitiveProcessor is
      18             :  * responsible for providing a color and coverage input into the Ganesh rendering pipeline.  Through
      19             :  * optimization, Ganesh may decide a different color, no color, and / or no coverage are required
      20             :  * from the GrPrimitiveProcessor, so the GrPrimitiveProcessor must be able to support this
      21             :  * functionality.
      22             :  *
      23             :  * There are two feedback loops between the GrFragmentProcessors, the GrXferProcessor, and the
      24             :  * GrPrimitiveProcessor. These loops run on the CPU and to determine known properties of the final
      25             :  * color and coverage inputs to the GrXferProcessor in order to perform optimizations that preserve
      26             :  * correctness. The GrDrawOp seeds these loops with initial color and coverage, in its
      27             :  * getProcessorAnalysisInputs implementation. These seed values are processed by the
      28             :  * subsequent
      29             :  * stages of the rendering pipeline and the output is then fed back into the GrDrawOp in
      30             :  * the applyPipelineOptimizations call, where the op can use the information to inform decisions
      31             :  * about GrPrimitiveProcessor creation.
      32             :  */
      33             : 
      34             : class GrGLSLPrimitiveProcessor;
      35             : 
      36             : /*
      37             :  * GrPrimitiveProcessor defines an interface which all subclasses must implement.  All
      38             :  * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh color / coverage
      39             :  * pipelines, and they must provide some notion of equality
      40             :  */
      41           0 : class GrPrimitiveProcessor : public GrResourceIOProcessor, public GrProgramElement {
      42             : public:
      43             :     // Only the GrGeometryProcessor subclass actually has a geo shader or vertex attributes, but
      44             :     // we put these calls on the base class to prevent having to cast
      45             :     virtual bool willUseGeoShader() const = 0;
      46             : 
      47             :     struct Attribute {
      48             :         Attribute()
      49             :             : fName(nullptr)
      50             :             , fType(kFloat_GrVertexAttribType)
      51             :             , fOffset(0) {}
      52           0 :         Attribute(const char* name, GrVertexAttribType type, GrSLPrecision precision)
      53           0 :             : fName(name)
      54             :             , fType(type)
      55           0 :             , fOffset(SkAlign4(GrVertexAttribTypeSize(type)))
      56           0 :             , fPrecision(precision) {}
      57             :         const char* fName;
      58             :         GrVertexAttribType fType;
      59             :         size_t fOffset;
      60             :         GrSLPrecision fPrecision;
      61             :     };
      62             : 
      63           0 :     int numAttribs() const { return fAttribs.count(); }
      64           0 :     const Attribute& getAttrib(int index) const { return fAttribs[index]; }
      65             : 
      66             :     // Returns the vertex stride of the GP.  A common use case is to request geometry from a
      67             :     // GrOpList based off of the stride, and to populate this memory using an implicit array of
      68             :     // structs.  In this case, it is best to assert the vertexstride == sizeof(VertexStruct).
      69           0 :     size_t getVertexStride() const { return fVertexStride; }
      70             : 
      71             :     /**
      72             :      * Computes a transformKey from an array of coord transforms. Will only look at the first
      73             :      * <numCoords> transforms in the array.
      74             :      *
      75             :      * TODO: A better name for this function  would be "compute" instead of "get".
      76             :      */
      77             :     uint32_t getTransformKey(const SkTArray<const GrCoordTransform*, true>& coords,
      78             :                              int numCoords) const;
      79             : 
      80             :     /**
      81             :      * Sets a unique key on the GrProcessorKeyBuilder that is directly associated with this geometry
      82             :      * processor's GL backend implementation.
      83             :      *
      84             :      * TODO: A better name for this function  would be "compute" instead of "get".
      85             :      */
      86             :     virtual void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const = 0;
      87             : 
      88             : 
      89             :     /** Returns a new instance of the appropriate *GL* implementation class
      90             :         for the given GrProcessor; caller is responsible for deleting
      91             :         the object. */
      92             :     virtual GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const = 0;
      93             : 
      94           0 :     virtual bool isPathRendering() const { return false; }
      95             : 
      96             :     /**
      97             :      * If non-null, overrides the dest color returned by GrGLSLFragmentShaderBuilder::dstColor().
      98             :      */
      99           0 :     virtual const char* getDestColorOverride() const { return nullptr; }
     100             : 
     101           0 :     virtual float getSampleShading() const {
     102           0 :         return 0.0;
     103             :     }
     104             : 
     105             :     /* Sub-class should override and return true if this primitive processor implements the distance
     106             :      * vector field, a field of vectors to the nearest point in the edge of the shape.  */
     107           0 :     virtual bool implementsDistanceVector() const { return false; }
     108             : 
     109             : protected:
     110           0 :     GrPrimitiveProcessor() : fVertexStride(0) {}
     111             : 
     112             :     enum { kPreallocAttribCnt = 8 };
     113             :     SkSTArray<kPreallocAttribCnt, Attribute> fAttribs;
     114             :     size_t fVertexStride;
     115             : 
     116             : private:
     117           0 :     void addPendingIOs() const override { GrResourceIOProcessor::addPendingIOs(); }
     118           0 :     void removeRefs() const override { GrResourceIOProcessor::removeRefs(); }
     119           0 :     void pendingIOComplete() const override { GrResourceIOProcessor::pendingIOComplete(); }
     120           0 :     void notifyRefCntIsZero() const final {}
     121             :     virtual bool hasExplicitLocalCoords() const = 0;
     122             : 
     123             :     typedef GrProcessor INHERITED;
     124             : };
     125             : 
     126             : #endif

Generated by: LCOV version 1.13