Removed data compression UMA from ProxyService
[chromium-blink-merge.git] / cc / trees / layer_tree_host_pixeltest_blending.cc
blob7a492a1d5bfde2cc2e11afa89d82057645b60256
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.
5 #include "cc/layers/solid_color_layer.h"
6 #include "cc/layers/texture_layer.h"
7 #include "cc/test/layer_tree_pixel_test.h"
9 #if !defined(OS_ANDROID)
11 namespace cc {
12 namespace {
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};
24 const int kBlendModesCount = arraysize(kBlendModes);
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;
33 scoped_refptr<SolidColorLayer> background =
34 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange);
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]);
46 RunPixelTest(type,
47 background,
48 base::FilePath(FILE_PATH_LITERAL("blending_with_root.png")));
51 void RunBlendingWithTransparentPixelTestType(PixelTestType type) {
52 const int kLaneWidth = 15;
53 const int kLaneHeight = kBlendModesCount * kLaneWidth;
54 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth;
56 scoped_refptr<SolidColorLayer> root =
57 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSBrown);
59 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
60 gfx::Rect(0, kLaneWidth * 2, kRootSize, kLaneWidth), kCSSOrange);
62 root->AddChild(background);
63 background->SetIsRootForIsolatedGroup(true);
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]);
75 RunPixelTest(type,
76 root,
77 base::FilePath(FILE_PATH_LITERAL("blending_transparent.png")));
81 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) {
82 RunBlendingWithRootPixelTestType(GL_WITH_BITMAP);
85 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithBackgroundFilter) {
86 const int kLaneWidth = 15;
87 const int kLaneHeight = kBlendModesCount * kLaneWidth;
88 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth;
90 scoped_refptr<SolidColorLayer> background =
91 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange);
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);
102 FilterOperations filters;
103 filters.Append(FilterOperation::CreateGrayscaleFilter(.75));
104 green_lane->SetBackgroundFilters(filters);
105 green_lane->SetBlendMode(kBlendModes[i]);
108 RunPixelTest(GL_WITH_BITMAP,
109 background,
110 base::FilePath(FILE_PATH_LITERAL("blending_and_filter.png")));
113 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_GL) {
114 RunBlendingWithTransparentPixelTestType(GL_WITH_BITMAP);
117 } // namespace
118 } // namespace cc
120 #endif // OS_ANDROID