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

Unified Diff: src/gpu/GrProcessor.cpp

Issue 608253002: Add isSingleComponent bool to getConstantColorComponent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix isSolidWhite Created 6 years, 2 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/gpu/GrPaint.cpp ('k') | src/gpu/effects/GrBezierEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrProcessor.cpp
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 45298b522d3ef9e1bf367c19ea8989a8b02f900e..26e00530be848491e87d9ecb82035f29dd4c680f 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -88,4 +88,46 @@ void GrProcessor::assertEquality(const GrProcessor& other) const {
SkASSERT(this->textureAccess(i) == other.textureAccess(i));
}
}
+
+void GrProcessor::InvariantOutput::validate() const {
+ if (fIsSingleComponent) {
+ SkASSERT(0 == fValidFlags || kRGBA_GrColorComponentFlags == fValidFlags);
+ if (kRGBA_GrColorComponentFlags == fValidFlags) {
+ SkASSERT(this->colorComponentsAllEqual());
+ }
+ }
+
+ SkASSERT(this->validPreMulColor());
+}
+
+bool GrProcessor::InvariantOutput::colorComponentsAllEqual() const {
+ unsigned colorA = GrColorUnpackA(fColor);
+ return(GrColorUnpackR(fColor) == colorA &&
+ GrColorUnpackG(fColor) == colorA &&
+ GrColorUnpackB(fColor) == colorA);
+}
+
+bool GrProcessor::InvariantOutput::validPreMulColor() const {
+ if (kA_GrColorComponentFlag & fValidFlags) {
+ float c[4];
+ GrColorToRGBAFloat(fColor, c);
+ if (kR_GrColorComponentFlag & fValidFlags) {
+ if (c[0] > c[3]) {
+ return false;
+ }
+ }
+ if (kG_GrColorComponentFlag & fValidFlags) {
+ if (c[1] > c[3]) {
+ return false;
+ }
+ }
+ if (kB_GrColorComponentFlag & fValidFlags) {
+ if (c[2] > c[3]) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
#endif
+
« no previous file with comments | « src/gpu/GrPaint.cpp ('k') | src/gpu/effects/GrBezierEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698