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

Unified Diff: include/gpu/GrProcessor.h

Issue 656503002: Move willUseInputColor check to computeInvariantOutput (Closed) Base URL: https://skia.googlesource.com/skia.git@addMultFlag
Patch Set: Rebase2 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 | « include/gpu/GrPaint.h ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »
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 c860b32c1bdc0f235a81cb3988342f886dd2b7c1..ee1266359f3d46441deb50bec2e4ef3e5ef64a13 100644
--- a/include/gpu/GrProcessor.h
+++ b/include/gpu/GrProcessor.h
@@ -13,6 +13,7 @@
#include "GrProcessorUnitTest.h"
#include "GrProgramElement.h"
#include "GrTextureAccess.h"
+#include "SkMath.h"
class GrContext;
class GrCoordTransform;
@@ -32,7 +33,12 @@ public:
struct InvariantOutput{
InvariantOutput() : fColor(0), fValidFlags(0), fIsSingleComponent(false),
- fNonMulStageFound(false) {}
+ fNonMulStageFound(false), fWillUseInputColor(true) {}
+
+ enum ReadInput {
+ kWill_ReadInput,
+ kWillNot_ReadInput,
+ };
void mulByUnknownOpaqueColor() {
if (this->isOpaque()) {
@@ -62,26 +68,44 @@ public:
}
}
- void invalidateComponents(uint8_t invalidateFlags) {
- fValidFlags &= ~invalidateFlags;
- fIsSingleComponent = false;
+ void mulByKnownAlpha(uint8_t alpha) {
+ if (this->hasZeroAlpha() || 0 == alpha) {
+ this->internalSetToTransparentBlack();
+ } else {
+ if (alpha != 255) {
+ // Multiply color by alpha
+ fColor = GrColorPackRGBA(SkMulDiv255Round(GrColorUnpackR(fColor), alpha),
+ SkMulDiv255Round(GrColorUnpackG(fColor), alpha),
+ SkMulDiv255Round(GrColorUnpackB(fColor), alpha),
+ SkMulDiv255Round(GrColorUnpackA(fColor), alpha));
+ }
+ }
}
- void setToTransparentBlack() {
- this->internalSetToTransparentBlack();
- fNonMulStageFound = true;
+ void invalidateComponents(uint8_t invalidateFlags, ReadInput readsInput) {
+ fValidFlags &= ~invalidateFlags;
+ fIsSingleComponent = false;
+ if (kWillNot_ReadInput == readsInput) {
+ fWillUseInputColor = false;
+ }
}
- void setToOther(uint8_t validFlags, GrColor color) {
+ void setToOther(uint8_t validFlags, GrColor color, ReadInput readsInput) {
fValidFlags = validFlags;
fColor = color;
fIsSingleComponent = false;
fNonMulStageFound = true;
+ if (kWillNot_ReadInput == readsInput) {
+ fWillUseInputColor = false;
+ }
}
- void setToUnknown() {
+ void setToUnknown(ReadInput readsInput) {
this->internalSetToUnknown();
fNonMulStageFound= true;
+ if (kWillNot_ReadInput == readsInput) {
+ fWillUseInputColor = false;
+ }
}
bool isOpaque() const {
@@ -129,11 +153,13 @@ public:
friend class GrDrawState;
friend class GrOptDrawState;
friend class GrPaint;
+ friend class GrProcessor;
GrColor fColor;
uint32_t fValidFlags;
bool fIsSingleComponent;
bool fNonMulStageFound;
+ bool fWillUseInputColor;
};
/**
@@ -145,6 +171,7 @@ public:
* meaning if the corresponding bit in validFlags is set.
*/
void computeInvariantOutput(InvariantOutput* inout) const {
+ inout->fWillUseInputColor = true;
this->onComputeInvariantOutput(inout);
#ifdef SK_DEBUG
inout->validate();
« no previous file with comments | « include/gpu/GrPaint.h ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698