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

Unified Diff: src/gpu/GrPaint.cpp

Issue 21877006: Add blend optimization helpers and use to convert rect draws to clears. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: change src to rect in comment Created 7 years, 4 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 | « src/gpu/GrDrawState.h ('k') | no next file » | 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 d67f2e8707124d034003a7a170826c26e48a685a..0522e2508599066e2e53dec5c6210f5dbb457c1d 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -8,6 +8,7 @@
#include "GrPaint.h"
+#include "GrBlend.h"
#include "effects/GrSimpleTextureEffect.h"
void GrPaint::addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) {
@@ -33,3 +34,59 @@ void GrPaint::addCoverageTextureEffect(GrTexture* texture,
GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params);
this->addCoverageEffect(effect)->unref();
}
+
+bool GrPaint::isOpaque() const {
+ return this->getOpaqueAndKnownColor(NULL, NULL);
+}
+
+bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const {
+ GrColor tempColor;
+ uint32_t colorComps;
+ if (this->getOpaqueAndKnownColor(&tempColor, &colorComps)) {
+ if (kRGBA_GrColorComponentFlags == colorComps) {
+ *color = tempColor;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
+ uint32_t* solidColorKnownComponents) const {
+
+ // TODO: Share this implementation with GrDrawState
+
+ // Since fColorFilterXfermode is going away soon, we aren't attempting to handle anything but
+ // the default setting.
+ if (SkXfermode::kDst_Mode != fColorFilterXfermode) {
+ return false;
+ }
+
+ GrColor coverage = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage);
+ uint32_t coverageComps = kRGBA_GrColorComponentFlags;
+ int count = fCoverageStages.count();
+ for (int i = 0; i < count; ++i) {
+ (*fCoverageStages[i].getEffect())->getConstantColorComponents(&coverage, &coverageComps);
+ }
+ if (kRGBA_GrColorComponentFlags != coverageComps || 0xffffffff != coverage) {
+ return false;
+ }
+
+ GrColor color = fColor;
+ uint32_t colorComps = kRGBA_GrColorComponentFlags;
+ count = fColorStages.count();
+ for (int i = 0; i < count; ++i) {
+ (*fColorStages[i].getEffect())->getConstantColorComponents(&color, &colorComps);
+ }
+
+ GrAssert((NULL == solidColor) == (NULL == solidColorKnownComponents));
+ if (NULL != solidColor) {
+ *solidColor = color;
+ *solidColorKnownComponents = colorComps;
+ }
+
+ GrBlendCoeff srcCoeff = fSrcBlendCoeff;
+ GrBlendCoeff dstCoeff = fDstBlendCoeff;
+ GrSimplifyBlend(&srcCoeff, &dstCoeff, color, colorComps, 0, 0, 0);
+ return kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoeff);
+}
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698