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

Side by Side Diff: src/core/SkXfermodeInterpretation.cpp

Issue 1159763004: SkPDF: with opaque draws, treat SRC mode as SRC_OVER (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unify with blitter code 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkXfermodeInterpretation.h"
9 #include "SkPaint.h"
10
11 static bool just_solid_color(const SkPaint& p) {
12 return SK_AlphaOPAQUE == p.getAlpha()
13 && !p.getColorFilter() && !p.getShader();
14 }
15
16 SkXfermodeInterpretation SkInterpretXfermode(const SkPaint& paint,
17 bool dstIsOpaque) {
18 const SkXfermode* xfer = paint.getXfermode();
19 SkXfermode::Mode mode;
20 if (!SkXfermode::AsMode(xfer, &mode)) {
21 return kNormal_SkXfermodeInterpretation;
22 }
23 switch (mode) {
24 case SkXfermode::kSrcOver_Mode:
25 return kSrcOver_SkXfermodeInterpretation;
26 case SkXfermode::kSrc_Mode:
27 if (just_solid_color(paint)) {
28 return kSrcOver_SkXfermodeInterpretation;
29 }
30 return kNormal_SkXfermodeInterpretation;
31 case SkXfermode::kDst_Mode:
32 return kSkipDrawing_SkXfermodeInterpretation;
33 case SkXfermode::kDstOver_Mode:
34 if (dstIsOpaque) {
35 return kSkipDrawing_SkXfermodeInterpretation;
36 }
37 return kNormal_SkXfermodeInterpretation;
38 case SkXfermode::kSrcIn_Mode:
39 if (dstIsOpaque && just_solid_color(paint)) {
40 return kSrcOver_SkXfermodeInterpretation;
41 }
42 return kNormal_SkXfermodeInterpretation;
43 case SkXfermode::kDstIn_Mode:
44 if (just_solid_color(paint)) {
45 return kSkipDrawing_SkXfermodeInterpretation;
46 }
47 return kNormal_SkXfermodeInterpretation;
48 default:
49 return kNormal_SkXfermodeInterpretation;
50 }
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698