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

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

Issue 1314943008: cc: Remove implicit conversions from Rect to RectF in src/cc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rectfconvert-cc: rebase-and-sandwich-strategy Created 5 years, 3 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
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 } 49 }
50 50
51 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, 51 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl,
52 LayerTreeHostImpl::FrameData* frame_data, 52 LayerTreeHostImpl::FrameData* frame_data,
53 DrawResult draw_result) override { 53 DrawResult draw_result) override {
54 EXPECT_EQ(DRAW_SUCCESS, draw_result); 54 EXPECT_EQ(DRAW_SUCCESS, draw_result);
55 55
56 RenderSurfaceImpl* root_surface = 56 RenderSurfaceImpl* root_surface =
57 impl->active_tree()->root_layer()->render_surface(); 57 impl->active_tree()->root_layer()->render_surface();
58 gfx::RectF root_damage = 58 gfx::Rect root_damage =
59 root_surface->damage_tracker()->current_damage_rect(); 59 root_surface->damage_tracker()->current_damage_rect();
60 60
61 switch (draw_count_) { 61 switch (draw_count_) {
62 case 0: 62 case 0:
63 // The first frame has full damage. 63 // The first frame has full damage.
64 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString()); 64 EXPECT_EQ(gfx::Rect(10, 10), root_damage);
65 break; 65 break;
66 case 1: 66 case 1:
67 // The second frame has full damage. 67 // The second frame has full damage.
68 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString()); 68 EXPECT_EQ(gfx::Rect(10, 10), root_damage);
69 EndTest(); 69 EndTest();
70 break; 70 break;
71 case 2: 71 case 2:
72 NOTREACHED(); 72 NOTREACHED();
73 } 73 }
74 74
75 ++draw_count_; 75 ++draw_count_;
76 return draw_result; 76 return draw_result;
77 } 77 }
78 78
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 } 111 }
112 112
113 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, 113 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl,
114 LayerTreeHostImpl::FrameData* frame_data, 114 LayerTreeHostImpl::FrameData* frame_data,
115 DrawResult draw_result) override { 115 DrawResult draw_result) override {
116 EXPECT_EQ(DRAW_SUCCESS, draw_result); 116 EXPECT_EQ(DRAW_SUCCESS, draw_result);
117 117
118 RenderSurfaceImpl* root_surface = 118 RenderSurfaceImpl* root_surface =
119 impl->active_tree()->root_layer()->render_surface(); 119 impl->active_tree()->root_layer()->render_surface();
120 gfx::RectF root_damage = 120 gfx::Rect root_damage =
121 root_surface->damage_tracker()->current_damage_rect(); 121 root_surface->damage_tracker()->current_damage_rect();
122 122
123 switch (draw_count_) { 123 switch (draw_count_) {
124 case 0: 124 case 0:
125 // The first frame has full damage. 125 // The first frame has full damage.
126 EXPECT_EQ(gfx::RectF(10.f, 10.f).ToString(), root_damage.ToString()); 126 EXPECT_EQ(gfx::Rect(10, 10), root_damage);
127 break; 127 break;
128 case 1: 128 case 1:
129 // The second frame has full damage. 129 // The second frame has full damage.
130 EXPECT_EQ(gfx::RectF(15.f, 15.f).ToString(), root_damage.ToString()); 130 EXPECT_EQ(gfx::Rect(15, 15), root_damage);
131 EndTest(); 131 EndTest();
132 break; 132 break;
133 case 2: 133 case 2:
134 NOTREACHED(); 134 NOTREACHED();
135 } 135 }
136 136
137 ++draw_count_; 137 ++draw_count_;
138 return draw_result; 138 return draw_result;
139 } 139 }
140 140
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 LayerTreeHostDamageTest::SetupTree(); 253 LayerTreeHostDamageTest::SetupTree();
254 } 254 }
255 255
256 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 256 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
257 LayerTreeHostImpl::FrameData* frame_data, 257 LayerTreeHostImpl::FrameData* frame_data,
258 DrawResult draw_result) override { 258 DrawResult draw_result) override {
259 EXPECT_EQ(DRAW_SUCCESS, draw_result); 259 EXPECT_EQ(DRAW_SUCCESS, draw_result);
260 260
261 RenderSurfaceImpl* root_surface = 261 RenderSurfaceImpl* root_surface =
262 host_impl->active_tree()->root_layer()->render_surface(); 262 host_impl->active_tree()->root_layer()->render_surface();
263 gfx::RectF root_damage = 263 gfx::Rect root_damage =
264 root_surface->damage_tracker()->current_damage_rect(); 264 root_surface->damage_tracker()->current_damage_rect();
265 root_damage.Intersect(root_surface->content_rect()); 265 root_damage.Intersect(root_surface->content_rect());
266 266
267 int source_frame = host_impl->active_tree()->source_frame_number(); 267 int source_frame = host_impl->active_tree()->source_frame_number();
268 switch (source_frame) { 268 switch (source_frame) {
269 case 0: 269 case 0:
270 // The first frame draws and clears any damage. 270 // The first frame draws and clears any damage.
271 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(), 271 EXPECT_EQ(root_surface->content_rect(), root_damage);
272 root_damage.ToString());
273 EXPECT_FALSE(frame_data->has_no_damage); 272 EXPECT_FALSE(frame_data->has_no_damage);
274 break; 273 break;
275 case 1: 274 case 1:
276 // If we get a frame without damage then we don't draw. 275 // If we get a frame without damage then we don't draw.
277 EXPECT_EQ(gfx::RectF().ToString(), root_damage.ToString()); 276 EXPECT_EQ(gfx::Rect(), root_damage);
278 EXPECT_TRUE(frame_data->has_no_damage); 277 EXPECT_TRUE(frame_data->has_no_damage);
279 278
280 // Then we set full damage for the next frame. 279 // Then we set full damage for the next frame.
281 host_impl->SetFullRootLayerDamage(); 280 host_impl->SetFullRootLayerDamage();
282 break; 281 break;
283 case 2: 282 case 2:
284 // The whole frame should be damaged as requested. 283 // The whole frame should be damaged as requested.
285 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(), 284 EXPECT_EQ(root_surface->content_rect(), root_damage);
286 root_damage.ToString());
287 EXPECT_FALSE(frame_data->has_no_damage); 285 EXPECT_FALSE(frame_data->has_no_damage);
288 286
289 // Just a part of the next frame should be damaged. 287 // Just a part of the next frame should be damaged.
290 child_damage_rect_ = gfx::Rect(10, 11, 12, 13); 288 child_damage_rect_ = gfx::Rect(10, 11, 12, 13);
291 break; 289 break;
292 case 3: 290 case 3:
293 // The update rect in the child should be damaged and the damaged area 291 // The update rect in the child should be damaged and the damaged area
294 // should match the invalidation. 292 // should match the invalidation.
295 EXPECT_EQ(gfx::RectF(100+10, 100+11, 12, 13).ToString(), 293 EXPECT_EQ(gfx::Rect(100 + 10, 100 + 11, 12, 13), root_damage);
296 root_damage.ToString());
297 EXPECT_FALSE(frame_data->has_no_damage); 294 EXPECT_FALSE(frame_data->has_no_damage);
298 295
299 // If we damage part of the frame, but also damage the full 296 // If we damage part of the frame, but also damage the full
300 // frame, then the whole frame should be damaged. 297 // frame, then the whole frame should be damaged.
301 child_damage_rect_ = gfx::Rect(10, 11, 12, 13); 298 child_damage_rect_ = gfx::Rect(10, 11, 12, 13);
302 host_impl->SetFullRootLayerDamage(); 299 host_impl->SetFullRootLayerDamage();
303 break; 300 break;
304 case 4: 301 case 4:
305 // The whole frame is damaged. 302 // The whole frame is damaged.
306 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(), 303 EXPECT_EQ(root_surface->content_rect(), root_damage);
307 root_damage.ToString());
308 EXPECT_FALSE(frame_data->has_no_damage); 304 EXPECT_FALSE(frame_data->has_no_damage);
309 305
310 EndTest(); 306 EndTest();
311 break; 307 break;
312 } 308 }
313 return draw_result; 309 return draw_result;
314 } 310 }
315 311
316 void DidCommitAndDrawFrame() override { 312 void DidCommitAndDrawFrame() override {
317 if (!TestEnded()) 313 if (!TestEnded())
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 did_swaps_ = 0; 376 did_swaps_ = 0;
381 PostSetNeedsCommitToMainThread(); 377 PostSetNeedsCommitToMainThread();
382 } 378 }
383 379
384 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 380 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
385 LayerTreeHostImpl::FrameData* frame_data, 381 LayerTreeHostImpl::FrameData* frame_data,
386 DrawResult draw_result) override { 382 DrawResult draw_result) override {
387 EXPECT_EQ(DRAW_SUCCESS, draw_result); 383 EXPECT_EQ(DRAW_SUCCESS, draw_result);
388 RenderSurfaceImpl* root_surface = 384 RenderSurfaceImpl* root_surface =
389 host_impl->active_tree()->root_layer()->render_surface(); 385 host_impl->active_tree()->root_layer()->render_surface();
390 gfx::RectF root_damage = 386 gfx::Rect root_damage =
391 root_surface->damage_tracker()->current_damage_rect(); 387 root_surface->damage_tracker()->current_damage_rect();
392 root_damage.Intersect(root_surface->content_rect()); 388 root_damage.Intersect(root_surface->content_rect());
393 switch (did_swaps_) { 389 switch (did_swaps_) {
394 case 0: 390 case 0:
395 // The first frame has damage, so we should draw and swap. 391 // The first frame has damage, so we should draw and swap.
396 break; 392 break;
397 case 1: 393 case 1:
398 // The second frame should not damage the scrollbars. 394 // The second frame should not damage the scrollbars.
399 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100))); 395 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100)));
400 break; 396 break;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 did_swaps_ = 0; 467 did_swaps_ = 0;
472 PostSetNeedsCommitToMainThread(); 468 PostSetNeedsCommitToMainThread();
473 } 469 }
474 470
475 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 471 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
476 LayerTreeHostImpl::FrameData* frame_data, 472 LayerTreeHostImpl::FrameData* frame_data,
477 DrawResult draw_result) override { 473 DrawResult draw_result) override {
478 EXPECT_EQ(DRAW_SUCCESS, draw_result); 474 EXPECT_EQ(DRAW_SUCCESS, draw_result);
479 RenderSurfaceImpl* root_surface = 475 RenderSurfaceImpl* root_surface =
480 host_impl->active_tree()->root_layer()->render_surface(); 476 host_impl->active_tree()->root_layer()->render_surface();
481 gfx::RectF root_damage = 477 gfx::Rect root_damage =
482 root_surface->damage_tracker()->current_damage_rect(); 478 root_surface->damage_tracker()->current_damage_rect();
483 root_damage.Intersect(root_surface->content_rect()); 479 root_damage.Intersect(root_surface->content_rect());
484 int frame = host_impl->active_tree()->source_frame_number(); 480 int frame = host_impl->active_tree()->source_frame_number();
485 switch (did_swaps_) { 481 switch (did_swaps_) {
486 case 0: 482 case 0:
487 // The first frame has damage, so we should draw and swap. 483 // The first frame has damage, so we should draw and swap.
488 EXPECT_EQ(0, frame); 484 EXPECT_EQ(0, frame);
489 break; 485 break;
490 case 1: 486 case 1:
491 // The second frame has scrolled, so the scrollbar should be damaged. 487 // The second frame has scrolled, so the scrollbar should be damaged.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 529
534 void AfterTest() override { EXPECT_EQ(3, did_swaps_); } 530 void AfterTest() override { EXPECT_EQ(3, did_swaps_); }
535 531
536 int did_swaps_; 532 int did_swaps_;
537 }; 533 };
538 534
539 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); 535 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage);
540 536
541 } // namespace 537 } // namespace
542 } // namespace cc 538 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_context.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