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

Unified 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, 4 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
Index: public/platform/WebBlendMode.h
diff --git a/public/platform/WebBlendMode.h b/public/platform/WebBlendMode.h
new file mode 100644
index 0000000000000000000000000000000000000000..3070fc683c5f921c6183d02df4af74924a8b0b61
--- /dev/null
+++ b/public/platform/WebBlendMode.h
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebBlendMode_h
+#define WebBlendMode_h
+
+#include "WebCommon.h"
+
+#include "third_party/skia/include/core/SkXfermode.h"
+
+#if WEBKIT_IMPLEMENTATION
+#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.
+#endif
+
+namespace WebKit {
+
+enum WebBlendMode {
+ WebBlendModeNormal,
+ WebBlendModeMultiply,
+ WebBlendModeScreen,
+ WebBlendModeOverlay,
+ WebBlendModeDarken,
+ WebBlendModeLighten,
+ WebBlendModeColorDodge,
+ WebBlendModeColorBurn,
+ WebBlendModeHardLight,
+ WebBlendModeSoftLight,
+ WebBlendModeDifference,
+ WebBlendModeExclusion,
+ WebBlendModeHue,
+ WebBlendModeSaturation,
+ WebBlendModeColor,
+ WebBlendModeLuminosity
+};
+
+#if WEBKIT_IMPLEMENTATION
+#define WBM_COMPILE_ASSERT(WebBM, WebCoreBM) \
+ COMPILE_ASSERT((int)WebBM == (int)WebCoreBM, WebBlendMode_mismatch)
+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.
+WBM_COMPILE_ASSERT(WebBlendModeMultiply, WebCore::BlendModeMultiply);
+WBM_COMPILE_ASSERT(WebBlendModeScreen, WebCore::BlendModeScreen);
+WBM_COMPILE_ASSERT(WebBlendModeOverlay, WebCore::BlendModeOverlay);
+WBM_COMPILE_ASSERT(WebBlendModeDarken, WebCore::BlendModeDarken);
+WBM_COMPILE_ASSERT(WebBlendModeLighten, WebCore::BlendModeLighten);
+WBM_COMPILE_ASSERT(WebBlendModeColorDodge, WebCore::BlendModeColorDodge);
+WBM_COMPILE_ASSERT(WebBlendModeColorBurn, WebCore::BlendModeColorBurn);
+WBM_COMPILE_ASSERT(WebBlendModeHardLight, WebCore::BlendModeHardLight);
+WBM_COMPILE_ASSERT(WebBlendModeSoftLight, WebCore::BlendModeSoftLight);
+WBM_COMPILE_ASSERT(WebBlendModeDifference, WebCore::BlendModeDifference);
+WBM_COMPILE_ASSERT(WebBlendModeExclusion, WebCore::BlendModeExclusion);
+WBM_COMPILE_ASSERT(WebBlendModeHue, WebCore::BlendModeHue);
+WBM_COMPILE_ASSERT(WebBlendModeSaturation, WebCore::BlendModeSaturation);
+WBM_COMPILE_ASSERT(WebBlendModeColor, WebCore::BlendModeColor);
+WBM_COMPILE_ASSERT(WebBlendModeLuminosity, WebCore::BlendModeLuminosity);
+
+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
+{
+ return static_cast<WebCore::BlendMode>(blendMode);
+}
+
+inline WebBlendMode fromWebCoreBlendMode(WebCore::BlendMode blendMode)
+{
+ return static_cast<WebBlendMode>(blendMode);
+}
+
+#endif // WEBKIT_IMPLEMENTATION
+
+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
+{
+ switch (blendMode) {
+ case WebBlendModeNormal: return SkXfermode::kSrcOver_Mode;
+ case WebBlendModeMultiply: return SkXfermode::kMultiply_Mode;
+ case WebBlendModeScreen: return SkXfermode::kScreen_Mode;
+ case WebBlendModeOverlay: return SkXfermode::kOverlay_Mode;
+ case WebBlendModeDarken: return SkXfermode::kDarken_Mode;
+ case WebBlendModeLighten: return SkXfermode::kLighten_Mode;
+ case WebBlendModeColorDodge: return SkXfermode::kColorDodge_Mode;
+ case WebBlendModeColorBurn: return SkXfermode::kColorBurn_Mode;
+ case WebBlendModeHardLight: return SkXfermode::kHardLight_Mode;
+ case WebBlendModeSoftLight: return SkXfermode::kSoftLight_Mode;
+ case WebBlendModeDifference: return SkXfermode::kDifference_Mode;
+ case WebBlendModeExclusion: return SkXfermode::kExclusion_Mode;
+ case WebBlendModeHue: return SkXfermode::kHue_Mode;
+ case WebBlendModeSaturation: return SkXfermode::kSaturation_Mode;
+ case WebBlendModeColor: return SkXfermode::kColor_Mode;
+ case WebBlendModeLuminosity: return SkXfermode::kLuminosity_Mode;
+ default: WEBKIT_ASSERT(false);
+ }
+ return SkXfermode::kSrcOver_Mode;
+}
+
+inline WebBlendMode fromSkiaBlendMode(SkXfermode::Mode blendMode)
+{
+ switch (blendMode) {
+ case SkXfermode::kSrcOver_Mode: return WebBlendModeNormal;
+ case SkXfermode::kMultiply_Mode: return WebBlendModeMultiply;
+ case SkXfermode::kScreen_Mode: return WebBlendModeScreen;
+ case SkXfermode::kOverlay_Mode: return WebBlendModeOverlay;
+ case SkXfermode::kDarken_Mode: return WebBlendModeDarken;
+ case SkXfermode::kLighten_Mode: return WebBlendModeLighten;
+ case SkXfermode::kColorDodge_Mode: return WebBlendModeColorDodge;
+ case SkXfermode::kColorBurn_Mode: return WebBlendModeColorBurn;
+ case SkXfermode::kHardLight_Mode: return WebBlendModeHardLight;
+ case SkXfermode::kSoftLight_Mode: return WebBlendModeSoftLight;
+ case SkXfermode::kDifference_Mode: return WebBlendModeDifference;
+ case SkXfermode::kExclusion_Mode: return WebBlendModeExclusion;
+ case SkXfermode::kHue_Mode: return WebBlendModeHue;
+ case SkXfermode::kSaturation_Mode: return WebBlendModeSaturation;
+ case SkXfermode::kColor_Mode: return WebBlendModeColor;
+ case SkXfermode::kLuminosity_Mode: return WebBlendModeLuminosity;
+ default: WEBKIT_ASSERT(false);
+ }
+ return WebBlendModeNormal;
+}
+
+} // namespace WebKit
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698