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

Unified Diff: src/core/SkXfermodeInterpretation.cpp

Issue 1160623007: SkPDF: with opaque draws, treat SRC mode as SRC_OVER (cherrypick a681433 and 3098a75) (Closed) Base URL: https://skia.googlesource.com/skia.git@m44
Patch Set: Created 5 years, 6 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/SkXfermodeInterpretation.h ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkXfermodeInterpretation.cpp
diff --git a/src/core/SkXfermodeInterpretation.cpp b/src/core/SkXfermodeInterpretation.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1b2c8e32e6315cef7ceefafd9f11379585f8a6ec
--- /dev/null
+++ b/src/core/SkXfermodeInterpretation.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkXfermodeInterpretation.h"
+#include "SkPaint.h"
+
reed1 2015/06/08 17:30:09 Does this function need to return true only if the
hal.canary 2015/06/08 17:40:36 Good question, but outside the scope of this CL.
+static bool just_solid_color(const SkPaint& p) {
reed1 2015/06/08 17:30:09 We can inspect shaders and colorfilters as well to
hal.canary 2015/06/08 17:40:36 same.
+ return SK_AlphaOPAQUE == p.getAlpha()
+ && !p.getColorFilter() && !p.getShader();
+}
+
+SkXfermodeInterpretation SkInterpretXfermode(const SkPaint& paint,
+ bool dstIsOpaque) {
+ const SkXfermode* xfer = paint.getXfermode();
+ SkXfermode::Mode mode;
+ if (!SkXfermode::AsMode(xfer, &mode)) {
+ return kNormal_SkXfermodeInterpretation;
+ }
+ switch (mode) {
+ case SkXfermode::kSrcOver_Mode:
+ return kSrcOver_SkXfermodeInterpretation;
+ case SkXfermode::kSrc_Mode:
+ if (just_solid_color(paint)) {
+ return kSrcOver_SkXfermodeInterpretation;
+ }
+ return kNormal_SkXfermodeInterpretation;
+ case SkXfermode::kDst_Mode:
+ return kSkipDrawing_SkXfermodeInterpretation;
+ case SkXfermode::kDstOver_Mode:
+ if (dstIsOpaque) {
+ return kSkipDrawing_SkXfermodeInterpretation;
+ }
+ return kNormal_SkXfermodeInterpretation;
+ case SkXfermode::kSrcIn_Mode:
+ if (dstIsOpaque && just_solid_color(paint)) {
+ return kSrcOver_SkXfermodeInterpretation;
+ }
+ return kNormal_SkXfermodeInterpretation;
+ case SkXfermode::kDstIn_Mode:
+ if (just_solid_color(paint)) {
+ return kSkipDrawing_SkXfermodeInterpretation;
+ }
+ return kNormal_SkXfermodeInterpretation;
+ default:
+ return kNormal_SkXfermodeInterpretation;
+ }
+}
« no previous file with comments | « src/core/SkXfermodeInterpretation.h ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698