OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 CacheViewportForTilePriorityInContentSpace(); |
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::CacheViewportForTilePriorityInContentSpace() { |
danakj
2015/01/21 22:32:18
s/CacheViewportFor/UpdateViewportRectFor/
hush (inactive)
2015/01/21 22:40:46
Done.
| |
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_; |
510 | |
danakj
2015/01/21 22:32:18
don't add whitespace
hush (inactive)
2015/01/21 22:40:46
Done.
| |
511 gfx::Rect viewport_rect_for_tile_priority = | 511 gfx::Rect viewport_rect_for_tile_priority = |
512 layer_tree_impl()->ViewportRectForTilePriority(); | 512 layer_tree_impl()->ViewportRectForTilePriority(); |
513 | |
514 if (visible_rect_in_content_space.IsEmpty() || | 513 if (visible_rect_in_content_space.IsEmpty() || |
515 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority) { | 514 layer_tree_impl()->DeviceViewport() != viewport_rect_for_tile_priority) { |
516 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); | 515 gfx::Transform view_to_layer(gfx::Transform::kSkipInitialization); |
517 if (screen_space_transform().GetInverse(&view_to_layer)) { | 516 if (screen_space_transform().GetInverse(&view_to_layer)) { |
518 // Transform from view space to content space. | 517 // Transform from view space to content space. |
519 visible_rect_in_content_space = | 518 visible_rect_in_content_space = |
520 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 519 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
521 view_to_layer, viewport_rect_for_tile_priority)); | 520 view_to_layer, viewport_rect_for_tile_priority)); |
522 } | 521 } |
523 } | 522 } |
524 return visible_rect_in_content_space; | 523 viewport_rect_for_tile_priority_in_content_space_ = |
524 visible_rect_in_content_space; | |
525 } | 525 } |
526 | 526 |
527 PictureLayerImpl* PictureLayerImpl::GetPendingOrActiveTwinLayer() const { | 527 PictureLayerImpl* PictureLayerImpl::GetPendingOrActiveTwinLayer() const { |
528 if (!twin_layer_ || !twin_layer_->IsOnActiveOrPendingTree()) | 528 if (!twin_layer_ || !twin_layer_->IsOnActiveOrPendingTree()) |
529 return nullptr; | 529 return nullptr; |
530 return twin_layer_; | 530 return twin_layer_; |
531 } | 531 } |
532 | 532 |
533 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { | 533 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { |
534 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) | 534 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1173 | 1173 |
1174 void PictureLayerImpl::AsValueInto(base::debug::TracedValue* state) const { | 1174 void PictureLayerImpl::AsValueInto(base::debug::TracedValue* state) const { |
1175 LayerImpl::AsValueInto(state); | 1175 LayerImpl::AsValueInto(state); |
1176 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 1176 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
1177 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); | 1177 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); |
1178 state->BeginArray("tilings"); | 1178 state->BeginArray("tilings"); |
1179 tilings_->AsValueInto(state); | 1179 tilings_->AsValueInto(state); |
1180 state->EndArray(); | 1180 state->EndArray(); |
1181 | 1181 |
1182 state->BeginArray("tile_priority_rect"); | 1182 state->BeginArray("tile_priority_rect"); |
1183 MathUtil::AddToTracedValue(GetViewportForTilePriorityInContentSpace(), state); | 1183 MathUtil::AddToTracedValue(viewport_rect_for_tile_priority_in_content_space_, |
1184 state); | |
1184 state->EndArray(); | 1185 state->EndArray(); |
1185 | 1186 |
1186 state->BeginArray("visible_rect"); | 1187 state->BeginArray("visible_rect"); |
1187 MathUtil::AddToTracedValue(visible_content_rect(), state); | 1188 MathUtil::AddToTracedValue(visible_content_rect(), state); |
1188 state->EndArray(); | 1189 state->EndArray(); |
1189 | 1190 |
1190 state->BeginArray("pictures"); | 1191 state->BeginArray("pictures"); |
1191 raster_source_->AsValueInto(state); | 1192 raster_source_->AsValueInto(state); |
1192 state->EndArray(); | 1193 state->EndArray(); |
1193 | 1194 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1238 TileRequirementCheck is_tile_required_callback) const { | 1239 TileRequirementCheck is_tile_required_callback) const { |
1239 if (!HasValidTilePriorities()) | 1240 if (!HasValidTilePriorities()) |
1240 return true; | 1241 return true; |
1241 | 1242 |
1242 if (!tilings_) | 1243 if (!tilings_) |
1243 return true; | 1244 return true; |
1244 | 1245 |
1245 if (visible_rect_for_tile_priority_.IsEmpty()) | 1246 if (visible_rect_for_tile_priority_.IsEmpty()) |
1246 return true; | 1247 return true; |
1247 | 1248 |
1248 gfx::Rect rect = GetViewportForTilePriorityInContentSpace(); | 1249 gfx::Rect rect = viewport_rect_for_tile_priority_in_content_space_; |
1249 rect.Intersect(visible_rect_for_tile_priority_); | 1250 rect.Intersect(visible_rect_for_tile_priority_); |
1250 | 1251 |
1251 // The high resolution tiling is the only tiling that can mark tiles as | 1252 // The high resolution tiling is the only tiling that can mark tiles as |
1252 // requiring either draw or activation. There is an explicit check in those | 1253 // requiring either draw or activation. There is an explicit check in those |
1253 // callbacks to return false if they are not high resolution tilings. This | 1254 // callbacks to return false if they are not high resolution tilings. This |
1254 // check needs to remain since there are other callers of that function that | 1255 // check needs to remain since there are other callers of that function that |
1255 // rely on it. However, for the purposes of this function, we don't have to | 1256 // rely on it. However, for the purposes of this function, we don't have to |
1256 // check other tilings. | 1257 // check other tilings. |
1257 PictureLayerTiling* tiling = | 1258 PictureLayerTiling* tiling = |
1258 tilings_->FindTilingWithResolution(HIGH_RESOLUTION); | 1259 tilings_->FindTilingWithResolution(HIGH_RESOLUTION); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1292 | 1293 |
1293 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { | 1294 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { |
1294 if (!layer_tree_impl()->IsActiveTree()) | 1295 if (!layer_tree_impl()->IsActiveTree()) |
1295 return true; | 1296 return true; |
1296 | 1297 |
1297 return AllTilesRequiredAreReadyToDraw( | 1298 return AllTilesRequiredAreReadyToDraw( |
1298 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); | 1299 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); |
1299 } | 1300 } |
1300 | 1301 |
1301 } // namespace cc | 1302 } // namespace cc |
OLD | NEW |