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

Side by Side Diff: content/browser/compositor/reflector_impl_unittest.cc

Issue 1080633009: ui: Clean up damaged rects and clear them after painting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: damagedregion: fixtest Created 5 years, 8 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
« no previous file with comments | « no previous file | ui/compositor/compositor.cc » ('j') | ui/compositor/compositor.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "cc/test/fake_output_surface_client.h" 8 #include "cc/test/fake_output_surface_client.h"
9 #include "cc/test/test_context_provider.h" 9 #include "cc/test/test_context_provider.h"
10 #include "cc/test/test_web_graphics_context_3d.h" 10 #include "cc/test/test_web_graphics_context_3d.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 #if defined(OS_MACOSX) 83 #if defined(OS_MACOSX)
84 void OnSurfaceDisplayed() override {} 84 void OnSurfaceDisplayed() override {}
85 void OnSurfaceRecycled() override {} 85 void OnSurfaceRecycled() override {}
86 bool ShouldNotShowFramesAfterRecycle() const override { return false; } 86 bool ShouldNotShowFramesAfterRecycle() const override { return false; }
87 #endif 87 #endif
88 88
89 gfx::Size SurfaceSize() const override { return gfx::Size(256, 256); } 89 gfx::Size SurfaceSize() const override { return gfx::Size(256, 256); }
90 }; 90 };
91 91
92 const gfx::Rect kSubRect = gfx::Rect(0, 0, 64, 64); 92 const gfx::Rect kSubRect(0, 0, 64, 64);
93 const SkIRect kSkSubRect = SkIRect::MakeXYWH(0, 0, 64, 64);
94 93
95 } // namespace 94 } // namespace
96 95
97 class ReflectorImplTest : public testing::Test { 96 class ReflectorImplTest : public testing::Test {
98 public: 97 public:
99 void SetUp() override { 98 void SetUp() override {
100 bool enable_pixel_output = false; 99 bool enable_pixel_output = false;
101 ui::ContextFactory* context_factory = 100 ui::ContextFactory* context_factory =
102 ui::InitializeContextFactoryForTests(enable_pixel_output); 101 ui::InitializeContextFactoryForTests(enable_pixel_output);
103 ImageTransportFactory::InitializeForUnitTests( 102 ImageTransportFactory::InitializeForUnitTests(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 scoped_ptr<ReflectorImpl> reflector_; 151 scoped_ptr<ReflectorImpl> reflector_;
153 scoped_ptr<TestOutputSurface> output_surface_; 152 scoped_ptr<TestOutputSurface> output_surface_;
154 }; 153 };
155 154
156 namespace { 155 namespace {
157 TEST_F(ReflectorImplTest, CheckNormalOutputSurface) { 156 TEST_F(ReflectorImplTest, CheckNormalOutputSurface) {
158 output_surface_->SetFlip(false); 157 output_surface_->SetFlip(false);
159 SetUpReflector(); 158 SetUpReflector();
160 UpdateTexture(); 159 UpdateTexture();
161 EXPECT_TRUE(mirroring_layer_->TextureFlipped()); 160 EXPECT_TRUE(mirroring_layer_->TextureFlipped());
162 EXPECT_EQ(SkRegion(SkIRect::MakeXYWH( 161 gfx::Rect expected_rect =
163 0, output_surface_->SurfaceSize().height() - kSubRect.height(), 162 kSubRect + gfx::Vector2d(0, output_surface_->SurfaceSize().height()) -
164 kSubRect.width(), kSubRect.height())), 163 gfx::Vector2d(0, kSubRect.height());
165 mirroring_layer_->damaged_region()); 164 EXPECT_EQ(expected_rect, mirroring_layer_->damaged_region());
166 } 165 }
167 166
168 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { 167 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) {
169 output_surface_->SetFlip(true); 168 output_surface_->SetFlip(true);
170 SetUpReflector(); 169 SetUpReflector();
171 UpdateTexture(); 170 UpdateTexture();
172 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); 171 EXPECT_FALSE(mirroring_layer_->TextureFlipped());
173 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); 172 EXPECT_EQ(kSubRect, mirroring_layer_->damaged_region());
174 } 173 }
175 174
176 #if defined(USE_OZONE) 175 #if defined(USE_OZONE)
177 TEST_F(ReflectorImplTest, CheckOverlayNoReflector) { 176 TEST_F(ReflectorImplTest, CheckOverlayNoReflector) {
178 cc::OverlayCandidateList list; 177 cc::OverlayCandidateList list;
179 cc::OverlayCandidate plane_1, plane_2; 178 cc::OverlayCandidate plane_1, plane_2;
180 plane_1.plane_z_order = 0; 179 plane_1.plane_z_order = 0;
181 plane_2.plane_z_order = 1; 180 plane_2.plane_z_order = 1;
182 list.push_back(plane_1); 181 list.push_back(plane_1);
183 list.push_back(plane_2); 182 list.push_back(plane_2);
184 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); 183 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list);
185 EXPECT_TRUE(list[0].overlay_handled); 184 EXPECT_TRUE(list[0].overlay_handled);
186 } 185 }
187 186
188 TEST_F(ReflectorImplTest, CheckOverlaySWMirroring) { 187 TEST_F(ReflectorImplTest, CheckOverlaySWMirroring) {
189 SetUpReflector(); 188 SetUpReflector();
190 cc::OverlayCandidateList list; 189 cc::OverlayCandidateList list;
191 cc::OverlayCandidate plane_1, plane_2; 190 cc::OverlayCandidate plane_1, plane_2;
192 plane_1.plane_z_order = 0; 191 plane_1.plane_z_order = 0;
193 plane_2.plane_z_order = 1; 192 plane_2.plane_z_order = 1;
194 list.push_back(plane_1); 193 list.push_back(plane_1);
195 list.push_back(plane_2); 194 list.push_back(plane_2);
196 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); 195 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list);
197 EXPECT_FALSE(list[0].overlay_handled); 196 EXPECT_FALSE(list[0].overlay_handled);
198 } 197 }
199 #endif // defined(USE_OZONE) 198 #endif // defined(USE_OZONE)
200 199
201 } // namespace 200 } // namespace
202 } // namespace content 201 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/compositor.cc » ('j') | ui/compositor/compositor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698