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

Unified Diff: src/gpu/effects/GrPorterDuffXferProcessor.cpp

Issue 814933002: Add an InvariantOutput for the XPF. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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/effects/GrCoverageSetOpXP.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrPorterDuffXferProcessor.cpp
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index a091a48b08e21faf3dc94e524f93163fd0508939..2dd3d539a6061785c624ea340a2169cae98de0ec 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -443,47 +443,20 @@ bool GrPorterDuffXPFactory::canApplyCoverage(const GrProcOptInfo& colorPOI,
return false;
}
-bool GrPorterDuffXPFactory::willBlendWithDst(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI,
- bool colorWriteDisabled) const {
- if (!coveragePOI.isSolidWhite()) {
- return true;
- }
-
- // TODO: once all SkXferEffects are XP's then we will never reads dst here since only XP's
- // will readDst and PD XP's don't read dst.
- if ((!colorWriteDisabled && colorPOI.readsDst()) || coveragePOI.readsDst()) {
- return true;
- }
-
- if (GrBlendCoeffRefsDst(fSrcCoeff)) {
- return true;
- }
-
- bool srcAIsOne = colorPOI.isOpaque();
-
- if (!(kZero_GrBlendCoeff == fDstCoeff ||
- (kISA_GrBlendCoeff == fDstCoeff && srcAIsOne))) {
- return true;
- }
-
- return false;
-}
-
bool GrPorterDuffXPFactory::canTweakAlphaForCoverage() const {
return can_tweak_alpha_for_coverage(fDstCoeff);
}
-bool GrPorterDuffXPFactory::getOpaqueAndKnownColor(const GrProcOptInfo& colorPOI,
- const GrProcOptInfo& coveragePOI,
- GrColor* solidColor,
- uint32_t* solidColorKnownComponents) const {
+void GrPorterDuffXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI,
+ const GrProcOptInfo& coveragePOI,
+ bool colorWriteDisabled,
+ GrXPFactory::InvariantOutput* output) const {
if (!coveragePOI.isSolidWhite()) {
- return false;
+ output->fWillBlendWithDst = true;
+ output->fBlendedColorFlags = 0;
+ return;
}
- SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents));
-
GrBlendCoeff srcCoeff = fSrcCoeff;
GrBlendCoeff dstCoeff = fDstCoeff;
@@ -492,47 +465,62 @@ bool GrPorterDuffXPFactory::getOpaqueAndKnownColor(const GrProcOptInfo& colorPOI
GrSimplifyBlend(&srcCoeff, &dstCoeff, colorPOI.color(), colorPOI.validFlags(),
0, 0, 0);
- bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoeff);
- if (solidColor) {
- if (opaque) {
- switch (srcCoeff) {
- case kZero_GrBlendCoeff:
- *solidColor = 0;
- *solidColorKnownComponents = kRGBA_GrColorComponentFlags;
- break;
+ if (GrBlendCoeffRefsDst(srcCoeff)) {
+ output->fWillBlendWithDst = true;
+ output->fBlendedColorFlags = 0;
+ return;
+ }
- case kOne_GrBlendCoeff:
- *solidColor = colorPOI.color();
- *solidColorKnownComponents = colorPOI.validFlags();
- break;
+ if (kZero_GrBlendCoeff != dstCoeff) {
+ bool srcAIsOne = colorPOI.isOpaque();
+ if (kISA_GrBlendCoeff != dstCoeff || !srcAIsOne) {
+ output->fWillBlendWithDst = true;
+ }
+ output->fBlendedColorFlags = 0;
+ return;
+ }
- // The src coeff should never refer to the src and if it refers to dst then opaque
- // should have been false.
- case kSC_GrBlendCoeff:
- case kISC_GrBlendCoeff:
- case kDC_GrBlendCoeff:
- case kIDC_GrBlendCoeff:
- case kSA_GrBlendCoeff:
- case kISA_GrBlendCoeff:
- case kDA_GrBlendCoeff:
- case kIDA_GrBlendCoeff:
- default:
- SkFAIL("srcCoeff should not refer to src or dst.");
- break;
+ switch (srcCoeff) {
+ case kZero_GrBlendCoeff:
+ output->fBlendedColor = 0;
+ output->fBlendedColorFlags = kRGBA_GrColorComponentFlags;
+ break;
- // TODO: update this once GrPaint actually has a const color.
- case kConstC_GrBlendCoeff:
- case kIConstC_GrBlendCoeff:
- case kConstA_GrBlendCoeff:
- case kIConstA_GrBlendCoeff:
- *solidColorKnownComponents = 0;
- break;
- }
- } else {
- solidColorKnownComponents = 0;
- }
+ case kOne_GrBlendCoeff:
+ output->fBlendedColor = colorPOI.color();
+ output->fBlendedColorFlags = colorPOI.validFlags();
+ break;
+
+ // The src coeff should never refer to the src and if it refers to dst then opaque
+ // should have been false.
+ case kSC_GrBlendCoeff:
+ case kISC_GrBlendCoeff:
+ case kDC_GrBlendCoeff:
+ case kIDC_GrBlendCoeff:
+ case kSA_GrBlendCoeff:
+ case kISA_GrBlendCoeff:
+ case kDA_GrBlendCoeff:
+ case kIDA_GrBlendCoeff:
+ default:
+ SkFAIL("srcCoeff should not refer to src or dst.");
+ break;
+
+ // TODO: update this once GrPaint actually has a const color.
+ case kConstC_GrBlendCoeff:
+ case kIConstC_GrBlendCoeff:
+ case kConstA_GrBlendCoeff:
+ case kIConstA_GrBlendCoeff:
+ output->fBlendedColorFlags = 0;
+ break;
+ }
+
+ // TODO: once all SkXferEffects are XP's then we will never reads dst here since only XP's
+ // will readDst and PD XP's don't read dst.
+ if ((!colorWriteDisabled && colorPOI.readsDst()) || coveragePOI.readsDst()) {
bsalomon 2014/12/18 20:29:48 output->fWillBlendWithDst = (!colorWriteDisabled &
+ output->fWillBlendWithDst = true;
+ return;
}
- return opaque;
+ output->fWillBlendWithDst = false;
}
GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory);
« no previous file with comments | « src/gpu/effects/GrCoverageSetOpXP.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698