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

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

Issue 131683005: cc: Make PrepareToDraw return an enum for why it aborts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DRAW_SUCCESS; assert CanDraw Created 6 years, 10 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 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/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 virtual void DidCommitAndDrawFrame() OVERRIDE { 43 virtual void DidCommitAndDrawFrame() OVERRIDE {
44 switch (layer_tree_host()->source_frame_number()) { 44 switch (layer_tree_host()->source_frame_number()) {
45 case 1: 45 case 1:
46 layer_tree_host()->SetNeedsRedraw(); 46 layer_tree_host()->SetNeedsRedraw();
47 break; 47 break;
48 } 48 }
49 } 49 }
50 50
51 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* impl, 51 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
52 LayerTreeHostImpl::FrameData* frame_data, 52 LayerTreeHostImpl* impl,
53 bool result) OVERRIDE { 53 LayerTreeHostImpl::FrameData* frame_data,
54 EXPECT_TRUE(result); 54 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
55 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
55 56
56 RenderSurfaceImpl* root_surface = 57 RenderSurfaceImpl* root_surface =
57 impl->active_tree()->root_layer()->render_surface(); 58 impl->active_tree()->root_layer()->render_surface();
58 gfx::RectF root_damage = 59 gfx::RectF root_damage =
59 root_surface->damage_tracker()->current_damage_rect(); 60 root_surface->damage_tracker()->current_damage_rect();
60 61
61 switch (draw_count_) { 62 switch (draw_count_) {
62 case 0: 63 case 0:
63 // The first frame has full damage. 64 // The first frame has full damage.
64 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString()); 65 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString());
65 break; 66 break;
66 case 1: 67 case 1:
67 // The second frame has full damage. 68 // The second frame has full damage.
68 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString()); 69 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString());
69 EndTest(); 70 EndTest();
70 break; 71 break;
71 case 2: 72 case 2:
72 NOTREACHED(); 73 NOTREACHED();
73 } 74 }
74 75
75 ++draw_count_; 76 ++draw_count_;
76 return result; 77 return draw_result;
77 } 78 }
78 79
79 virtual void AfterTest() OVERRIDE {} 80 virtual void AfterTest() OVERRIDE {}
80 81
81 int draw_count_; 82 int draw_count_;
82 FakeContentLayerClient client_; 83 FakeContentLayerClient client_;
83 }; 84 };
84 85
85 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestSetNeedsRedraw); 86 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestSetNeedsRedraw);
86 87
(...skipping 15 matching lines...) Expand all
102 } 103 }
103 104
104 virtual void DidCommitAndDrawFrame() OVERRIDE { 105 virtual void DidCommitAndDrawFrame() OVERRIDE {
105 switch (layer_tree_host()->source_frame_number()) { 106 switch (layer_tree_host()->source_frame_number()) {
106 case 1: 107 case 1:
107 layer_tree_host()->SetViewportSize(gfx::Size(15, 15)); 108 layer_tree_host()->SetViewportSize(gfx::Size(15, 15));
108 break; 109 break;
109 } 110 }
110 } 111 }
111 112
112 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* impl, 113 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
113 LayerTreeHostImpl::FrameData* frame_data, 114 LayerTreeHostImpl* impl,
114 bool result) OVERRIDE { 115 LayerTreeHostImpl::FrameData* frame_data,
115 EXPECT_TRUE(result); 116 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
117 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
116 118
117 RenderSurfaceImpl* root_surface = 119 RenderSurfaceImpl* root_surface =
118 impl->active_tree()->root_layer()->render_surface(); 120 impl->active_tree()->root_layer()->render_surface();
119 gfx::RectF root_damage = 121 gfx::RectF root_damage =
120 root_surface->damage_tracker()->current_damage_rect(); 122 root_surface->damage_tracker()->current_damage_rect();
121 123
122 switch (draw_count_) { 124 switch (draw_count_) {
123 case 0: 125 case 0:
124 // The first frame has full damage. 126 // The first frame has full damage.
125 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString()); 127 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString());
126 break; 128 break;
127 case 1: 129 case 1:
128 // The second frame has full damage. 130 // The second frame has full damage.
129 EXPECT_EQ(gfx::RectF(15.f, 15.f).ToString(), root_damage.ToString()); 131 EXPECT_EQ(gfx::RectF(15.f, 15.f).ToString(), root_damage.ToString());
130 EndTest(); 132 EndTest();
131 break; 133 break;
132 case 2: 134 case 2:
133 NOTREACHED(); 135 NOTREACHED();
134 } 136 }
135 137
136 ++draw_count_; 138 ++draw_count_;
137 return result; 139 return draw_result;
138 } 140 }
139 141
140 virtual void AfterTest() OVERRIDE {} 142 virtual void AfterTest() OVERRIDE {}
141 143
142 int draw_count_; 144 int draw_count_;
143 FakeContentLayerClient client_; 145 FakeContentLayerClient client_;
144 }; 146 };
145 147
146 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestSetViewportSize); 148 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestSetViewportSize);
147 149
(...skipping 12 matching lines...) Expand all
160 162
161 // Most of the layer isn't visible. 163 // Most of the layer isn't visible.
162 content_ = FakeContentLayer::Create(&client_); 164 content_ = FakeContentLayer::Create(&client_);
163 content_->SetBounds(gfx::Size(2000, 100)); 165 content_->SetBounds(gfx::Size(2000, 100));
164 root->AddChild(content_); 166 root->AddChild(content_);
165 167
166 layer_tree_host()->SetRootLayer(root); 168 layer_tree_host()->SetRootLayer(root);
167 LayerTreeHostDamageTest::SetupTree(); 169 LayerTreeHostDamageTest::SetupTree();
168 } 170 }
169 171
170 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 172 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
171 LayerTreeHostImpl::FrameData* frame_data, 173 LayerTreeHostImpl* host_impl,
172 bool result) OVERRIDE { 174 LayerTreeHostImpl::FrameData* frame_data,
173 EXPECT_TRUE(result); 175 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
176 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
174 177
175 int source_frame = host_impl->active_tree()->source_frame_number(); 178 int source_frame = host_impl->active_tree()->source_frame_number();
176 switch (source_frame) { 179 switch (source_frame) {
177 case 0: 180 case 0:
178 // The first frame has damage, so we should draw and swap. 181 // The first frame has damage, so we should draw and swap.
179 ++expect_swap_and_succeed_; 182 ++expect_swap_and_succeed_;
180 break; 183 break;
181 case 1: 184 case 1:
182 // The second frame has no damage, so we should not draw and swap. 185 // The second frame has no damage, so we should not draw and swap.
183 break; 186 break;
184 case 2: 187 case 2:
185 // The third frame has damage again, so we should draw and swap. 188 // The third frame has damage again, so we should draw and swap.
186 ++expect_swap_and_succeed_; 189 ++expect_swap_and_succeed_;
187 break; 190 break;
188 case 3: 191 case 3:
189 // The fourth frame has no visible damage, so we should not draw and 192 // The fourth frame has no visible damage, so we should not draw and
190 // swap. 193 // swap.
191 EndTest(); 194 EndTest();
192 break; 195 break;
193 } 196 }
194 return result; 197 return draw_result;
195 } 198 }
196 199
197 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 200 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
198 bool result) OVERRIDE { 201 bool result) OVERRIDE {
199 ++did_swaps_; 202 ++did_swaps_;
200 if (result) 203 if (result)
201 ++did_swap_and_succeed_; 204 ++did_swap_and_succeed_;
202 EXPECT_EQ(expect_swap_and_succeed_, did_swap_and_succeed_); 205 EXPECT_EQ(expect_swap_and_succeed_, did_swap_and_succeed_);
203 } 206 }
204 207
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 252
250 // Most of the layer isn't visible. 253 // Most of the layer isn't visible.
251 content_ = FakeContentLayer::Create(&client_); 254 content_ = FakeContentLayer::Create(&client_);
252 content_->SetBounds(gfx::Size(100, 100)); 255 content_->SetBounds(gfx::Size(100, 100));
253 root->AddChild(content_); 256 root->AddChild(content_);
254 257
255 layer_tree_host()->SetRootLayer(root); 258 layer_tree_host()->SetRootLayer(root);
256 LayerTreeHostDamageTest::SetupTree(); 259 LayerTreeHostDamageTest::SetupTree();
257 } 260 }
258 261
259 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 262 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
260 LayerTreeHostImpl::FrameData* frame_data, 263 LayerTreeHostImpl* host_impl,
261 bool result) OVERRIDE { 264 LayerTreeHostImpl::FrameData* frame_data,
262 EXPECT_TRUE(result); 265 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
266 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
263 267
264 int source_frame = host_impl->active_tree()->source_frame_number(); 268 int source_frame = host_impl->active_tree()->source_frame_number();
265 switch (source_frame) { 269 switch (source_frame) {
266 case 0: 270 case 0:
267 // The first frame draws and clears any damage. 271 // The first frame draws and clears any damage.
268 break; 272 break;
269 case 1: { 273 case 1: {
270 // The second frame is a readback, we should have damage in the readback 274 // The second frame is a readback, we should have damage in the readback
271 // rect, but not swap. 275 // rect, but not swap.
272 RenderSurfaceImpl* root_surface = 276 RenderSurfaceImpl* root_surface =
273 host_impl->active_tree()->root_layer()->render_surface(); 277 host_impl->active_tree()->root_layer()->render_surface();
274 gfx::RectF root_damage = 278 gfx::RectF root_damage =
275 root_surface->damage_tracker()->current_damage_rect(); 279 root_surface->damage_tracker()->current_damage_rect();
276 root_damage.Intersect(root_surface->content_rect()); 280 root_damage.Intersect(root_surface->content_rect());
277 EXPECT_TRUE(root_damage.Contains(gfx::Rect(3, 3, 1, 1))); 281 EXPECT_TRUE(root_damage.Contains(gfx::Rect(3, 3, 1, 1)));
278 break; 282 break;
279 } 283 }
280 case 2: 284 case 2:
281 // CompositeAndReadback causes a follow-up commit. 285 // CompositeAndReadback causes a follow-up commit.
282 break; 286 break;
283 case 3: 287 case 3:
284 NOTREACHED(); 288 NOTREACHED();
285 break; 289 break;
286 } 290 }
287 return result; 291 return draw_result;
288 } 292 }
289 293
290 virtual void DidCommitAndDrawFrame() OVERRIDE { 294 virtual void DidCommitAndDrawFrame() OVERRIDE {
291 int next_frame = layer_tree_host()->source_frame_number(); 295 int next_frame = layer_tree_host()->source_frame_number();
292 switch (next_frame) { 296 switch (next_frame) {
293 case 1: { 297 case 1: {
294 char pixels[4]; 298 char pixels[4];
295 layer_tree_host()->CompositeAndReadback(static_cast<void*>(&pixels), 299 layer_tree_host()->CompositeAndReadback(static_cast<void*>(&pixels),
296 gfx::Rect(3, 3, 1, 1)); 300 gfx::Rect(3, 3, 1, 1));
297 EndTest(); 301 EndTest();
(...skipping 21 matching lines...) Expand all
319 323
320 root_->SetBounds(gfx::Size(500, 500)); 324 root_->SetBounds(gfx::Size(500, 500));
321 child_->SetPosition(gfx::Point(100, 100)); 325 child_->SetPosition(gfx::Point(100, 100));
322 child_->SetBounds(gfx::Size(30, 30)); 326 child_->SetBounds(gfx::Size(30, 30));
323 327
324 root_->AddChild(child_); 328 root_->AddChild(child_);
325 layer_tree_host()->SetRootLayer(root_); 329 layer_tree_host()->SetRootLayer(root_);
326 LayerTreeHostDamageTest::SetupTree(); 330 LayerTreeHostDamageTest::SetupTree();
327 } 331 }
328 332
329 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 333 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
330 LayerTreeHostImpl::FrameData* frame_data, 334 LayerTreeHostImpl* host_impl,
331 bool result) OVERRIDE { 335 LayerTreeHostImpl::FrameData* frame_data,
332 EXPECT_TRUE(result); 336 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
337 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
333 338
334 RenderSurfaceImpl* root_surface = 339 RenderSurfaceImpl* root_surface =
335 host_impl->active_tree()->root_layer()->render_surface(); 340 host_impl->active_tree()->root_layer()->render_surface();
336 gfx::RectF root_damage = 341 gfx::RectF root_damage =
337 root_surface->damage_tracker()->current_damage_rect(); 342 root_surface->damage_tracker()->current_damage_rect();
338 root_damage.Intersect(root_surface->content_rect()); 343 root_damage.Intersect(root_surface->content_rect());
339 344
340 int source_frame = host_impl->active_tree()->source_frame_number(); 345 int source_frame = host_impl->active_tree()->source_frame_number();
341 switch (source_frame) { 346 switch (source_frame) {
342 case 0: 347 case 0:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 break; 396 break;
392 case 4: 397 case 4:
393 // The whole frame is damaged. 398 // The whole frame is damaged.
394 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(), 399 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(),
395 root_damage.ToString()); 400 root_damage.ToString());
396 EXPECT_FALSE(frame_data->has_no_damage); 401 EXPECT_FALSE(frame_data->has_no_damage);
397 402
398 EndTest(); 403 EndTest();
399 break; 404 break;
400 } 405 }
401 return result; 406 return draw_result;
402 } 407 }
403 408
404 virtual void DidCommitAndDrawFrame() OVERRIDE { 409 virtual void DidCommitAndDrawFrame() OVERRIDE {
405 if (!TestEnded()) 410 if (!TestEnded())
406 layer_tree_host()->SetNeedsCommit(); 411 layer_tree_host()->SetNeedsCommit();
407 412
408 if (!child_damage_rect_.IsEmpty()) { 413 if (!child_damage_rect_.IsEmpty()) {
409 child_->SetNeedsDisplayRect(child_damage_rect_); 414 child_->SetNeedsDisplayRect(child_damage_rect_);
410 child_damage_rect_ = gfx::RectF(); 415 child_damage_rect_ = gfx::RectF();
411 } 416 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 FakeContentLayerClient client_; 459 FakeContentLayerClient client_;
455 }; 460 };
456 461
457 class LayerTreeHostDamageTestScrollbarDoesDamage 462 class LayerTreeHostDamageTestScrollbarDoesDamage
458 : public LayerTreeHostScrollbarDamageTest { 463 : public LayerTreeHostScrollbarDamageTest {
459 virtual void BeginTest() OVERRIDE { 464 virtual void BeginTest() OVERRIDE {
460 did_swaps_ = 0; 465 did_swaps_ = 0;
461 PostSetNeedsCommitToMainThread(); 466 PostSetNeedsCommitToMainThread();
462 } 467 }
463 468
464 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 469 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
465 LayerTreeHostImpl::FrameData* frame_data, 470 LayerTreeHostImpl* host_impl,
466 bool result) OVERRIDE { 471 LayerTreeHostImpl::FrameData* frame_data,
467 EXPECT_TRUE(result); 472 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
473 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
468 RenderSurfaceImpl* root_surface = 474 RenderSurfaceImpl* root_surface =
469 host_impl->active_tree()->root_layer()->render_surface(); 475 host_impl->active_tree()->root_layer()->render_surface();
470 gfx::RectF root_damage = 476 gfx::RectF root_damage =
471 root_surface->damage_tracker()->current_damage_rect(); 477 root_surface->damage_tracker()->current_damage_rect();
472 root_damage.Intersect(root_surface->content_rect()); 478 root_damage.Intersect(root_surface->content_rect());
473 switch (did_swaps_) { 479 switch (did_swaps_) {
474 case 0: 480 case 0:
475 // The first frame has damage, so we should draw and swap. 481 // The first frame has damage, so we should draw and swap.
476 break; 482 break;
477 case 1: 483 case 1:
478 // The second frame should not damage the scrollbars. 484 // The second frame should not damage the scrollbars.
479 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100))); 485 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100)));
480 break; 486 break;
481 case 2: 487 case 2:
482 // The third frame should damage the scrollbars. 488 // The third frame should damage the scrollbars.
483 EXPECT_TRUE(root_damage.Contains(gfx::Rect(300, 300, 10, 100))); 489 EXPECT_TRUE(root_damage.Contains(gfx::Rect(300, 300, 10, 100)));
484 break; 490 break;
485 case 3: 491 case 3:
486 // The fourth frame should damage the scrollbars. 492 // The fourth frame should damage the scrollbars.
487 EXPECT_TRUE(root_damage.Contains(gfx::Rect(300, 300, 10, 100))); 493 EXPECT_TRUE(root_damage.Contains(gfx::Rect(300, 300, 10, 100)));
488 EndTest(); 494 EndTest();
489 break; 495 break;
490 } 496 }
491 return result; 497 return draw_result;
492 } 498 }
493 499
494 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 500 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
495 bool result) OVERRIDE { 501 bool result) OVERRIDE {
496 ++did_swaps_; 502 ++did_swaps_;
497 EXPECT_TRUE(result); 503 EXPECT_TRUE(result);
498 LayerImpl* root = host_impl->active_tree()->root_layer(); 504 LayerImpl* root = host_impl->active_tree()->root_layer();
499 LayerImpl* scroll_layer = root->children()[0]; 505 LayerImpl* scroll_layer = root->children()[0];
500 switch (did_swaps_) { 506 switch (did_swaps_) {
501 case 1: 507 case 1:
(...skipping 23 matching lines...) Expand all
525 531
526 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarDoesDamage); 532 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarDoesDamage);
527 533
528 class LayerTreeHostDamageTestScrollbarCommitDoesNoDamage 534 class LayerTreeHostDamageTestScrollbarCommitDoesNoDamage
529 : public LayerTreeHostScrollbarDamageTest { 535 : public LayerTreeHostScrollbarDamageTest {
530 virtual void BeginTest() OVERRIDE { 536 virtual void BeginTest() OVERRIDE {
531 did_swaps_ = 0; 537 did_swaps_ = 0;
532 PostSetNeedsCommitToMainThread(); 538 PostSetNeedsCommitToMainThread();
533 } 539 }
534 540
535 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 541 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
536 LayerTreeHostImpl::FrameData* frame_data, 542 LayerTreeHostImpl* host_impl,
537 bool result) OVERRIDE { 543 LayerTreeHostImpl::FrameData* frame_data,
538 EXPECT_TRUE(result); 544 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
545 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
539 RenderSurfaceImpl* root_surface = 546 RenderSurfaceImpl* root_surface =
540 host_impl->active_tree()->root_layer()->render_surface(); 547 host_impl->active_tree()->root_layer()->render_surface();
541 gfx::RectF root_damage = 548 gfx::RectF root_damage =
542 root_surface->damage_tracker()->current_damage_rect(); 549 root_surface->damage_tracker()->current_damage_rect();
543 root_damage.Intersect(root_surface->content_rect()); 550 root_damage.Intersect(root_surface->content_rect());
544 int frame = host_impl->active_tree()->source_frame_number(); 551 int frame = host_impl->active_tree()->source_frame_number();
545 switch (did_swaps_) { 552 switch (did_swaps_) {
546 case 0: 553 case 0:
547 // The first frame has damage, so we should draw and swap. 554 // The first frame has damage, so we should draw and swap.
548 EXPECT_EQ(0, frame); 555 EXPECT_EQ(0, frame);
549 break; 556 break;
550 case 1: 557 case 1:
551 // The second frame has scrolled, so the scrollbar should be damaged. 558 // The second frame has scrolled, so the scrollbar should be damaged.
552 EXPECT_EQ(0, frame); 559 EXPECT_EQ(0, frame);
553 EXPECT_TRUE(root_damage.Contains(gfx::Rect(300, 300, 10, 100))); 560 EXPECT_TRUE(root_damage.Contains(gfx::Rect(300, 300, 10, 100)));
554 break; 561 break;
555 case 2: 562 case 2:
556 // The third frame (after the commit) has no changes, so it shouldn't. 563 // The third frame (after the commit) has no changes, so it shouldn't.
557 EXPECT_EQ(1, frame); 564 EXPECT_EQ(1, frame);
558 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100))); 565 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100)));
559 break; 566 break;
560 default: 567 default:
561 NOTREACHED(); 568 NOTREACHED();
562 break; 569 break;
563 } 570 }
564 return result; 571 return draw_result;
565 } 572 }
566 573
567 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 574 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
568 bool result) OVERRIDE { 575 bool result) OVERRIDE {
569 ++did_swaps_; 576 ++did_swaps_;
570 EXPECT_TRUE(result); 577 EXPECT_TRUE(result);
571 LayerImpl* root = host_impl->active_tree()->root_layer(); 578 LayerImpl* root = host_impl->active_tree()->root_layer();
572 LayerImpl* scroll_layer = root->children()[0]; 579 LayerImpl* scroll_layer = root->children()[0];
573 switch (did_swaps_) { 580 switch (did_swaps_) {
574 case 1: 581 case 1:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 scoped_refptr<FakePictureLayer> root = FakePictureLayer::Create(&client_); 622 scoped_refptr<FakePictureLayer> root = FakePictureLayer::Create(&client_);
616 root->SetBounds(gfx::Size(500, 500)); 623 root->SetBounds(gfx::Size(500, 500));
617 layer_tree_host()->SetRootLayer(root); 624 layer_tree_host()->SetRootLayer(root);
618 LayerTreeHostDamageTest::SetupTree(); 625 LayerTreeHostDamageTest::SetupTree();
619 626
620 swap_count_ = 0; 627 swap_count_ = 0;
621 prepare_to_draw_count_ = 0; 628 prepare_to_draw_count_ = 0;
622 update_visible_tile_count_ = 0; 629 update_visible_tile_count_ = 0;
623 } 630 }
624 631
625 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 632 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
626 LayerTreeHostImpl::FrameData* frame_data, 633 LayerTreeHostImpl* host_impl,
627 bool result) OVERRIDE { 634 LayerTreeHostImpl::FrameData* frame_data,
628 EXPECT_TRUE(result); 635 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
636 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
629 prepare_to_draw_count_++; 637 prepare_to_draw_count_++;
630 switch (prepare_to_draw_count_) { 638 switch (prepare_to_draw_count_) {
631 case 1: 639 case 1:
632 // Detect that we have an incomplete tile, during the first frame. 640 // Detect that we have an incomplete tile, during the first frame.
633 // The first frame should have damage. 641 // The first frame should have damage.
634 frame_data->contains_incomplete_tile = true; 642 frame_data->contains_incomplete_tile = true;
635 DCHECK(!frame_data->has_no_damage); 643 DCHECK(!frame_data->has_no_damage);
636 break; 644 break;
637 case 2: 645 case 2:
638 // Make a no-damage frame. We early out and can't detect 646 // Make a no-damage frame. We early out and can't detect
639 // incomplete tiles, even if they still exist. 647 // incomplete tiles, even if they still exist.
640 frame_data->contains_incomplete_tile = false; 648 frame_data->contains_incomplete_tile = false;
641 frame_data->has_no_damage = true; 649 frame_data->has_no_damage = true;
642 break; 650 break;
643 case 3: 651 case 3:
644 // Trigger the last swap for the completed tile. 652 // Trigger the last swap for the completed tile.
645 frame_data->contains_incomplete_tile = false; 653 frame_data->contains_incomplete_tile = false;
646 frame_data->has_no_damage = false; 654 frame_data->has_no_damage = false;
647 EndTest(); 655 EndTest();
648 break; 656 break;
649 default: 657 default:
650 NOTREACHED(); 658 NOTREACHED();
651 break; 659 break;
652 } 660 }
653 661
654 return result; 662 return draw_result;
655 } 663 }
656 664
657 virtual void UpdateVisibleTilesOnThread( 665 virtual void UpdateVisibleTilesOnThread(
658 LayerTreeHostImpl* host_impl) OVERRIDE { 666 LayerTreeHostImpl* host_impl) OVERRIDE {
659 // Simulate creating some visible tiles (that trigger prepare-to-draws). 667 // Simulate creating some visible tiles (that trigger prepare-to-draws).
660 // The first we make into a no-damage-frame during prepare-to-draw (see 668 // The first we make into a no-damage-frame during prepare-to-draw (see
661 // above). This is to ensure we still get UpdateVisibleTiles calls after 669 // above). This is to ensure we still get UpdateVisibleTiles calls after
662 // a no-damage or aborted frame. 670 // a no-damage or aborted frame.
663 update_visible_tile_count_++; 671 update_visible_tile_count_++;
664 switch (update_visible_tile_count_) { 672 switch (update_visible_tile_count_) {
(...skipping 27 matching lines...) Expand all
692 FakeContentLayerClient client_; 700 FakeContentLayerClient client_;
693 int swap_count_; 701 int swap_count_;
694 int prepare_to_draw_count_; 702 int prepare_to_draw_count_;
695 int update_visible_tile_count_; 703 int update_visible_tile_count_;
696 }; 704 };
697 705
698 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); 706 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws);
699 707
700 } // namespace 708 } // namespace
701 } // namespace cc 709 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698