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

Unified Diff: src/core/SkPaintPriv.cpp

Issue 663233002: More genericity: overload isPaintOpaque(SkPaint, SkBitmap) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Revert last patchset Created 6 years, 2 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/SkPaintPriv.h ('k') | no next file » | 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 ce0538901922fde98f8e6e9695a7cdd1fab5caee..e82c4045aa1371a8d0c0bc1f0765d43eed0dd608 100644
--- a/src/core/SkPaintPriv.cpp
+++ b/src/core/SkPaintPriv.cpp
@@ -12,13 +12,12 @@
#include "SkPaint.h"
#include "SkShader.h"
-bool isPaintOpaque(const SkPaint* paint,
- const SkBitmap* bmpReplacesShader) {
+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 bmpReplacesShader ? bmpReplacesShader->isOpaque() : true;
+ return contentType != kUnknown_SkPaintBitmapOpacity;
}
SkXfermode::Coeff srcCoeff, dstCoeff;
@@ -34,10 +33,8 @@ bool isPaintOpaque(const SkPaint* paint,
if (paint->getAlpha() != 255) {
break;
}
- if (bmpReplacesShader) {
- if (!bmpReplacesShader->isOpaque()) {
- break;
- }
+ if (contentType == kUnknown_SkPaintBitmapOpacity) {
+ break;
} else if (paint->getShader() && !paint->getShader()->isOpaque()) {
break;
}
@@ -61,7 +58,7 @@ bool isPaintOpaque(const SkPaint* paint,
if (paint->getColor() != 0) { // all components must be 0
break;
}
- if (bmpReplacesShader || paint->getShader()) {
+ if (contentType != kNoBitmap_SkPaintBitmapOpacity || paint->getShader()) {
break;
}
if (paint->getColorFilter() && (
@@ -76,3 +73,16 @@ bool isPaintOpaque(const SkPaint* paint,
}
return false;
}
+
+bool isPaintOpaque(const SkPaint* paint, const SkBitmap* bmpReplacesShader) {
+ SkPaintBitmapOpacity contentType;
+
+ if(!bmpReplacesShader)
+ contentType = kNoBitmap_SkPaintBitmapOpacity;
+ else if(bmpReplacesShader->isOpaque())
+ contentType = kOpaque_SkPaintBitmapOpacity;
+ else
+ contentType = kUnknown_SkPaintBitmapOpacity;
+
+ return isPaintOpaque(paint, contentType);
+}
« no previous file with comments | « src/core/SkPaintPriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698