Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / cc / blink / web_blend_mode.h
blob95c48d0b443b03418d69c2dc41d57b8d5e9920f4
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_BLINK_WEB_BLEND_MODE_H_
6 #define CC_BLINK_WEB_BLEND_MODE_H_
8 #include "third_party/WebKit/public/platform/WebBlendMode.h"
9 #include "third_party/skia/include/core/SkXfermode.h"
11 namespace cc_blink {
13 inline SkXfermode::Mode BlendModeToSkia(blink::WebBlendMode blend_mode) {
14 switch (blend_mode) {
15 case blink::WebBlendModeNormal:
16 return SkXfermode::kSrcOver_Mode;
17 case blink::WebBlendModeMultiply:
18 return SkXfermode::kMultiply_Mode;
19 case blink::WebBlendModeScreen:
20 return SkXfermode::kScreen_Mode;
21 case blink::WebBlendModeOverlay:
22 return SkXfermode::kOverlay_Mode;
23 case blink::WebBlendModeDarken:
24 return SkXfermode::kDarken_Mode;
25 case blink::WebBlendModeLighten:
26 return SkXfermode::kLighten_Mode;
27 case blink::WebBlendModeColorDodge:
28 return SkXfermode::kColorDodge_Mode;
29 case blink::WebBlendModeColorBurn:
30 return SkXfermode::kColorBurn_Mode;
31 case blink::WebBlendModeHardLight:
32 return SkXfermode::kHardLight_Mode;
33 case blink::WebBlendModeSoftLight:
34 return SkXfermode::kSoftLight_Mode;
35 case blink::WebBlendModeDifference:
36 return SkXfermode::kDifference_Mode;
37 case blink::WebBlendModeExclusion:
38 return SkXfermode::kExclusion_Mode;
39 case blink::WebBlendModeHue:
40 return SkXfermode::kHue_Mode;
41 case blink::WebBlendModeSaturation:
42 return SkXfermode::kSaturation_Mode;
43 case blink::WebBlendModeColor:
44 return SkXfermode::kColor_Mode;
45 case blink::WebBlendModeLuminosity:
46 return SkXfermode::kLuminosity_Mode;
48 return SkXfermode::kSrcOver_Mode;
51 inline blink::WebBlendMode BlendModeFromSkia(SkXfermode::Mode blend_mode) {
52 switch (blend_mode) {
53 case SkXfermode::kSrcOver_Mode:
54 return blink::WebBlendModeNormal;
55 case SkXfermode::kMultiply_Mode:
56 return blink::WebBlendModeMultiply;
57 case SkXfermode::kScreen_Mode:
58 return blink::WebBlendModeScreen;
59 case SkXfermode::kOverlay_Mode:
60 return blink::WebBlendModeOverlay;
61 case SkXfermode::kDarken_Mode:
62 return blink::WebBlendModeDarken;
63 case SkXfermode::kLighten_Mode:
64 return blink::WebBlendModeLighten;
65 case SkXfermode::kColorDodge_Mode:
66 return blink::WebBlendModeColorDodge;
67 case SkXfermode::kColorBurn_Mode:
68 return blink::WebBlendModeColorBurn;
69 case SkXfermode::kHardLight_Mode:
70 return blink::WebBlendModeHardLight;
71 case SkXfermode::kSoftLight_Mode:
72 return blink::WebBlendModeSoftLight;
73 case SkXfermode::kDifference_Mode:
74 return blink::WebBlendModeDifference;
75 case SkXfermode::kExclusion_Mode:
76 return blink::WebBlendModeExclusion;
77 case SkXfermode::kHue_Mode:
78 return blink::WebBlendModeHue;
79 case SkXfermode::kSaturation_Mode:
80 return blink::WebBlendModeSaturation;
81 case SkXfermode::kColor_Mode:
82 return blink::WebBlendModeColor;
83 case SkXfermode::kLuminosity_Mode:
84 return blink::WebBlendModeLuminosity;
86 // these value are SkXfermodes, but no blend modes.
87 case SkXfermode::kClear_Mode:
88 case SkXfermode::kSrc_Mode:
89 case SkXfermode::kDst_Mode:
90 case SkXfermode::kDstOver_Mode:
91 case SkXfermode::kSrcIn_Mode:
92 case SkXfermode::kDstIn_Mode:
93 case SkXfermode::kSrcOut_Mode:
94 case SkXfermode::kDstOut_Mode:
95 case SkXfermode::kSrcATop_Mode:
96 case SkXfermode::kDstATop_Mode:
97 case SkXfermode::kXor_Mode:
98 case SkXfermode::kPlus_Mode:
99 case SkXfermode::kModulate_Mode:
100 NOTREACHED();
102 return blink::WebBlendModeNormal;
105 } // namespace cc_blink
107 #endif // CC_BLINK_WEB_BLEND_MODE_H_