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

Unified Diff: src/gpu/GrPaint.cpp

Issue 766653008: Revert of Make all blending up to GrOptDrawState be handled by the xp/xp factory. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferFactorySolo
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/GrOptDrawState.cpp ('k') | src/gpu/GrProcOptInfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrPaint.cpp
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index 5ed573a88bbb0906a4dd8d4ea210368f672d6b39..443e1c0abf71a1e81471956989b9626f3cfe2980 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -8,6 +8,7 @@
#include "GrPaint.h"
+#include "GrBlend.h"
#include "GrProcOptInfo.h"
#include "effects/GrPorterDuffXferProcessor.h"
#include "effects/GrSimpleTextureEffect.h"
@@ -51,20 +52,73 @@
void GrPaint::resetStages() {
fColorStages.reset();
fCoverageStages.reset();
- fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode));
+ fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode));
}
bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
uint32_t* solidColorKnownComponents) const {
+ // TODO: Share this implementation with GrDrawState
+
GrProcOptInfo coverageProcInfo;
coverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), this->numCoverageStages(),
0xFFFFFFFF, kRGBA_GrColorComponentFlags, true);
+
+ if (!coverageProcInfo.isSolidWhite()) {
+ return false;
+ }
+
GrProcOptInfo colorProcInfo;
colorProcInfo.calcWithInitialValues(fColorStages.begin(), this->numColorStages(), fColor,
kRGBA_GrColorComponentFlags, false);
- return fXPFactory->getOpaqueAndKnownColor(colorProcInfo, coverageProcInfo, solidColor,
- solidColorKnownComponents);
+ SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents));
+
+ GrBlendCoeff srcCoeff = fSrcBlendCoeff;
+ GrBlendCoeff dstCoeff = fDstBlendCoeff;
+ GrSimplifyBlend(&srcCoeff, &dstCoeff, colorProcInfo.color(), colorProcInfo.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;
+
+ case kOne_GrBlendCoeff:
+ *solidColor = colorProcInfo.color();
+ *solidColorKnownComponents = colorProcInfo.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:
+ *solidColorKnownComponents = 0;
+ break;
+ }
+ } else {
+ solidColorKnownComponents = 0;
+ }
+ }
+ return opaque;
}
« no previous file with comments | « src/gpu/GrOptDrawState.cpp ('k') | src/gpu/GrProcOptInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698