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

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 819643004: Cache viewport rect for tile priority in UpdateTiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 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 | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 276 }
277 277
278 // Keep track of the tilings that were used so that tilings that are 278 // Keep track of the tilings that were used so that tilings that are
279 // unused can be considered for removal. 279 // unused can be considered for removal.
280 std::vector<PictureLayerTiling*> seen_tilings; 280 std::vector<PictureLayerTiling*> seen_tilings;
281 281
282 // Ignore missing tiles outside of viewport for tile priority. This is 282 // Ignore missing tiles outside of viewport for tile priority. This is
283 // normally the same as draw viewport but can be independently overridden by 283 // normally the same as draw viewport but can be independently overridden by
284 // embedders like Android WebView with SetExternalDrawConstraints. 284 // embedders like Android WebView with SetExternalDrawConstraints.
285 gfx::Rect scaled_viewport_for_tile_priority = gfx::ScaleToEnclosingRect( 285 gfx::Rect scaled_viewport_for_tile_priority = gfx::ScaleToEnclosingRect(
286 GetViewportForTilePriorityInContentSpace(), max_contents_scale); 286 viewport_rect_for_tile_priority_in_content_space_, max_contents_scale);
287 287
288 size_t missing_tile_count = 0u; 288 size_t missing_tile_count = 0u;
289 size_t on_demand_missing_tile_count = 0u; 289 size_t on_demand_missing_tile_count = 0u;
290 only_used_low_res_last_append_quads_ = true; 290 only_used_low_res_last_append_quads_ = true;
291 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), 291 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(),
292 max_contents_scale, 292 max_contents_scale,
293 scaled_visible_content_rect, 293 scaled_visible_content_rect,
294 ideal_contents_scale_); 294 ideal_contents_scale_);
295 iter; 295 iter;
296 ++iter) { 296 ++iter) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 return UpdateTilePriorities(occlusion_in_content_space); 467 return UpdateTilePriorities(occlusion_in_content_space);
468 } 468 }
469 469
470 bool PictureLayerImpl::UpdateTilePriorities( 470 bool PictureLayerImpl::UpdateTilePriorities(
471 const Occlusion& occlusion_in_content_space) { 471 const Occlusion& occlusion_in_content_space) {
472 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); 472 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0);
473 473
474 double current_frame_time_in_seconds = 474 double current_frame_time_in_seconds =
475 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - 475 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time -
476 base::TimeTicks()).InSecondsF(); 476 base::TimeTicks()).InSecondsF();
477 gfx::Rect viewport_rect_in_layer_space = 477 UpdateViewportRectForTilePriorityInContentSpace();
478 GetViewportForTilePriorityInContentSpace();
479 478
480 // The tiling set can require tiles for activation any of the following 479 // The tiling set can require tiles for activation any of the following
481 // conditions are true: 480 // conditions are true:
482 // - This layer produced a high-res or non-ideal-res tile last frame. 481 // - This layer produced a high-res or non-ideal-res tile last frame.
483 // - We're in requires high res to draw mode. 482 // - We're in requires high res to draw mode.
484 // - We're not in smoothness takes priority mode. 483 // - We're not in smoothness takes priority mode.
485 // To put different, the tiling set can't require tiles for activation if 484 // To put different, the tiling set can't require tiles for activation if
486 // we're in smoothness mode and only used low-res or checkerboard to draw last 485 // we're in smoothness mode and only used low-res or checkerboard to draw last
487 // frame and we don't need high res to draw. 486 // frame and we don't need high res to draw.
488 // 487 //
489 // The reason for this is that we should be able to activate sooner and get a 488 // The reason for this is that we should be able to activate sooner and get a
490 // more up to date recording, so we don't run out of recording on the active 489 // more up to date recording, so we don't run out of recording on the active
491 // tree. 490 // tree.
492 bool can_require_tiles_for_activation = 491 bool can_require_tiles_for_activation =
493 !only_used_low_res_last_append_quads_ || RequiresHighResToDraw() || 492 !only_used_low_res_last_append_quads_ || RequiresHighResToDraw() ||
494 !layer_tree_impl()->SmoothnessTakesPriority(); 493 !layer_tree_impl()->SmoothnessTakesPriority();
495 494
496 // Pass |occlusion_in_content_space| for |occlusion_in_layer_space| since 495 // Pass |occlusion_in_content_space| for |occlusion_in_layer_space| since
497 // they are the same space in picture layer, as contents scale is always 1. 496 // they are the same space in picture layer, as contents scale is always 1.
498 bool updated = tilings_->UpdateTilePriorities( 497 bool updated = tilings_->UpdateTilePriorities(
499 viewport_rect_in_layer_space, ideal_contents_scale_, 498 viewport_rect_for_tile_priority_in_content_space_, ideal_contents_scale_,
500 current_frame_time_in_seconds, occlusion_in_content_space, 499 current_frame_time_in_seconds, occlusion_in_content_space,
501 can_require_tiles_for_activation); 500 can_require_tiles_for_activation);
502 return updated; 501 return updated;
503 } 502 }
504 503
505 gfx::Rect PictureLayerImpl::GetViewportForTilePriorityInContentSpace() const { 504 void PictureLayerImpl::UpdateViewportRectForTilePriorityInContentSpace() {
506 // If visible_rect_for_tile_priority_ is empty or 505 // If visible_rect_for_tile_priority_ is empty or
507 // viewport_rect_for_tile_priority is set to be different from the device 506 // viewport_rect_for_tile_priority is set to be different from the device
508 // viewport, try to inverse project the viewport into layer space and use 507 // viewport, try to inverse project the viewport into layer space and use
509 // that. Otherwise just use visible_rect_for_tile_priority_ 508 // that. Otherwise just use visible_rect_for_tile_priority_
510 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_; 509 gfx::Rect visible_rect_in_content_space = visible_rect_for_tile_priority_;
511 gfx::Rect viewport_rect_for_tile_priority = 510 gfx::Rect viewport_rect_for_tile_priority =
512 layer_tree_impl()->ViewportRectForTilePriority(); 511 layer_tree_impl()->ViewportRectForTilePriority();
513
514 if (visible_rect_in_content_space.IsEmpty() || 512 if (visible_rect_in_content_space.IsEmpty() ||
515 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority) { 513 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority) {
516 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); 514 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization);
517 if (screen_space_transform().GetInverse(&view_to_layer)) { 515 if (screen_space_transform().GetInverse(&view_to_layer)) {
518 // Transform from view space to content space. 516 // Transform from view space to content space.
519 visible_rect_in_content_space = 517 visible_rect_in_content_space =
520 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( 518 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
521 view_to_layer, viewport_rect_for_tile_priority)); 519 view_to_layer, viewport_rect_for_tile_priority));
522 } 520 }
523 } 521 }
524 return visible_rect_in_content_space; 522 viewport_rect_for_tile_priority_in_content_space_ =
523 visible_rect_in_content_space;
525 } 524 }
526 525
527 PictureLayerImpl* PictureLayerImpl::GetPendingOrActiveTwinLayer() const { 526 PictureLayerImpl* PictureLayerImpl::GetPendingOrActiveTwinLayer() const {
528 if (!twin_layer_ || !twin_layer_->IsOnActiveOrPendingTree()) 527 if (!twin_layer_ || !twin_layer_->IsOnActiveOrPendingTree())
529 return nullptr; 528 return nullptr;
530 return twin_layer_; 529 return twin_layer_;
531 } 530 }
532 531
533 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { 532 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const {
534 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) 533 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree())
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 1172
1174 void PictureLayerImpl::AsValueInto(base::debug::TracedValue* state) const { 1173 void PictureLayerImpl::AsValueInto(base::debug::TracedValue* state) const {
1175 LayerImpl::AsValueInto(state); 1174 LayerImpl::AsValueInto(state);
1176 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 1175 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
1177 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); 1176 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale());
1178 state->BeginArray("tilings"); 1177 state->BeginArray("tilings");
1179 tilings_->AsValueInto(state); 1178 tilings_->AsValueInto(state);
1180 state->EndArray(); 1179 state->EndArray();
1181 1180
1182 MathUtil::AddToTracedValue("tile_priority_rect", 1181 MathUtil::AddToTracedValue("tile_priority_rect",
1183 GetViewportForTilePriorityInContentSpace(), state); 1182 viewport_rect_for_tile_priority_in_content_space_,
1184 1183 state);
1185 MathUtil::AddToTracedValue("visible_rect", visible_content_rect(), state); 1184 MathUtil::AddToTracedValue("visible_rect", visible_content_rect(), state);
1186 1185
1187 state->BeginArray("pictures"); 1186 state->BeginArray("pictures");
1188 raster_source_->AsValueInto(state); 1187 raster_source_->AsValueInto(state);
1189 state->EndArray(); 1188 state->EndArray();
1190 1189
1191 state->BeginArray("invalidation"); 1190 state->BeginArray("invalidation");
1192 invalidation_.AsValueInto(state); 1191 invalidation_.AsValueInto(state);
1193 state->EndArray(); 1192 state->EndArray();
1194 1193
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 TileRequirementCheck is_tile_required_callback) const { 1232 TileRequirementCheck is_tile_required_callback) const {
1234 if (!HasValidTilePriorities()) 1233 if (!HasValidTilePriorities())
1235 return true; 1234 return true;
1236 1235
1237 if (!tilings_) 1236 if (!tilings_)
1238 return true; 1237 return true;
1239 1238
1240 if (visible_rect_for_tile_priority_.IsEmpty()) 1239 if (visible_rect_for_tile_priority_.IsEmpty())
1241 return true; 1240 return true;
1242 1241
1243 gfx::Rect rect = GetViewportForTilePriorityInContentSpace(); 1242 gfx::Rect rect = viewport_rect_for_tile_priority_in_content_space_;
1244 rect.Intersect(visible_rect_for_tile_priority_); 1243 rect.Intersect(visible_rect_for_tile_priority_);
1245 1244
1246 // The high resolution tiling is the only tiling that can mark tiles as 1245 // The high resolution tiling is the only tiling that can mark tiles as
1247 // requiring either draw or activation. There is an explicit check in those 1246 // requiring either draw or activation. There is an explicit check in those
1248 // callbacks to return false if they are not high resolution tilings. This 1247 // callbacks to return false if they are not high resolution tilings. This
1249 // check needs to remain since there are other callers of that function that 1248 // check needs to remain since there are other callers of that function that
1250 // rely on it. However, for the purposes of this function, we don't have to 1249 // rely on it. However, for the purposes of this function, we don't have to
1251 // check other tilings. 1250 // check other tilings.
1252 PictureLayerTiling* tiling = 1251 PictureLayerTiling* tiling =
1253 tilings_->FindTilingWithResolution(HIGH_RESOLUTION); 1252 tilings_->FindTilingWithResolution(HIGH_RESOLUTION);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 1286
1288 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { 1287 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const {
1289 if (!layer_tree_impl()->IsActiveTree()) 1288 if (!layer_tree_impl()->IsActiveTree())
1290 return true; 1289 return true;
1291 1290
1292 return AllTilesRequiredAreReadyToDraw( 1291 return AllTilesRequiredAreReadyToDraw(
1293 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); 1292 &PictureLayerTiling::IsTileRequiredForDrawIfVisible);
1294 } 1293 }
1295 1294
1296 } // namespace cc 1295 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698