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

Unified Diff: include/gpu/GrProcessor.h

Issue 643743003: Create helper functions to use in computeInvariantOutput calls (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixes 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 | « no previous file | src/core/SkXfermode.cpp » ('j') | src/effects/SkBlurMaskFilter.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrProcessor.h
diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h
index c1755a895472a9973315de9bc575fc90fb928eca..c8ea02084a1026b45ac8a8aa48d477a559294221 100644
--- a/include/gpu/GrProcessor.h
+++ b/include/gpu/GrProcessor.h
@@ -44,6 +44,45 @@ public:
InvariantOutput() : fColor(0), fValidFlags(0), fIsSingleComponent(false) {}
+ void mulByUnknownOpaqueColor() {
+ if (this->isOpaque()) {
+ fValidFlags = kA_GrColorComponentFlag;
+ fIsSingleComponent = false;
+ } else {
+ // Since the current state is not opaque we no longer care if the color being
+ // multiplied is opaque.
+ this->mulByUnknownColor();
+ }
+ }
+
+ void mulByUnknownColor() {
+ if (this->hasZeroAlpha()) {
+ this->transparentBlackOutput();
+ } else {
+ this->unknownOutput();
+ }
+ }
+
+ void mulByUnknownAlpha() {
+ if (this->hasZeroAlpha()) {
+ this->transparentBlackOutput();
+ } else {
+ // We don't need to change fIsSingleComponent in this case
+ fValidFlags = 0;
+ }
+ }
+
+ void transparentBlackOutput() {
bsalomon 2014/10/10 19:48:16 setToTransparentBlack() ?
egdaniel 2014/10/13 16:44:57 Done.
+ fValidFlags = kRGBA_GrColorComponentFlags;
+ fColor = 0;
+ fIsSingleComponent = true;
+ }
+
+ void unknownOutput() {
bsalomon 2014/10/10 19:48:16 setUnknownOutput? (just trying to avoid confusion
egdaniel 2014/10/13 16:44:57 Done.
+ fValidFlags = 0;
+ fIsSingleComponent = false;
+ }
+
bool isOpaque() const {
return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(fColor));
}
@@ -59,8 +98,11 @@ public:
SkDEBUGCODE(void validate() const;)
private:
- SkDEBUGCODE(bool colorComponentsAllEqual() const;)
+ bool hasZeroAlpha() const {
+ return ((fValidFlags & kA_GrColorComponentFlag) && 0 == GrColorUnpackA(fColor));
+ }
+ SkDEBUGCODE(bool colorComponentsAllEqual() const;)
/**
* If alpha is valid, check that any valid R,G,B values are <= A
*/
« no previous file with comments | « no previous file | src/core/SkXfermode.cpp » ('j') | src/effects/SkBlurMaskFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698