Chromium Code Reviews| Index: include/gpu/GrProcessor.h |
| diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h |
| index 7053872bbe4a75d6e0039c0c646daf00af8043a9..d975b4b8517dc46b486f56ea142d452ceb9fb3e0 100644 |
| --- a/include/gpu/GrProcessor.h |
| +++ b/include/gpu/GrProcessor.h |
| @@ -37,14 +37,44 @@ public: |
| virtual ~GrProcessor(); |
| + struct InvarientOutput{ |
|
bsalomon
2014/09/30 00:41:01
"Invariant" (gulp)
There might be some more usefu
egdaniel
2014/10/02 14:58:33
Fixed speeling
|
| + GrColor color; |
| + uint32_t validFlags; |
|
bsalomon
2014/09/30 00:41:01
fColor, fValidFlags, fIsSingleComponent
egdaniel
2014/10/02 14:58:33
Done.
|
| + bool isSingleComponent; |
| + |
| + bool hasOpaqueAlpha() const { |
|
bsalomon
2014/09/30 00:41:01
isOpaque?
egdaniel
2014/10/02 14:58:33
Done.
|
| + return ((validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(color)); |
| + } |
| + |
| + bool hasOpaqueColor() const { |
| + return (validFlags == kRGBA_GrColorComponentFlags && |
|
bsalomon
2014/09/30 00:41:01
isSolidWhite?
egdaniel
2014/10/02 14:58:33
Done.
|
| + 0xFFFFFFFF == GrColorUnpackA(color)); |
| + } |
| + |
| + /** |
| + * If isSingleComponent is true, then the flag values for r, g, b, and a must all be the |
| + * same. If the flags are all set then all color components must be equal. |
| + */ |
| + SkDEBUGCODE(void validate() const;) |
| + |
| + private: |
| + SkDEBUGCODE(bool colorComponentsAllEqual() const;) |
| + }; |
| + |
| /** |
| - * This function is used to perform optimizations. When called the color and validFlags params |
| + * This function is used to perform optimizations. When called the invarientOuput param |
| * indicate whether the input components to this effect in the FS will have known values. |
| - * validFlags is a bitfield of GrColorComponentFlags. The function updates both params to |
| - * indicate known values of its output. A component of the color param only has meaning if the |
| - * corresponding bit in validFlags is set. |
| + * In invarientOutput the validFlags member is a bitfield of GrColorComponentFlags. The |
| + * isSingleComponent member indicates whether the input will be 1 or 4 bytes. The function |
| + * updates the members of invarientOutput to indicate known values of its output. A component |
| + * of the color member only has meaning if the corresponding bit in validFlags is set. |
| */ |
| - virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const = 0; |
| + void computeInvarientOutput(InvarientOutput* invarientOutput) const { |
|
bsalomon
2014/09/30 00:41:01
Because the param is inout it feels weird to call
egdaniel
2014/10/02 14:58:33
Done.
|
| + this->onComputeInvarientOutput(invarientOutput); |
| +#ifdef SK_DEBUG |
| + invarientOutput->validate(); |
| +#endif |
| + } |
| /** This object, besides creating back-end-specific helper objects, is used for run-time-type- |
| identification. The factory should be an instance of templated class, |
| @@ -158,6 +188,10 @@ private: |
| getFactory()).*/ |
| virtual bool onIsEqual(const GrProcessor& other) const = 0; |
| + /** |
| + * Subclass implements this to support getConstantColorComponents(...). |
| + */ |
| + virtual void onComputeInvarientOutput(InvarientOutput* invarientOutput) const = 0; |
| friend class GrGeometryProcessor; // to set fRequiresVertexShader and build fVertexAttribTypes. |
| SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |