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

Unified Diff: src/core/SkPaintPriv.cpp

Issue 864833002: Remove the need for asCoeff in SkXfermode. (Closed) Base URL: https://skia.googlesource.com/skia.git@moreXferCleanup
Patch Set: Fix build Created 5 years, 11 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/core/SkDraw.cpp ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPaintPriv.cpp
diff --git a/src/core/SkPaintPriv.cpp b/src/core/SkPaintPriv.cpp
index e82c4045aa1371a8d0c0bc1f0765d43eed0dd608..c6957cd1cafe29ba19b76937a3d10999c7680927 100644
--- a/src/core/SkPaintPriv.cpp
+++ b/src/core/SkPaintPriv.cpp
@@ -13,65 +13,28 @@
#include "SkShader.h"
bool isPaintOpaque(const SkPaint* paint, SkPaintBitmapOpacity contentType) {
- // TODO: SkXfermode should have a virtual isOpaque method, which would
- // make it possible to test modes that do not have a Coeff representation.
-
if (!paint) {
return contentType != kUnknown_SkPaintBitmapOpacity;
}
-
- SkXfermode::Coeff srcCoeff, dstCoeff;
- if (SkXfermode::AsCoeff(paint->getXfermode(), &srcCoeff, &dstCoeff)){
- if (SkXfermode::kDA_Coeff == srcCoeff || SkXfermode::kDC_Coeff == srcCoeff ||
- SkXfermode::kIDA_Coeff == srcCoeff || SkXfermode::kIDC_Coeff == srcCoeff) {
- return false;
- }
- switch (dstCoeff) {
- case SkXfermode::kZero_Coeff:
- return true;
- case SkXfermode::kISA_Coeff:
- if (paint->getAlpha() != 255) {
- break;
- }
- if (contentType == kUnknown_SkPaintBitmapOpacity) {
- break;
- } else if (paint->getShader() && !paint->getShader()->isOpaque()) {
- break;
- }
- if (paint->getColorFilter() &&
- ((paint->getColorFilter()->getFlags() &
- SkColorFilter::kAlphaUnchanged_Flag) == 0)) {
- break;
- }
- return true;
- case SkXfermode::kSA_Coeff:
- if (paint->getAlpha() != 0) {
- break;
- }
- if (paint->getColorFilter() &&
- ((paint->getColorFilter()->getFlags() &
- SkColorFilter::kAlphaUnchanged_Flag) == 0)) {
- break;
- }
- return true;
- case SkXfermode::kSC_Coeff:
- if (paint->getColor() != 0) { // all components must be 0
- break;
- }
- if (contentType != kNoBitmap_SkPaintBitmapOpacity || paint->getShader()) {
- break;
- }
- if (paint->getColorFilter() && (
- (paint->getColorFilter()->getFlags() &
- SkColorFilter::kAlphaUnchanged_Flag) == 0)) {
- break;
- }
- return true;
- default:
- break;
+ SkXfermode::SrcColorOpacity opacityType = SkXfermode::kUnknown_SrcColorOpacity;
+
+ if (!paint->getColorFilter() ||
+ ((paint->getColorFilter()->getFlags() &
+ SkColorFilter::kAlphaUnchanged_Flag) != 0)) {
+ if (0xff == paint->getAlpha() &&
+ contentType != kUnknown_SkPaintBitmapOpacity &&
+ (!paint->getShader() || paint->getShader()->isOpaque())) {
+ opacityType = SkXfermode::kOpaque_SrcColorOpacity;
+ } else if (0 == paint->getColor() &&
+ contentType == kNoBitmap_SkPaintBitmapOpacity &&
+ !paint->getShader()) {
+ opacityType = SkXfermode::kTransparentBlack_SrcColorOpacity;
+ } else if (0 == paint->getAlpha()) {
+ opacityType = SkXfermode::kTransparentAlpha_SrcColorOpacity;
}
}
- return false;
+
+ return SkXfermode::IsOpaque(paint->getXfermode(), opacityType);
}
bool isPaintOpaque(const SkPaint* paint, const SkBitmap* bmpReplacesShader) {
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698