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

Side by Side 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 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 | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_occlusion.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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.
4
5 #include "cc/layers/solid_color_layer.h"
6 #include "cc/layers/texture_layer.h"
7 #include "cc/test/layer_tree_pixel_test.h"
8
9 #if !defined(OS_ANDROID)
10
11 namespace cc {
12 namespace {
13
14 SkXfermode::Mode const kBlendModes[] = {
15 SkXfermode::kSrcOver_Mode, SkXfermode::kScreen_Mode,
16 SkXfermode::kOverlay_Mode, SkXfermode::kDarken_Mode,
17 SkXfermode::kLighten_Mode, SkXfermode::kColorDodge_Mode,
18 SkXfermode::kColorBurn_Mode, SkXfermode::kHardLight_Mode,
19 SkXfermode::kSoftLight_Mode, SkXfermode::kDifference_Mode,
20 SkXfermode::kExclusion_Mode, SkXfermode::kMultiply_Mode,
21 SkXfermode::kHue_Mode, SkXfermode::kSaturation_Mode,
22 SkXfermode::kColor_Mode, SkXfermode::kLuminosity_Mode};
23
24 const int kBlendModesCount = arraysize(kBlendModes);
25
26 class LayerTreeHostBlendingPixelTest : public LayerTreePixelTest {
27 protected:
28 void RunBlendingWithRootPixelTestType(PixelTestType type) {
29 const int kLaneWidth = 15;
30 const int kLaneHeight = kBlendModesCount * kLaneWidth;
31 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth;
32
33 scoped_refptr<SolidColorLayer> background =
34 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange);
35
36 // Orange child layers will blend with the green background
37 for (int i = 0; i < kBlendModesCount; ++i) {
38 gfx::Rect child_rect(
39 (i + 1) * kLaneWidth, kLaneWidth, kLaneWidth, kLaneHeight);
40 scoped_refptr<SolidColorLayer> green_lane =
41 CreateSolidColorLayer(child_rect, kCSSGreen);
42 background->AddChild(green_lane);
43 green_lane->SetBlendMode(kBlendModes[i]);
44 }
45
46 RunPixelTest(type,
47 background,
48 base::FilePath(FILE_PATH_LITERAL("blending_with_root.png")));
49 }
50
51 void RunBlendingWithTransparentPixelTestType(PixelTestType type) {
52 const int kLaneWidth = 15;
53 const int kLaneHeight = kBlendModesCount * kLaneWidth;
54 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth;
55
56 scoped_refptr<SolidColorLayer> root =
57 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSBrown);
58
59 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
60 gfx::Rect(0, kLaneWidth * 2, kRootSize, kLaneWidth), kCSSOrange);
61
62 root->AddChild(background);
63 background->SetIsRootForIsolatedGroup(true);
64
65 // Orange child layers will blend with the green background
66 for (int i = 0; i < kBlendModesCount; ++i) {
67 gfx::Rect child_rect(
68 (i + 1) * kLaneWidth, -kLaneWidth, kLaneWidth, kLaneHeight);
69 scoped_refptr<SolidColorLayer> green_lane =
70 CreateSolidColorLayer(child_rect, kCSSGreen);
71 background->AddChild(green_lane);
72 green_lane->SetBlendMode(kBlendModes[i]);
73 }
74
75 RunPixelTest(type,
76 root,
77 base::FilePath(FILE_PATH_LITERAL("blending_transparent.png")));
78 }
79 };
80
81 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) {
82 RunBlendingWithRootPixelTestType(GL_WITH_BITMAP);
83 }
84
85 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithBackgroundFilter) {
86 const int kLaneWidth = 15;
87 const int kLaneHeight = kBlendModesCount * kLaneWidth;
88 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth;
89
90 scoped_refptr<SolidColorLayer> background =
91 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange);
92
93 // Orange child layers have a background filter set and they will blend with
94 // the green background
95 for (int i = 0; i < kBlendModesCount; ++i) {
96 gfx::Rect child_rect(
97 (i + 1) * kLaneWidth, kLaneWidth, kLaneWidth, kLaneHeight);
98 scoped_refptr<SolidColorLayer> green_lane =
99 CreateSolidColorLayer(child_rect, kCSSGreen);
100 background->AddChild(green_lane);
101
102 FilterOperations filters;
103 filters.Append(FilterOperation::CreateGrayscaleFilter(.75));
104 green_lane->SetBackgroundFilters(filters);
105 green_lane->SetBlendMode(kBlendModes[i]);
106 }
107
108 RunPixelTest(GL_WITH_BITMAP,
109 background,
110 base::FilePath(FILE_PATH_LITERAL("blending_and_filter.png")));
111 }
112
113 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_GL) {
114 RunBlendingWithTransparentPixelTestType(GL_WITH_BITMAP);
115 }
116
117 } // namespace
118 } // namespace cc
119
120 #endif // OS_ANDROID
OLDNEW
« 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