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

Unified Diff: cc/trees/layer_tree_host_pixeltest_blending.cc

Issue 23455060: mix-blend-mode implementation for accelerated layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unittests fixed Created 7 years, 1 month 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_occlusion.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_pixeltest_blending.cc
diff --git a/cc/trees/layer_tree_host_pixeltest_blending.cc b/cc/trees/layer_tree_host_pixeltest_blending.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a492a1d5bfde2cc2e11afa89d82057645b60256
--- /dev/null
+++ b/cc/trees/layer_tree_host_pixeltest_blending.cc
@@ -0,0 +1,120 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/layers/solid_color_layer.h"
+#include "cc/layers/texture_layer.h"
+#include "cc/test/layer_tree_pixel_test.h"
+
+#if !defined(OS_ANDROID)
+
+namespace cc {
+namespace {
+
+SkXfermode::Mode const kBlendModes[] = {
+ SkXfermode::kSrcOver_Mode, SkXfermode::kScreen_Mode,
+ SkXfermode::kOverlay_Mode, SkXfermode::kDarken_Mode,
+ SkXfermode::kLighten_Mode, SkXfermode::kColorDodge_Mode,
+ SkXfermode::kColorBurn_Mode, SkXfermode::kHardLight_Mode,
+ SkXfermode::kSoftLight_Mode, SkXfermode::kDifference_Mode,
+ SkXfermode::kExclusion_Mode, SkXfermode::kMultiply_Mode,
+ SkXfermode::kHue_Mode, SkXfermode::kSaturation_Mode,
+ SkXfermode::kColor_Mode, SkXfermode::kLuminosity_Mode};
+
+const int kBlendModesCount = arraysize(kBlendModes);
+
+class LayerTreeHostBlendingPixelTest : public LayerTreePixelTest {
+ protected:
+ void RunBlendingWithRootPixelTestType(PixelTestType type) {
+ const int kLaneWidth = 15;
+ const int kLaneHeight = kBlendModesCount * kLaneWidth;
+ const int kRootSize = (kBlendModesCount + 2) * kLaneWidth;
+
+ scoped_refptr<SolidColorLayer> background =
+ CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange);
+
+ // Orange child layers will blend with the green background
+ for (int i = 0; i < kBlendModesCount; ++i) {
+ gfx::Rect child_rect(
+ (i + 1) * kLaneWidth, kLaneWidth, kLaneWidth, kLaneHeight);
+ scoped_refptr<SolidColorLayer> green_lane =
+ CreateSolidColorLayer(child_rect, kCSSGreen);
+ background->AddChild(green_lane);
+ green_lane->SetBlendMode(kBlendModes[i]);
+ }
+
+ RunPixelTest(type,
+ background,
+ base::FilePath(FILE_PATH_LITERAL("blending_with_root.png")));
+ }
+
+ void RunBlendingWithTransparentPixelTestType(PixelTestType type) {
+ const int kLaneWidth = 15;
+ const int kLaneHeight = kBlendModesCount * kLaneWidth;
+ const int kRootSize = (kBlendModesCount + 2) * kLaneWidth;
+
+ scoped_refptr<SolidColorLayer> root =
+ CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSBrown);
+
+ scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
+ gfx::Rect(0, kLaneWidth * 2, kRootSize, kLaneWidth), kCSSOrange);
+
+ root->AddChild(background);
+ background->SetIsRootForIsolatedGroup(true);
+
+ // Orange child layers will blend with the green background
+ for (int i = 0; i < kBlendModesCount; ++i) {
+ gfx::Rect child_rect(
+ (i + 1) * kLaneWidth, -kLaneWidth, kLaneWidth, kLaneHeight);
+ scoped_refptr<SolidColorLayer> green_lane =
+ CreateSolidColorLayer(child_rect, kCSSGreen);
+ background->AddChild(green_lane);
+ green_lane->SetBlendMode(kBlendModes[i]);
+ }
+
+ RunPixelTest(type,
+ root,
+ base::FilePath(FILE_PATH_LITERAL("blending_transparent.png")));
+ }
+};
+
+TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) {
+ RunBlendingWithRootPixelTestType(GL_WITH_BITMAP);
+}
+
+TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithBackgroundFilter) {
+ const int kLaneWidth = 15;
+ const int kLaneHeight = kBlendModesCount * kLaneWidth;
+ const int kRootSize = (kBlendModesCount + 2) * kLaneWidth;
+
+ scoped_refptr<SolidColorLayer> background =
+ CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange);
+
+ // Orange child layers have a background filter set and they will blend with
+ // the green background
+ for (int i = 0; i < kBlendModesCount; ++i) {
+ gfx::Rect child_rect(
+ (i + 1) * kLaneWidth, kLaneWidth, kLaneWidth, kLaneHeight);
+ scoped_refptr<SolidColorLayer> green_lane =
+ CreateSolidColorLayer(child_rect, kCSSGreen);
+ background->AddChild(green_lane);
+
+ FilterOperations filters;
+ filters.Append(FilterOperation::CreateGrayscaleFilter(.75));
+ green_lane->SetBackgroundFilters(filters);
+ green_lane->SetBlendMode(kBlendModes[i]);
+ }
+
+ RunPixelTest(GL_WITH_BITMAP,
+ background,
+ base::FilePath(FILE_PATH_LITERAL("blending_and_filter.png")));
+}
+
+TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_GL) {
+ RunBlendingWithTransparentPixelTestType(GL_WITH_BITMAP);
+}
+
+} // namespace
+} // namespace cc
+
+#endif // OS_ANDROID
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_occlusion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698