diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrCoordTransform.h | 10 | ||||
-rw-r--r-- | include/gpu/GrFragmentProcessor.h | 34 |
2 files changed, 30 insertions, 14 deletions
diff --git a/include/gpu/GrCoordTransform.h b/include/gpu/GrCoordTransform.h index db71ff1158..42598dd8c5 100644 --- a/include/gpu/GrCoordTransform.h +++ b/include/gpu/GrCoordTransform.h @@ -91,12 +91,14 @@ public: return &fMatrix; } - bool operator== (const GrCoordTransform& other) const { - return fSourceCoords == other.fSourceCoords && - fMatrix.cheapEqualTo(other.fMatrix) && - fReverseY == other.fReverseY; + bool operator== (const GrCoordTransform& that) const { + return fSourceCoords == that.fSourceCoords && + fMatrix.cheapEqualTo(that.fMatrix) && + fReverseY == that.fReverseY; } + bool operator!= (const GrCoordTransform& that) const { return !(*this == that); } + GrCoordSet sourceCoords() const { return fSourceCoords; } const SkMatrix& getMatrix() const { return fMatrix; } bool reverseY() const { return fReverseY; } diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h index f872d90835..4642307176 100644 --- a/include/gpu/GrFragmentProcessor.h +++ b/include/gpu/GrFragmentProcessor.h @@ -46,7 +46,7 @@ public: generate the same shader code. To test for identical code generation use the prceossor' keys computed by the GrBackendProcessorFactory. */ bool isEqual(const GrFragmentProcessor& other) const { - if (&this->getFactory() != &other.getFactory()) { + if (&this->getFactory() != &other.getFactory() || !this->hasSameTransforms(other)) { return false; } bool result = this->onIsEqual(other); @@ -61,11 +61,20 @@ public: protected: /** * Fragment Processor subclasses call this from their constructor to register coordinate - * transformations. The processor subclass manages the lifetime of the transformations (this - * function only stores a pointer). The GrCoordTransform is typically a member field of the - * GrProcessor subclass. When the matrix has perspective, the transformed coordinates will have - * 3 components. Otherwise they'll have 2. This must only be called from the constructor because - * GrProcessors are immutable. + * transformations. Coord transforms provide a mechanism for a processor to receive coordinates + * in their FS code. The matrix expresses a transformation from local space. For a given + * fragment the matrix will be applied to the local coordinate that maps to the fragment. + * + * When the transformation has perspective, the transformed coordinates will have + * 3 components. Otherwise they'll have 2. + * + * This must only be called from the constructor because GrProcessors are immutable. The + * processor subclass manages the lifetime of the transformations (this function only stores a + * pointer). The GrCoordTransform is typically a member field of the GrProcessor subclass. + * + * A processor subclass that has multiple methods of construction should always add its coord + * transforms in a consistent order. The non-virtual implementation of isEqual() automatically + * compares transforms and will assume they line up across the two processor instances. */ void addCoordTransform(const GrCoordTransform*); @@ -84,10 +93,15 @@ protected: void setWillNotUseInputColor() { fWillUseInputColor = false; } private: - /** Subclass implements this to support isEqual(). It will only be called if it is known that - the two prceossor are of the same subclass (i.e. they return the same object from - getFactory()).*/ - virtual bool onIsEqual(const GrFragmentProcessor& other) const = 0; + /** + * Subclass implements this to support isEqual(). It will only be called if it is known that + * the two processors are of the same subclass (i.e. they return the same object from + * getFactory()). The processor subclass should not compare its coord transforms as that will + * be performed automatically in the non-virtual isEqual(). + */ + virtual bool onIsEqual(const GrFragmentProcessor&) const = 0; + + bool hasSameTransforms(const GrFragmentProcessor&) const; SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; bool fWillReadDstColor; |