Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: include/gpu/GrPaint.h

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/GrFragmentProcessor.h ('k') | include/gpu/GrProcessorUnitTest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrPaint.h
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 7de559ca4c0b6cbe5dbdb986975c0d8307a8ae36..af408488d7b8d003270f67b1f9edeaa29ead164c 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -15,6 +15,7 @@
#include "effects/GrPorterDuffXferProcessor.h"
#include "GrFragmentProcessor.h"
+#include "SkRefCnt.h"
#include "SkRegion.h"
#include "SkXfermode.h"
@@ -42,7 +43,7 @@ public:
GrPaint(const GrPaint& paint) { *this = paint; }
- ~GrPaint() { this->resetFragmentProcessors(); }
+ ~GrPaint() { }
/**
* The initial color of the drawn primitive. Defaults to solid white.
@@ -79,13 +80,12 @@ public:
setAllowSRGBInputs(gammaCorrect);
}
- const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) {
- fXPFactory.reset(SkSafeRef(xpFactory));
- return xpFactory;
+ void setXPFactory(sk_sp<GrXPFactory> xpFactory) {
+ fXPFactory = std::move(xpFactory);
}
void setPorterDuffXPFactory(SkXfermode::Mode mode) {
- fXPFactory.reset(GrPorterDuffXPFactory::Create(mode));
+ fXPFactory = GrPorterDuffXPFactory::Make(mode);
}
void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage = false);
@@ -93,19 +93,17 @@ public:
/**
* Appends an additional color processor to the color computation.
*/
- const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcessor* fp) {
+ void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> fp) {
SkASSERT(fp);
- fColorFragmentProcessors.push_back(SkRef(fp));
- return fp;
+ fColorFragmentProcessors.push_back(std::move(fp));
}
/**
* Appends an additional coverage processor to the coverage computation.
*/
- const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProcessor* fp) {
+ void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> fp) {
SkASSERT(fp);
- fCoverageFragmentProcessors.push_back(SkRef(fp));
- return fp;
+ fCoverageFragmentProcessors.push_back(std::move(fp));
}
/**
@@ -122,15 +120,15 @@ public:
int numTotalFragmentProcessors() const { return this->numColorFragmentProcessors() +
this->numCoverageFragmentProcessors(); }
- const GrXPFactory* getXPFactory() const {
- return fXPFactory;
+ GrXPFactory* getXPFactory() const {
+ return fXPFactory.get();
}
- const GrFragmentProcessor* getColorFragmentProcessor(int i) const {
- return fColorFragmentProcessors[i];
+ GrFragmentProcessor* getColorFragmentProcessor(int i) const {
+ return fColorFragmentProcessors[i].get();
}
- const GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
- return fCoverageFragmentProcessors[i];
+ GrFragmentProcessor* getCoverageFragmentProcessor(int i) const {
+ return fCoverageFragmentProcessors[i].get();
}
GrPaint& operator=(const GrPaint& paint) {
@@ -139,17 +137,10 @@ public:
fAllowSRGBInputs = paint.fAllowSRGBInputs;
fColor = paint.fColor;
- 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(SkSafeRef(paint.getXPFactory()));
+ fXPFactory = paint.fXPFactory;
return *this;
}
@@ -163,26 +154,15 @@ public:
bool isConstantBlendedColor(GrColor* constantColor) const;
private:
- 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;
+ mutable sk_sp<GrXPFactory> fXPFactory;
+ SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors;
+ SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors;
- bool fAntiAlias;
- bool fDisableOutputConversionToSRGB;
- bool fAllowSRGBInputs;
+ bool fAntiAlias;
+ bool fDisableOutputConversionToSRGB;
+ bool fAllowSRGBInputs;
- GrColor fColor;
+ GrColor fColor;
};
#endif
« no previous file with comments | « include/gpu/GrFragmentProcessor.h ('k') | include/gpu/GrProcessorUnitTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698