aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-10-15 13:49:02 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-15 13:49:02 -0700
commit9e4d6d180fcfbbe2ea242196cc0affd45b7ed7ae (patch)
treed017bec2b2fa112755f361fefdd0bdf6ddf823d0 /include
parentebd90ee211bb8740ff0e600632a7220ae82146a7 (diff)
Move willUseInputColor check to computeInvariantOutput
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrPaint.h6
-rw-r--r--include/gpu/GrProcessor.h45
2 files changed, 36 insertions, 15 deletions
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index ff37fcfee8..c5563f00fa 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -89,9 +89,6 @@ public:
*/
const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* fp) {
SkASSERT(fp);
- if (!fp->willUseInputColor()) {
- fColorStages.reset();
- }
SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (fp));
return fp;
}
@@ -101,9 +98,6 @@ public:
*/
const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* fp) {
SkASSERT(fp);
- if (!fp->willUseInputColor()) {
- fCoverageStages.reset();
- }
SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (fp));
return fp;
}
diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h
index c860b32c1b..ee1266359f 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();