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

Side by Side Diff: public/platform/WebBlendMode.h

Issue 23511004: mix-blend-mode implementation for accelerated layers - blink part (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: adding the rendering part Created 7 years, 3 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 (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef WebBlendMode_h
32 #define WebBlendMode_h
33
34 #include "WebCommon.h"
35
36 #include "third_party/skia/include/core/SkXfermode.h"
37
38 #if WEBKIT_IMPLEMENTATION
39 #include "core/platform/graphics/GraphicsTypes.h"
jamesr 2013/08/28 22:24:49 don't do this
rosca 2013/08/29 15:04:41 Done.
40 #endif
41
42 namespace WebKit {
43
44 enum WebBlendMode {
45 WebBlendModeNormal,
46 WebBlendModeMultiply,
47 WebBlendModeScreen,
48 WebBlendModeOverlay,
49 WebBlendModeDarken,
50 WebBlendModeLighten,
51 WebBlendModeColorDodge,
52 WebBlendModeColorBurn,
53 WebBlendModeHardLight,
54 WebBlendModeSoftLight,
55 WebBlendModeDifference,
56 WebBlendModeExclusion,
57 WebBlendModeHue,
58 WebBlendModeSaturation,
59 WebBlendModeColor,
60 WebBlendModeLuminosity
61 };
62
63 #if WEBKIT_IMPLEMENTATION
64 #define WBM_COMPILE_ASSERT(WebBM, WebCoreBM) \
65 COMPILE_ASSERT((int)WebBM == (int)WebCoreBM, WebBlendMode_mismatch)
66 WBM_COMPILE_ASSERT(WebBlendModeNormal, WebCore::BlendModeNormal);
jamesr 2013/08/28 22:24:49 put these assertions in AssertMatchingEnums.cpp, n
rosca 2013/08/29 15:04:41 Done.
67 WBM_COMPILE_ASSERT(WebBlendModeMultiply, WebCore::BlendModeMultiply);
68 WBM_COMPILE_ASSERT(WebBlendModeScreen, WebCore::BlendModeScreen);
69 WBM_COMPILE_ASSERT(WebBlendModeOverlay, WebCore::BlendModeOverlay);
70 WBM_COMPILE_ASSERT(WebBlendModeDarken, WebCore::BlendModeDarken);
71 WBM_COMPILE_ASSERT(WebBlendModeLighten, WebCore::BlendModeLighten);
72 WBM_COMPILE_ASSERT(WebBlendModeColorDodge, WebCore::BlendModeColorDodge);
73 WBM_COMPILE_ASSERT(WebBlendModeColorBurn, WebCore::BlendModeColorBurn);
74 WBM_COMPILE_ASSERT(WebBlendModeHardLight, WebCore::BlendModeHardLight);
75 WBM_COMPILE_ASSERT(WebBlendModeSoftLight, WebCore::BlendModeSoftLight);
76 WBM_COMPILE_ASSERT(WebBlendModeDifference, WebCore::BlendModeDifference);
77 WBM_COMPILE_ASSERT(WebBlendModeExclusion, WebCore::BlendModeExclusion);
78 WBM_COMPILE_ASSERT(WebBlendModeHue, WebCore::BlendModeHue);
79 WBM_COMPILE_ASSERT(WebBlendModeSaturation, WebCore::BlendModeSaturation);
80 WBM_COMPILE_ASSERT(WebBlendModeColor, WebCore::BlendModeColor);
81 WBM_COMPILE_ASSERT(WebBlendModeLuminosity, WebCore::BlendModeLuminosity);
82
83 inline WebCore::BlendMode toWebCoreBlendMode(WebBlendMode blendMode)
jamesr 2013/08/28 22:24:49 these don't belong in the public header - they're
rosca 2013/08/29 15:04:41 I removed to/fromWebCoreBlendMode from public inte
84 {
85 return static_cast<WebCore::BlendMode>(blendMode);
86 }
87
88 inline WebBlendMode fromWebCoreBlendMode(WebCore::BlendMode blendMode)
89 {
90 return static_cast<WebBlendMode>(blendMode);
91 }
92
93 #endif // WEBKIT_IMPLEMENTATION
94
95 inline SkXfermode::Mode toSkiaBlendMode(WebBlendMode blendMode)
jamesr 2013/08/28 22:24:49 I don't see why this is part of the public interfa
rosca 2013/08/29 15:04:41 compositor_bindings/web_layer_impl.cc used to conv
96 {
97 switch (blendMode) {
98 case WebBlendModeNormal: return SkXfermode::kSrcOver_Mode;
99 case WebBlendModeMultiply: return SkXfermode::kMultiply_Mode;
100 case WebBlendModeScreen: return SkXfermode::kScreen_Mode;
101 case WebBlendModeOverlay: return SkXfermode::kOverlay_Mode;
102 case WebBlendModeDarken: return SkXfermode::kDarken_Mode;
103 case WebBlendModeLighten: return SkXfermode::kLighten_Mode;
104 case WebBlendModeColorDodge: return SkXfermode::kColorDodge_Mode;
105 case WebBlendModeColorBurn: return SkXfermode::kColorBurn_Mode;
106 case WebBlendModeHardLight: return SkXfermode::kHardLight_Mode;
107 case WebBlendModeSoftLight: return SkXfermode::kSoftLight_Mode;
108 case WebBlendModeDifference: return SkXfermode::kDifference_Mode;
109 case WebBlendModeExclusion: return SkXfermode::kExclusion_Mode;
110 case WebBlendModeHue: return SkXfermode::kHue_Mode;
111 case WebBlendModeSaturation: return SkXfermode::kSaturation_Mode;
112 case WebBlendModeColor: return SkXfermode::kColor_Mode;
113 case WebBlendModeLuminosity: return SkXfermode::kLuminosity_Mode;
114 default: WEBKIT_ASSERT(false);
115 }
116 return SkXfermode::kSrcOver_Mode;
117 }
118
119 inline WebBlendMode fromSkiaBlendMode(SkXfermode::Mode blendMode)
120 {
121 switch (blendMode) {
122 case SkXfermode::kSrcOver_Mode: return WebBlendModeNormal;
123 case SkXfermode::kMultiply_Mode: return WebBlendModeMultiply;
124 case SkXfermode::kScreen_Mode: return WebBlendModeScreen;
125 case SkXfermode::kOverlay_Mode: return WebBlendModeOverlay;
126 case SkXfermode::kDarken_Mode: return WebBlendModeDarken;
127 case SkXfermode::kLighten_Mode: return WebBlendModeLighten;
128 case SkXfermode::kColorDodge_Mode: return WebBlendModeColorDodge;
129 case SkXfermode::kColorBurn_Mode: return WebBlendModeColorBurn;
130 case SkXfermode::kHardLight_Mode: return WebBlendModeHardLight;
131 case SkXfermode::kSoftLight_Mode: return WebBlendModeSoftLight;
132 case SkXfermode::kDifference_Mode: return WebBlendModeDifference;
133 case SkXfermode::kExclusion_Mode: return WebBlendModeExclusion;
134 case SkXfermode::kHue_Mode: return WebBlendModeHue;
135 case SkXfermode::kSaturation_Mode: return WebBlendModeSaturation;
136 case SkXfermode::kColor_Mode: return WebBlendModeColor;
137 case SkXfermode::kLuminosity_Mode: return WebBlendModeLuminosity;
138 default: WEBKIT_ASSERT(false);
139 }
140 return WebBlendModeNormal;
141 }
142
143 } // namespace WebKit
144
145 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698