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

Side by Side Diff: cc/resources/picture_layer_tiling.cc

Issue 13895005: cc: Find a better prioritized rect when the viewport rect is huge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: early out restored Created 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_set.h » ('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/resources/picture_layer_tiling.h" 5 #include "cc/resources/picture_layer_tiling.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 335 }
336 336
337 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const { 337 gfx::Size PictureLayerTiling::CoverageIterator::texture_size() const {
338 return tiling_->tiling_data_.max_texture_size(); 338 return tiling_->tiling_data_.max_texture_size();
339 } 339 }
340 340
341 void PictureLayerTiling::UpdateTilePriorities( 341 void PictureLayerTiling::UpdateTilePriorities(
342 WhichTree tree, 342 WhichTree tree,
343 gfx::Size device_viewport, 343 gfx::Size device_viewport,
344 const gfx::RectF& viewport_in_layer_space, 344 const gfx::RectF& viewport_in_layer_space,
345 const gfx::RectF& visible_layer_rect,
345 gfx::Size last_layer_bounds, 346 gfx::Size last_layer_bounds,
346 gfx::Size current_layer_bounds, 347 gfx::Size current_layer_bounds,
347 float last_layer_contents_scale, 348 float last_layer_contents_scale,
348 float current_layer_contents_scale, 349 float current_layer_contents_scale,
349 const gfx::Transform& last_screen_transform, 350 const gfx::Transform& last_screen_transform,
350 const gfx::Transform& current_screen_transform, 351 const gfx::Transform& current_screen_transform,
351 int current_source_frame_number, 352 int current_source_frame_number,
352 double current_frame_time, 353 double current_frame_time,
353 bool store_screen_space_quads_on_tiles, 354 bool store_screen_space_quads_on_tiles,
354 size_t max_tiles_for_interest_area) { 355 size_t max_tiles_for_interest_area) {
(...skipping 16 matching lines...) Expand all
371 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame) 372 if (!first_update_in_new_impl_frame && !first_update_in_new_source_frame)
372 return; 373 return;
373 374
374 double time_delta = 0; 375 double time_delta = 0;
375 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds) 376 if (last_impl_frame_time_ != 0 && last_layer_bounds == current_layer_bounds)
376 time_delta = current_frame_time - last_impl_frame_time_; 377 time_delta = current_frame_time - last_impl_frame_time_;
377 378
378 gfx::Rect viewport_in_content_space = 379 gfx::Rect viewport_in_content_space =
379 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space, 380 gfx::ToEnclosingRect(gfx::ScaleRect(viewport_in_layer_space,
380 contents_scale_)); 381 contents_scale_));
382 gfx::Rect visible_content_rect =
383 gfx::ToEnclosingRect(gfx::ScaleRect(visible_layer_rect,
384 contents_scale_));
381 385
382 gfx::Size tile_size = tiling_data_.max_texture_size(); 386 gfx::Size tile_size = tiling_data_.max_texture_size();
383 int64 prioritized_rect_area = 387 int64 prioritized_rect_area =
384 max_tiles_for_interest_area * 388 max_tiles_for_interest_area *
385 tile_size.width() * tile_size.height(); 389 tile_size.width() * tile_size.height();
386 390
391 gfx::Rect starting_rect = visible_content_rect.IsEmpty()
392 ? viewport_in_content_space
393 : visible_content_rect;
387 gfx::Rect prioritized_rect = ExpandRectEquallyToAreaBoundedBy( 394 gfx::Rect prioritized_rect = ExpandRectEquallyToAreaBoundedBy(
388 viewport_in_content_space, 395 starting_rect,
389 prioritized_rect_area, 396 prioritized_rect_area,
390 ContentRect()); 397 ContentRect());
391 DCHECK(ContentRect().Contains(prioritized_rect)); 398 DCHECK(ContentRect().Contains(prioritized_rect));
392 399
393 // Iterate through all of the tiles that were live last frame but will 400 // Iterate through all of the tiles that were live last frame but will
394 // not be live this frame, and mark them as being dead. 401 // not be live this frame, and mark them as being dead.
395 for (TilingData::DifferenceIterator iter(&tiling_data_, 402 for (TilingData::DifferenceIterator iter(&tiling_data_,
396 last_prioritized_rect_, 403 last_prioritized_rect_,
397 prioritized_rect); 404 prioritized_rect);
398 iter; 405 iter;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( 565 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy(
559 gfx::Rect starting_rect, 566 gfx::Rect starting_rect,
560 int64 target_area, 567 int64 target_area,
561 gfx::Rect bounding_rect) { 568 gfx::Rect bounding_rect) {
562 if (starting_rect.IsEmpty()) 569 if (starting_rect.IsEmpty())
563 return starting_rect; 570 return starting_rect;
564 571
565 DCHECK(!bounding_rect.IsEmpty()); 572 DCHECK(!bounding_rect.IsEmpty());
566 DCHECK_GT(target_area, 0); 573 DCHECK_GT(target_area, 0);
567 574
568 // Expand the starting rect to cover target_area. 575 // Expand the starting rect to cover target_area, if it is smaller than it.
569 int delta = ComputeExpansionDelta( 576 int delta = ComputeExpansionDelta(
570 2, 2, starting_rect.width(), starting_rect.height(), target_area); 577 2, 2, starting_rect.width(), starting_rect.height(), target_area);
571 gfx::Rect expanded_starting_rect = starting_rect; 578 gfx::Rect expanded_starting_rect = starting_rect;
572 expanded_starting_rect.Inset(-delta, -delta); 579 if (delta > 0)
580 expanded_starting_rect.Inset(-delta, -delta);
573 581
574 gfx::Rect rect = IntersectRects(expanded_starting_rect, bounding_rect); 582 gfx::Rect rect = IntersectRects(expanded_starting_rect, bounding_rect);
575 if (rect.IsEmpty()) { 583 if (rect.IsEmpty()) {
576 // The starting_rect and bounding_rect are far away. 584 // The starting_rect and bounding_rect are far away.
577 return rect; 585 return rect;
578 } 586 }
579 if (rect == expanded_starting_rect) { 587 if (delta >= 0 && rect == expanded_starting_rect) {
580 // The expanded starting rect already covers target_area on bounding_rect. 588 // The starting rect already covers the entire bounding_rect and isn't too
589 // large for the target_area.
581 return rect; 590 return rect;
582 } 591 }
583 592
584 // Continue to expand rect to let it cover target_area. 593 // Continue to expand/shrink rect to let it cover target_area.
585 594
586 // These values will be updated by the loop and uses as the output. 595 // These values will be updated by the loop and uses as the output.
587 int origin_x = rect.x(); 596 int origin_x = rect.x();
588 int origin_y = rect.y(); 597 int origin_y = rect.y();
589 int width = rect.width(); 598 int width = rect.width();
590 int height = rect.height(); 599 int height = rect.height();
591 600
592 // In the beginning we will consider 2 edges in each dimension. 601 // In the beginning we will consider 2 edges in each dimension.
593 int num_y_edges = 2; 602 int num_y_edges = 2;
594 int num_x_edges = 2; 603 int num_x_edges = 2;
595 604
596 // Create an event list. 605 // Create an event list.
597 EdgeEvent events[] = { 606 EdgeEvent events[] = {
598 { EdgeEvent::BOTTOM, &num_y_edges, rect.y() - bounding_rect.y() }, 607 { EdgeEvent::BOTTOM, &num_y_edges, rect.y() - bounding_rect.y() },
599 { EdgeEvent::TOP, &num_y_edges, bounding_rect.bottom() - rect.bottom() }, 608 { EdgeEvent::TOP, &num_y_edges, bounding_rect.bottom() - rect.bottom() },
600 { EdgeEvent::LEFT, &num_x_edges, rect.x() - bounding_rect.x() }, 609 { EdgeEvent::LEFT, &num_x_edges, rect.x() - bounding_rect.x() },
601 { EdgeEvent::RIGHT, &num_x_edges, bounding_rect.right() - rect.right() } 610 { EdgeEvent::RIGHT, &num_x_edges, bounding_rect.right() - rect.right() }
602 }; 611 };
603 612
604 // Sort the events by distance (closest first). 613 // Sort the events by distance (closest first).
605 if (events[0].distance > events[1].distance) std::swap(events[0], events[1]); 614 if (events[0].distance > events[1].distance) std::swap(events[0], events[1]);
606 if (events[2].distance > events[3].distance) std::swap(events[2], events[3]); 615 if (events[2].distance > events[3].distance) std::swap(events[2], events[3]);
607 if (events[0].distance > events[2].distance) std::swap(events[0], events[2]); 616 if (events[0].distance > events[2].distance) std::swap(events[0], events[2]);
608 if (events[1].distance > events[3].distance) std::swap(events[1], events[3]); 617 if (events[1].distance > events[3].distance) std::swap(events[1], events[3]);
609 if (events[1].distance > events[2].distance) std::swap(events[1], events[2]); 618 if (events[1].distance > events[2].distance) std::swap(events[1], events[2]);
610 619
611 for (int event_index = 0; event_index < 4; event_index++) { 620 for (int event_index = 0; event_index < 4; event_index++) {
612 const EdgeEvent& event = events[event_index]; 621 const EdgeEvent& event = events[event_index];
613 622
614 // Early out if our distance to event is 0.
615 // This optimization is not required for correctness.
616 if (event.distance == 0) {
617 --*event.num_edges;
618 continue;
619 }
620
621 int delta = ComputeExpansionDelta( 623 int delta = ComputeExpansionDelta(
622 num_x_edges, num_y_edges, width, height, target_area); 624 num_x_edges, num_y_edges, width, height, target_area);
623 625
624 // Clamp delta to our event distance. 626 // Clamp delta to our event distance.
625 if (delta > event.distance) 627 if (delta > event.distance)
626 delta = event.distance; 628 delta = event.distance;
627 629
628 // Adjust the edge count for this kind of edge. 630 // Adjust the edge count for this kind of edge.
629 --*event.num_edges; 631 --*event.num_edges;
630 632
(...skipping 20 matching lines...) Expand all
651 653
652 // If our delta is less then our event distance, we're done. 654 // If our delta is less then our event distance, we're done.
653 if (delta < event.distance) 655 if (delta < event.distance)
654 break; 656 break;
655 } 657 }
656 658
657 return gfx::Rect(origin_x, origin_y, width, height); 659 return gfx::Rect(origin_x, origin_y, width, height);
658 } 660 }
659 661
660 } // namespace cc 662 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698