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

Side by Side Diff: cc/trees/layer_tree_host_unittest_damage.cc

Issue 2632463005: cc: Ensure that large damage doesn't register as "frame has no damage" (Closed)
Patch Set: update Created 3 years, 11 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 | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_video.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 } 50 }
51 51
52 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, 52 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl,
53 LayerTreeHostImpl::FrameData* frame_data, 53 LayerTreeHostImpl::FrameData* frame_data,
54 DrawResult draw_result) override { 54 DrawResult draw_result) override {
55 EXPECT_EQ(DRAW_SUCCESS, draw_result); 55 EXPECT_EQ(DRAW_SUCCESS, draw_result);
56 56
57 RenderSurfaceImpl* root_surface = 57 RenderSurfaceImpl* root_surface =
58 impl->active_tree()->root_layer_for_testing()->render_surface(); 58 impl->active_tree()->root_layer_for_testing()->render_surface();
59 gfx::Rect root_damage = 59 gfx::Rect root_damage;
60 root_surface->damage_tracker()->current_damage_rect(); 60 EXPECT_TRUE(
61 root_surface->damage_tracker()->GetDamageRectIfValid(&root_damage));
61 62
62 switch (draw_count_) { 63 switch (draw_count_) {
63 case 0: 64 case 0:
64 // The first frame has full damage. 65 // The first frame has full damage.
65 EXPECT_EQ(gfx::Rect(10, 10), root_damage); 66 EXPECT_EQ(gfx::Rect(10, 10), root_damage);
66 break; 67 break;
67 case 1: 68 case 1:
68 // The second frame has full damage. 69 // The second frame has full damage.
69 EXPECT_EQ(gfx::Rect(10, 10), root_damage); 70 EXPECT_EQ(gfx::Rect(10, 10), root_damage);
70 EndTest(); 71 EndTest();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 112 }
112 } 113 }
113 114
114 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, 115 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl,
115 LayerTreeHostImpl::FrameData* frame_data, 116 LayerTreeHostImpl::FrameData* frame_data,
116 DrawResult draw_result) override { 117 DrawResult draw_result) override {
117 EXPECT_EQ(DRAW_SUCCESS, draw_result); 118 EXPECT_EQ(DRAW_SUCCESS, draw_result);
118 119
119 RenderSurfaceImpl* root_surface = 120 RenderSurfaceImpl* root_surface =
120 impl->active_tree()->root_layer_for_testing()->render_surface(); 121 impl->active_tree()->root_layer_for_testing()->render_surface();
121 gfx::Rect root_damage = 122 gfx::Rect root_damage;
122 root_surface->damage_tracker()->current_damage_rect(); 123 EXPECT_TRUE(
124 root_surface->damage_tracker()->GetDamageRectIfValid(&root_damage));
123 125
124 switch (draw_count_) { 126 switch (draw_count_) {
125 case 0: 127 case 0:
126 // The first frame has full damage. 128 // The first frame has full damage.
127 EXPECT_EQ(gfx::Rect(10, 10), root_damage); 129 EXPECT_EQ(gfx::Rect(10, 10), root_damage);
128 break; 130 break;
129 case 1: 131 case 1:
130 // The second frame has full damage. 132 // The second frame has full damage.
131 EXPECT_EQ(gfx::Rect(15, 15), root_damage); 133 EXPECT_EQ(gfx::Rect(15, 15), root_damage);
132 EndTest(); 134 EndTest();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 client_.set_bounds(root_->bounds()); 254 client_.set_bounds(root_->bounds());
253 } 255 }
254 256
255 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 257 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
256 LayerTreeHostImpl::FrameData* frame_data, 258 LayerTreeHostImpl::FrameData* frame_data,
257 DrawResult draw_result) override { 259 DrawResult draw_result) override {
258 EXPECT_EQ(DRAW_SUCCESS, draw_result); 260 EXPECT_EQ(DRAW_SUCCESS, draw_result);
259 261
260 RenderSurfaceImpl* root_surface = 262 RenderSurfaceImpl* root_surface =
261 host_impl->active_tree()->root_layer_for_testing()->render_surface(); 263 host_impl->active_tree()->root_layer_for_testing()->render_surface();
262 gfx::Rect root_damage = 264 gfx::Rect root_damage;
263 root_surface->damage_tracker()->current_damage_rect(); 265 EXPECT_TRUE(
266 root_surface->damage_tracker()->GetDamageRectIfValid(&root_damage));
264 root_damage.Intersect(root_surface->content_rect()); 267 root_damage.Intersect(root_surface->content_rect());
265 268
266 int source_frame = host_impl->active_tree()->source_frame_number(); 269 int source_frame = host_impl->active_tree()->source_frame_number();
267 switch (source_frame) { 270 switch (source_frame) {
268 case 0: 271 case 0:
269 // The first frame draws and clears any damage. 272 // The first frame draws and clears any damage.
270 EXPECT_EQ(root_surface->content_rect(), root_damage); 273 EXPECT_EQ(root_surface->content_rect(), root_damage);
271 EXPECT_FALSE(frame_data->has_no_damage); 274 EXPECT_FALSE(frame_data->has_no_damage);
272 break; 275 break;
273 case 1: 276 case 1:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 num_draws_ = 0; 380 num_draws_ = 0;
378 PostSetNeedsCommitToMainThread(); 381 PostSetNeedsCommitToMainThread();
379 } 382 }
380 383
381 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 384 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
382 LayerTreeHostImpl::FrameData* frame_data, 385 LayerTreeHostImpl::FrameData* frame_data,
383 DrawResult draw_result) override { 386 DrawResult draw_result) override {
384 EXPECT_EQ(DRAW_SUCCESS, draw_result); 387 EXPECT_EQ(DRAW_SUCCESS, draw_result);
385 RenderSurfaceImpl* root_surface = 388 RenderSurfaceImpl* root_surface =
386 host_impl->active_tree()->root_layer_for_testing()->render_surface(); 389 host_impl->active_tree()->root_layer_for_testing()->render_surface();
387 gfx::Rect root_damage = 390 gfx::Rect root_damage;
388 root_surface->damage_tracker()->current_damage_rect(); 391 EXPECT_TRUE(
392 root_surface->damage_tracker()->GetDamageRectIfValid(&root_damage));
389 root_damage.Intersect(root_surface->content_rect()); 393 root_damage.Intersect(root_surface->content_rect());
390 switch (num_draws_) { 394 switch (num_draws_) {
391 case 0: 395 case 0:
392 // The first frame has damage, so we should draw and swap. 396 // The first frame has damage, so we should draw and swap.
393 break; 397 break;
394 case 1: 398 case 1:
395 // The second frame should not damage the scrollbars. 399 // The second frame should not damage the scrollbars.
396 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100))); 400 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100)));
397 break; 401 break;
398 case 2: 402 case 2:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 num_draws_ = 0; 465 num_draws_ = 0;
462 PostSetNeedsCommitToMainThread(); 466 PostSetNeedsCommitToMainThread();
463 } 467 }
464 468
465 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 469 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
466 LayerTreeHostImpl::FrameData* frame_data, 470 LayerTreeHostImpl::FrameData* frame_data,
467 DrawResult draw_result) override { 471 DrawResult draw_result) override {
468 EXPECT_EQ(DRAW_SUCCESS, draw_result); 472 EXPECT_EQ(DRAW_SUCCESS, draw_result);
469 RenderSurfaceImpl* root_surface = 473 RenderSurfaceImpl* root_surface =
470 host_impl->active_tree()->root_layer_for_testing()->render_surface(); 474 host_impl->active_tree()->root_layer_for_testing()->render_surface();
471 gfx::Rect root_damage = 475 gfx::Rect root_damage;
472 root_surface->damage_tracker()->current_damage_rect(); 476 EXPECT_TRUE(
477 root_surface->damage_tracker()->GetDamageRectIfValid(&root_damage));
473 root_damage.Intersect(root_surface->content_rect()); 478 root_damage.Intersect(root_surface->content_rect());
474 int frame = host_impl->active_tree()->source_frame_number(); 479 int frame = host_impl->active_tree()->source_frame_number();
475 switch (num_draws_) { 480 switch (num_draws_) {
476 case 0: 481 case 0:
477 // The first frame has damage, so we should draw and swap. 482 // The first frame has damage, so we should draw and swap.
478 EXPECT_EQ(0, frame); 483 EXPECT_EQ(0, frame);
479 break; 484 break;
480 case 1: 485 case 1:
481 // The second frame has scrolled, so the scrollbar should be damaged. 486 // The second frame has scrolled, so the scrollbar should be damaged.
482 EXPECT_EQ(0, frame); 487 EXPECT_EQ(0, frame);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 526
522 void AfterTest() override { EXPECT_EQ(3, num_draws_); } 527 void AfterTest() override { EXPECT_EQ(3, num_draws_); }
523 528
524 int num_draws_; 529 int num_draws_;
525 }; 530 };
526 531
527 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); 532 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage);
528 533
529 } // namespace 534 } // namespace
530 } // namespace cc 535 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_video.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698