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

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

Issue 1021663002: cc: Fix skewport math (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/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 #include <limits> 9 #include <limits>
10 #include <set> 10 #include <set>
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 gfx::Rect max_skewport = skewport; 557 gfx::Rect max_skewport = skewport;
558 max_skewport.Inset(-skewport_extrapolation_limit_in_content_pixels_, 558 max_skewport.Inset(-skewport_extrapolation_limit_in_content_pixels_,
559 -skewport_extrapolation_limit_in_content_pixels_); 559 -skewport_extrapolation_limit_in_content_pixels_);
560 560
561 // Inset the skewport by the needed adjustment. 561 // Inset the skewport by the needed adjustment.
562 skewport.Inset(extrapolation_multiplier * (new_x - old_x), 562 skewport.Inset(extrapolation_multiplier * (new_x - old_x),
563 extrapolation_multiplier * (new_y - old_y), 563 extrapolation_multiplier * (new_y - old_y),
564 extrapolation_multiplier * (old_right - new_right), 564 extrapolation_multiplier * (old_right - new_right),
565 extrapolation_multiplier * (old_bottom - new_bottom)); 565 extrapolation_multiplier * (old_bottom - new_bottom));
566 566
567 // Clip the skewport to |max_skewport|. 567 // Ensure that visible rect is contained in the skewport.
568 skewport.Union(visible_rect_in_content_space);
569
570 // Clip the skewport to |max_skewport|. This needs to happen after the
571 // union in case intersecting would have left the empty rect.
568 skewport.Intersect(max_skewport); 572 skewport.Intersect(max_skewport);
569 573
570 // Finally, ensure that visible rect is contained in the skewport. 574 // The max_skewport should always contain the visible_rect_in_content_space
571 skewport.Union(visible_rect_in_content_space); 575 // so this should still be true.
576 DCHECK(skewport.Contains(visible_rect_in_content_space));
577
572 return skewport; 578 return skewport;
573 } 579 }
574 580
575 bool PictureLayerTiling::ComputeTilePriorityRects( 581 bool PictureLayerTiling::ComputeTilePriorityRects(
576 const gfx::Rect& viewport_in_layer_space, 582 const gfx::Rect& viewport_in_layer_space,
577 float ideal_contents_scale, 583 float ideal_contents_scale,
578 double current_frame_time_in_seconds, 584 double current_frame_time_in_seconds,
579 const Occlusion& occlusion_in_layer_space) { 585 const Occlusion& occlusion_in_layer_space) {
580 if (!NeedsUpdateForFrameAtTimeAndViewport(current_frame_time_in_seconds, 586 if (!NeedsUpdateForFrameAtTimeAndViewport(current_frame_time_in_seconds,
581 viewport_in_layer_space)) { 587 viewport_in_layer_space)) {
582 // This should never be zero for the purposes of has_ever_been_updated(). 588 // This should never be zero for the purposes of has_ever_been_updated().
583 DCHECK_NE(current_frame_time_in_seconds, 0.0); 589 DCHECK_NE(current_frame_time_in_seconds, 0.0);
584 return false; 590 return false;
585 } 591 }
586 592
587 gfx::Rect visible_rect_in_content_space = 593 gfx::Rect visible_rect_in_content_space =
588 gfx::ScaleToEnclosingRect(viewport_in_layer_space, contents_scale_); 594 gfx::ScaleToEnclosingRect(viewport_in_layer_space, contents_scale_);
589 595
590 if (tiling_size().IsEmpty()) { 596 if (tiling_size().IsEmpty()) {
591 UpdateVisibleRectHistory(current_frame_time_in_seconds, 597 UpdateVisibleRectHistory(current_frame_time_in_seconds,
592 visible_rect_in_content_space); 598 visible_rect_in_content_space);
593 last_viewport_in_layer_space_ = viewport_in_layer_space; 599 last_viewport_in_layer_space_ = viewport_in_layer_space;
594 return false; 600 return false;
595 } 601 }
596 602
597 // Calculate the skewport. 603 // Calculate the skewport.
598 gfx::Rect skewport = ComputeSkewport(current_frame_time_in_seconds, 604 gfx::Rect skewport = ComputeSkewport(current_frame_time_in_seconds,
599 visible_rect_in_content_space); 605 visible_rect_in_content_space);
600 DCHECK(skewport.Contains(visible_rect_in_content_space)); 606 DCHECK(skewport.Contains(visible_rect_in_content_space));
vmpstr 2015/03/18 23:11:51 <_<
601 607
602 // Calculate the eventually/live tiles rect. 608 // Calculate the eventually/live tiles rect.
603 gfx::Size tile_size = tiling_data_.max_texture_size(); 609 gfx::Size tile_size = tiling_data_.max_texture_size();
604 int64 eventually_rect_area = 610 int64 eventually_rect_area =
605 max_tiles_for_interest_area_ * tile_size.width() * tile_size.height(); 611 max_tiles_for_interest_area_ * tile_size.width() * tile_size.height();
606 612
607 gfx::Rect eventually_rect = 613 gfx::Rect eventually_rect =
608 ExpandRectEquallyToAreaBoundedBy(visible_rect_in_content_space, 614 ExpandRectEquallyToAreaBoundedBy(visible_rect_in_content_space,
609 eventually_rect_area, 615 eventually_rect_area,
610 gfx::Rect(tiling_size()), 616 gfx::Rect(tiling_size()),
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 break; 1047 break;
1042 } 1048 }
1043 1049
1044 gfx::Rect result(origin_x, origin_y, width, height); 1050 gfx::Rect result(origin_x, origin_y, width, height);
1045 if (cache) 1051 if (cache)
1046 cache->previous_result = result; 1052 cache->previous_result = result;
1047 return result; 1053 return result;
1048 } 1054 }
1049 1055
1050 } // namespace cc 1056 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/picture_layer_tiling_unittest.cc » ('j') | cc/resources/picture_layer_tiling_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698