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

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: Fix for empty viewport 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
« no previous file with comments | « no previous file | cc/resources/picture_layer_tiling_unittest.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/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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (recycled_twin) 522 if (recycled_twin)
523 recycled_twin->RemoveTileAt(it->first.first, it->first.second, nullptr); 523 recycled_twin->RemoveTileAt(it->first.first, it->first.second, nullptr);
524 } 524 }
525 tiles_.clear(); 525 tiles_.clear();
526 } 526 }
527 527
528 gfx::Rect PictureLayerTiling::ComputeSkewport( 528 gfx::Rect PictureLayerTiling::ComputeSkewport(
529 double current_frame_time_in_seconds, 529 double current_frame_time_in_seconds,
530 const gfx::Rect& visible_rect_in_content_space) const { 530 const gfx::Rect& visible_rect_in_content_space) const {
531 gfx::Rect skewport = visible_rect_in_content_space; 531 gfx::Rect skewport = visible_rect_in_content_space;
532 if (skewport.IsEmpty())
533 return skewport;
534
532 if (visible_rect_history_[1].frame_time_in_seconds == 0.0) 535 if (visible_rect_history_[1].frame_time_in_seconds == 0.0)
533 return skewport; 536 return skewport;
534 537
535 double time_delta = current_frame_time_in_seconds - 538 double time_delta = current_frame_time_in_seconds -
536 visible_rect_history_[1].frame_time_in_seconds; 539 visible_rect_history_[1].frame_time_in_seconds;
537 if (time_delta == 0.0) 540 if (time_delta == 0.0)
538 return skewport; 541 return skewport;
539 542
540 double extrapolation_multiplier = 543 double extrapolation_multiplier =
541 skewport_target_time_in_seconds_ / time_delta; 544 skewport_target_time_in_seconds_ / time_delta;
(...skipping 15 matching lines...) Expand all
557 gfx::Rect max_skewport = skewport; 560 gfx::Rect max_skewport = skewport;
558 max_skewport.Inset(-skewport_extrapolation_limit_in_content_pixels_, 561 max_skewport.Inset(-skewport_extrapolation_limit_in_content_pixels_,
559 -skewport_extrapolation_limit_in_content_pixels_); 562 -skewport_extrapolation_limit_in_content_pixels_);
560 563
561 // Inset the skewport by the needed adjustment. 564 // Inset the skewport by the needed adjustment.
562 skewport.Inset(extrapolation_multiplier * (new_x - old_x), 565 skewport.Inset(extrapolation_multiplier * (new_x - old_x),
563 extrapolation_multiplier * (new_y - old_y), 566 extrapolation_multiplier * (new_y - old_y),
564 extrapolation_multiplier * (old_right - new_right), 567 extrapolation_multiplier * (old_right - new_right),
565 extrapolation_multiplier * (old_bottom - new_bottom)); 568 extrapolation_multiplier * (old_bottom - new_bottom));
566 569
567 // Clip the skewport to |max_skewport|. 570 // Ensure that visible rect is contained in the skewport.
571 skewport.Union(visible_rect_in_content_space);
572
573 // Clip the skewport to |max_skewport|. This needs to happen after the
574 // union in case intersecting would have left the empty rect.
568 skewport.Intersect(max_skewport); 575 skewport.Intersect(max_skewport);
569 576
570 // Finally, ensure that visible rect is contained in the skewport.
571 skewport.Union(visible_rect_in_content_space);
572 return skewport; 577 return skewport;
573 } 578 }
574 579
575 bool PictureLayerTiling::ComputeTilePriorityRects( 580 bool PictureLayerTiling::ComputeTilePriorityRects(
576 const gfx::Rect& viewport_in_layer_space, 581 const gfx::Rect& viewport_in_layer_space,
577 float ideal_contents_scale, 582 float ideal_contents_scale,
578 double current_frame_time_in_seconds, 583 double current_frame_time_in_seconds,
579 const Occlusion& occlusion_in_layer_space) { 584 const Occlusion& occlusion_in_layer_space) {
580 if (!NeedsUpdateForFrameAtTimeAndViewport(current_frame_time_in_seconds, 585 if (!NeedsUpdateForFrameAtTimeAndViewport(current_frame_time_in_seconds,
581 viewport_in_layer_space)) { 586 viewport_in_layer_space)) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 break; 1046 break;
1042 } 1047 }
1043 1048
1044 gfx::Rect result(origin_x, origin_y, width, height); 1049 gfx::Rect result(origin_x, origin_y, width, height);
1045 if (cache) 1050 if (cache)
1046 cache->previous_result = result; 1051 cache->previous_result = result;
1047 return result; 1052 return result;
1048 } 1053 }
1049 1054
1050 } // namespace cc 1055 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/picture_layer_tiling_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698