aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrProcessor.cpp
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-10-02 09:57:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-02 09:57:48 -0700
commit3b8af078281a5a20f951b9fd84f38d92b8f6217b (patch)
tree92c250b9011e2ee5e0e1a2517e7c7ee550853ddc /src/gpu/GrProcessor.cpp
parent8f8c25eabb97da8eda488895f04f2d12cb5ea4cf (diff)
Add isSingleComponent bool to getConstantColorComponent
Initial step to allowing effects to use/output 1 or 4 color/coverage components. This cl doesn't change any current logic and all effects still assume they are working with 4 components. BUG=skia: Review URL: https://codereview.chromium.org/608253002
Diffstat (limited to 'src/gpu/GrProcessor.cpp')
-rw-r--r--src/gpu/GrProcessor.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 45298b522d..26e00530be 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
+