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

Side by Side Diff: cc/layers/render_surface_impl_unittest.cc

Issue 394193003: Implement HiDPI and pinch-zoom scaling of filter params (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable pixel test for Android Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/render_surface_impl.h" 5 #include "cc/layers/render_surface_impl.h"
6 6
7 #include "cc/layers/append_quads_data.h"
8 #include "cc/layers/content_layer.h"
7 #include "cc/test/layer_test_common.h" 9 #include "cc/test/layer_test_common.h"
10 #include "cc/test/layer_tree_pixel_test.h"
11 #include "cc/test/solid_color_content_layer_client.h"
8 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
9 13
10 namespace cc { 14 namespace cc {
11 namespace { 15 namespace {
12 16
13 TEST(RenderSurfaceLayerImplTest, Occlusion) { 17 TEST(RenderSurfaceLayerImplTest, Occlusion) {
14 gfx::Size layer_size(1000, 1000); 18 gfx::Size layer_size(1000, 1000);
15 gfx::Size viewport_size(1000, 1000); 19 gfx::Size viewport_size(1000, 1000);
16 20
17 LayerTestCommon::LayerImplTest impl; 21 LayerTestCommon::LayerImplTest impl;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 impl.quad_list(), 60 impl.quad_list(),
57 gfx::Rect(layer_size), 61 gfx::Rect(layer_size),
58 occluded, 62 occluded,
59 &partially_occluded_count); 63 &partially_occluded_count);
60 // The layer outputs one quad, which is partially occluded. 64 // The layer outputs one quad, which is partially occluded.
61 EXPECT_EQ(1u, impl.quad_list().size()); 65 EXPECT_EQ(1u, impl.quad_list().size());
62 EXPECT_EQ(1u, partially_occluded_count); 66 EXPECT_EQ(1u, partially_occluded_count);
63 } 67 }
64 } 68 }
65 69
70 #if !defined(OS_ANDROID)
71
72 class RenderSurfaceImplHiDpiTest : public LayerTreePixelTest {
danakj 2014/08/05 14:05:43 can you move this to one of the _pixeltest.cc suff
garykac 2014/08/05 21:17:49 Done. Do you have a better name for the test than
73 protected:
74 RenderSurfaceImplHiDpiTest()
75 : device_scale_factor_(1.f),
76 content_size_(100),
77 background_client_(SK_ColorWHITE),
78 green_client_(SK_ColorGREEN),
79 blue_client_(SK_ColorBLUE) {}
80
81 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
82 // Required so that device scale is inherited by content scale.
83 settings->layer_transforms_should_scale_layer_contents = true;
84 }
85
86 virtual void SetupTree() OVERRIDE {
87 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_);
88 LayerTreePixelTest::SetupTree();
89 }
90
91 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
92 LayerImpl* root_impl = host_impl->active_tree()->root_layer();
93
94 LayerImpl* layer_impl = root_impl->children()[0];
95 layer_impl->CreateRenderSurface();
96 layer_impl->draw_properties().render_target = layer_impl;
97
98 RenderSurfaceImpl* render_surface = layer_impl->render_surface();
99 render_surface->SetContentRect(layer_impl->visible_content_rect());
100 render_surface->SetClipRect(layer_impl->clip_rect());
101 render_surface->SetDrawOpacity(1.f);
102
103 MockOcclusionTracker<LayerImpl> occlusion_tracker;
104 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
105 AppendQuadsData append_quads_data;
106 render_surface->AppendQuads(render_pass.get(),
107 occlusion_tracker,
108 &append_quads_data,
109 false,
110 RenderPass::Id(2, 0));
111
112 ASSERT_EQ(1u, render_pass->shared_quad_state_list.size());
113 SharedQuadState* quad_state = render_pass->shared_quad_state_list[0];
114
115 int expected_size = content_size_ * device_scale_factor_;
116 ASSERT_EQ(expected_size, quad_state->content_bounds.width());
117 ASSERT_EQ(expected_size, quad_state->content_bounds.height());
118 }
119
120 void RunDpiTest(int content_size, float device_scale_factor) {
121 content_size_ = content_size;
122 int half_content = content_size / 2;
123
124 scoped_refptr<ContentLayer> background =
125 ContentLayer::Create(&background_client_);
126 background->SetBounds(gfx::Size(content_size, content_size));
127 background->SetIsDrawable(true);
128
129 scoped_refptr<ContentLayer> green = ContentLayer::Create(&green_client_);
130 green->SetBounds(gfx::Size(content_size, content_size));
131 green->SetIsDrawable(true);
132 background->AddChild(green);
133
134 scoped_refptr<ContentLayer> blue = ContentLayer::Create(&blue_client_);
135 blue->SetBounds(gfx::Size(half_content, half_content));
136 blue->SetPosition(gfx::Point(half_content, half_content));
137 blue->SetIsDrawable(true);
138 green->AddChild(blue);
139
140 device_scale_factor_ = device_scale_factor;
141
142 this->impl_side_painting_ = false;
143 RunPixelTest(
144 SOFTWARE_WITH_DEFAULT,
145 background,
146 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png")));
147 }
148
149 float device_scale_factor_;
150 int content_size_;
151 SolidColorContentLayerClient background_client_;
152 SolidColorContentLayerClient green_client_;
153 SolidColorContentLayerClient blue_client_;
154 };
155
156 TEST_F(RenderSurfaceImplHiDpiTest, TestStandardDpi) {
157 RunDpiTest(100, 1.f);
158 }
159
160 TEST_F(RenderSurfaceImplHiDpiTest, TestHiDpi) {
161 RunDpiTest(50, 2.f);
162 }
163
164 #endif // OS_ANDROID
165
66 } // namespace 166 } // namespace
67 } // namespace cc 167 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698