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

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

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 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 unified diff | Download patch
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkXfermodeInterpretation.h" 8 #include "SkXfermodeInterpretation.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 10
11 static bool just_solid_color(const SkPaint& p) { 11 static bool just_solid_color(const SkPaint& p) {
12 return SK_AlphaOPAQUE == p.getAlpha() 12 return SK_AlphaOPAQUE == p.getAlpha() && !p.getColorFilter() && !p.getShader ();
13 && !p.getColorFilter() && !p.getShader();
14 } 13 }
15 14
16 SkXfermodeInterpretation SkInterpretXfermode(const SkPaint& paint, 15 SkXfermodeInterpretation SkInterpretXfermode(const SkPaint& paint, bool dstIsOpa que) {
17 bool dstIsOpaque) { 16 switch (paint.getBlendMode()) {
18 const SkXfermode* xfer = paint.getXfermode(); 17 case SkBlendMode::kSrcOver:
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; 18 return kSrcOver_SkXfermodeInterpretation;
26 case SkXfermode::kSrc_Mode: 19 case SkBlendMode::kSrc:
27 if (just_solid_color(paint)) { 20 if (just_solid_color(paint)) {
28 return kSrcOver_SkXfermodeInterpretation; 21 return kSrcOver_SkXfermodeInterpretation;
29 } 22 }
30 return kNormal_SkXfermodeInterpretation; 23 return kNormal_SkXfermodeInterpretation;
31 case SkXfermode::kDst_Mode: 24 case SkBlendMode::kDst:
32 return kSkipDrawing_SkXfermodeInterpretation; 25 return kSkipDrawing_SkXfermodeInterpretation;
33 case SkXfermode::kDstOver_Mode: 26 case SkBlendMode::kDstOver:
34 if (dstIsOpaque) { 27 if (dstIsOpaque) {
35 return kSkipDrawing_SkXfermodeInterpretation; 28 return kSkipDrawing_SkXfermodeInterpretation;
36 } 29 }
37 return kNormal_SkXfermodeInterpretation; 30 return kNormal_SkXfermodeInterpretation;
38 case SkXfermode::kSrcIn_Mode: 31 case SkBlendMode::kSrcIn:
39 if (dstIsOpaque && just_solid_color(paint)) { 32 if (dstIsOpaque && just_solid_color(paint)) {
40 return kSrcOver_SkXfermodeInterpretation; 33 return kSrcOver_SkXfermodeInterpretation;
41 } 34 }
42 return kNormal_SkXfermodeInterpretation; 35 return kNormal_SkXfermodeInterpretation;
43 case SkXfermode::kDstIn_Mode: 36 case SkBlendMode::kDstIn:
44 if (just_solid_color(paint)) { 37 if (just_solid_color(paint)) {
45 return kSkipDrawing_SkXfermodeInterpretation; 38 return kSkipDrawing_SkXfermodeInterpretation;
46 } 39 }
47 return kNormal_SkXfermodeInterpretation; 40 return kNormal_SkXfermodeInterpretation;
48 default: 41 default:
49 return kNormal_SkXfermodeInterpretation; 42 return kNormal_SkXfermodeInterpretation;
50 } 43 }
51 } 44 }
OLDNEW
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698