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

Unified Diff: src/core/SkColorSpace_Base.h

Issue 2194903002: Fix various SkColorSpace bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use switch statement in nonstandard struct Created 4 years, 5 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 | « src/core/SkColorSpaceXform.cpp ('k') | tests/ColorSpaceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorSpace_Base.h
diff --git a/src/core/SkColorSpace_Base.h b/src/core/SkColorSpace_Base.h
index 6cfbb8c837bf4b3a398e59523d551cb795f3b8bb..f4507732b5eaf8b623b270441e0d859bce8d75cc 100644
--- a/src/core/SkColorSpace_Base.h
+++ b/src/core/SkColorSpace_Base.h
@@ -70,38 +70,57 @@ struct SkGammas : SkRefCnt {
};
bool isNamed(int i) const {
- SkASSERT(0 <= i && i < 3);
- return (&fRedType)[i] == Type::kNamed_Type;
+ return Type::kNamed_Type == this->type(i);
}
bool isValue(int i) const {
- SkASSERT(0 <= i && i < 3);
- return (&fRedType)[i] == Type::kValue_Type;
+ return Type::kValue_Type == this->type(i);
}
bool isTable(int i) const {
- SkASSERT(0 <= i && i < 3);
- return (&fRedType)[i] == Type::kTable_Type;
+ return Type::kTable_Type == this->type(i);
}
bool isParametric(int i) const {
- SkASSERT(0 <= i && i < 3);
- return (&fRedType)[i] == Type::kParam_Type;
+ return Type::kParam_Type == this->type(i);
}
const Data& data(int i) const {
- SkASSERT(0 <= i && i < 3);
- return (&fRedData)[i];
+ switch (i) {
+ case 0:
+ return fRedData;
+ case 1:
+ return fGreenData;
+ case 2:
+ return fBlueData;
+ default:
+ SkASSERT(false);
+ return fRedData;
+ }
}
const float* table(int i) const {
SkASSERT(isTable(i));
- return (&fRedData)[i].fTable.table(this);
+ return this->data(i).fTable.table(this);
}
const Params& params(int i) const {
SkASSERT(isParametric(i));
- return (&fRedData)[i].params(this);
+ return this->data(i).params(this);
+ }
+
+ Type type(int i) const {
+ switch (i) {
+ case 0:
+ return fRedType;
+ case 1:
+ return fGreenType;
+ case 2:
+ return fBlueType;
+ default:
+ SkASSERT(false);
+ return fRedType;
+ }
}
SkGammas()
« no previous file with comments | « src/core/SkColorSpaceXform.cpp ('k') | tests/ColorSpaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698