| Index: include/gpu/GrPaint.h
|
| diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
|
| index e11ccc7ae92d5d472f9c50c99d6c1db970d046f1..f8aaa0e04c915ba3b68c2db3b6f2b2686695394c 100644
|
| --- a/include/gpu/GrPaint.h
|
| +++ b/include/gpu/GrPaint.h
|
| @@ -11,7 +11,6 @@
|
| #define GrPaint_DEFINED
|
|
|
| #include "GrColor.h"
|
| -#include "GrStagedProcessor.h"
|
| #include "GrProcessorDataManager.h"
|
| #include "GrXferProcessor.h"
|
| #include "effects/GrPorterDuffXferProcessor.h"
|
| @@ -44,7 +43,7 @@ public:
|
|
|
| GrPaint(const GrPaint& paint) { *this = paint; }
|
|
|
| - ~GrPaint() {}
|
| + ~GrPaint() { this->resetFragmentProcessors(); }
|
|
|
| /**
|
| * The initial color of the drawn primitive. Defaults to solid white.
|
| @@ -78,18 +77,18 @@ public:
|
| /**
|
| * Appends an additional color processor to the color computation.
|
| */
|
| - const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) {
|
| + const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* fp) {
|
| SkASSERT(fp);
|
| - SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (fp));
|
| + fColorFragmentProcessors.push_back(SkRef(fp));
|
| return fp;
|
| }
|
|
|
| /**
|
| * Appends an additional coverage processor to the coverage computation.
|
| */
|
| - const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* fp) {
|
| + const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* fp) {
|
| SkASSERT(fp);
|
| - SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (fp));
|
| + fCoverageFragmentProcessors.push_back(SkRef(fp));
|
| return fp;
|
| }
|
|
|
| @@ -102,9 +101,10 @@ public:
|
| void addColorTextureProcessor(GrTexture*, const SkMatrix&, const GrTextureParams&);
|
| void addCoverageTextureProcessor(GrTexture*, const SkMatrix&, const GrTextureParams&);
|
|
|
| - int numColorStages() const { return fColorStages.count(); }
|
| - int numCoverageStages() const { return fCoverageStages.count(); }
|
| - int numTotalStages() const { return this->numColorStages() + this->numCoverageStages(); }
|
| + int numColorFragmentProcessors() const { return fColorFragmentProcessors.count(); }
|
| + int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
|
| + int numTotalFragmentProcessors() const { return this->numColorFragmentProcessors() +
|
| + this->numCoverageFragmentProcessors(); }
|
|
|
| const GrXPFactory* getXPFactory() const {
|
| if (!fXPFactory) {
|
| @@ -113,17 +113,27 @@ public:
|
| return fXPFactory.get();
|
| }
|
|
|
| - const GrFragmentStage& getColorStage(int s) const { return fColorStages[s]; }
|
| - const GrFragmentStage& getCoverageStage(int s) const { return fCoverageStages[s]; }
|
| + const GrFragmentProcessor* getColorFragmentProcessor(int i) const {
|
| + return fColorFragmentProcessors[i];
|
| + }
|
| + const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
|
| + return fCoverageFragmentProcessors[i];
|
| + }
|
|
|
| GrPaint& operator=(const GrPaint& paint) {
|
| fAntiAlias = paint.fAntiAlias;
|
| fDither = paint.fDither;
|
|
|
| fColor = paint.fColor;
|
| -
|
| - fColorStages = paint.fColorStages;
|
| - fCoverageStages = paint.fCoverageStages;
|
| + this->resetFragmentProcessors();
|
| + fColorFragmentProcessors = paint.fColorFragmentProcessors;
|
| + fCoverageFragmentProcessors = paint.fCoverageFragmentProcessors;
|
| + for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
|
| + fColorFragmentProcessors[i]->ref();
|
| + }
|
| + for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
|
| + fCoverageFragmentProcessors[i]->ref();
|
| + }
|
|
|
| fXPFactory.reset(SkRef(paint.getXPFactory()));
|
| fProcDataManager.reset(new GrProcessorDataManager(*paint.processorDataManager()));
|
| @@ -144,15 +154,26 @@ public:
|
| const GrProcessorDataManager* processorDataManager() const { return fProcDataManager.get(); }
|
|
|
| private:
|
| - mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
|
| - SkSTArray<4, GrFragmentStage> fColorStages;
|
| - SkSTArray<2, GrFragmentStage> fCoverageStages;
|
| + void resetFragmentProcessors() {
|
| + for (int i = 0; i < fColorFragmentProcessors.count(); ++i) {
|
| + fColorFragmentProcessors[i]->unref();
|
| + }
|
| + for (int i = 0; i < fCoverageFragmentProcessors.count(); ++i) {
|
| + fCoverageFragmentProcessors[i]->unref();
|
| + }
|
| + fColorFragmentProcessors.reset();
|
| + fCoverageFragmentProcessors.reset();
|
| + }
|
| +
|
| + mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
|
| + SkSTArray<4, const GrFragmentProcessor*, true> fColorFragmentProcessors;
|
| + SkSTArray<2, const GrFragmentProcessor*, true> fCoverageFragmentProcessors;
|
|
|
| - bool fAntiAlias;
|
| - bool fDither;
|
| + bool fAntiAlias;
|
| + bool fDither;
|
|
|
| - GrColor fColor;
|
| - SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
|
| + GrColor fColor;
|
| + SkAutoTUnref<GrProcessorDataManager> fProcDataManager;
|
| };
|
|
|
| #endif
|
|
|