| 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 <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 needs_post_commit_initialization_ = true; | 131 needs_post_commit_initialization_ = true; |
| 132 | 132 |
| 133 // We always need to push properties. | 133 // We always need to push properties. |
| 134 // See http://crbug.com/303943 | 134 // See http://crbug.com/303943 |
| 135 needs_push_properties_ = true; | 135 needs_push_properties_ = true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, | 138 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
| 139 AppendQuadsData* append_quads_data) { | 139 AppendQuadsData* append_quads_data) { |
| 140 DCHECK(!needs_post_commit_initialization_); | 140 DCHECK(!needs_post_commit_initialization_); |
| 141 | 141 gfx::Rect rect(visible_content_rect()); |
| 142 float max_contents_scale = MaximumTilingContentsScale(); | |
| 143 gfx::Transform scaled_draw_transform = draw_transform(); | |
| 144 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | |
| 145 SK_MScalar1 / max_contents_scale); | |
| 146 gfx::Size scaled_content_bounds = | |
| 147 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); | |
| 148 | |
| 149 gfx::Rect scaled_visible_content_rect = | |
| 150 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); | |
| 151 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); | |
| 152 | 142 |
| 153 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 143 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); |
| 154 shared_quad_state->SetAll(scaled_draw_transform, | 144 PopulateSharedQuadState(shared_quad_state); |
| 155 scaled_content_bounds, | |
| 156 scaled_visible_content_rect, | |
| 157 draw_properties().clip_rect, | |
| 158 draw_properties().is_clipped, | |
| 159 draw_properties().opacity, | |
| 160 blend_mode()); | |
| 161 | |
| 162 gfx::Rect rect = scaled_visible_content_rect; | |
| 163 | 145 |
| 164 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 146 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 165 AppendDebugBorderQuad( | 147 AppendDebugBorderQuad( |
| 166 quad_sink, | 148 quad_sink, |
| 167 shared_quad_state, | 149 shared_quad_state, |
| 168 append_quads_data, | 150 append_quads_data, |
| 169 DebugColors::DirectPictureBorderColor(), | 151 DebugColors::DirectPictureBorderColor(), |
| 170 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 152 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
| 171 | 153 |
| 172 gfx::Rect geometry_rect = rect; | 154 gfx::Rect geometry_rect = rect; |
| 173 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 155 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
| 174 gfx::Rect visible_geometry_rect = | 156 gfx::Rect visible_geometry_rect = |
| 175 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 157 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); |
| 176 if (visible_geometry_rect.IsEmpty()) | 158 if (visible_geometry_rect.IsEmpty()) |
| 177 return; | 159 return; |
| 178 | 160 |
| 179 gfx::Size texture_size = rect.size(); | 161 gfx::Size texture_size = rect.size(); |
| 180 gfx::RectF texture_rect = gfx::RectF(texture_size); | 162 gfx::RectF texture_rect = gfx::RectF(texture_size); |
| 181 gfx::Rect quad_content_rect = rect; | 163 gfx::Rect quad_content_rect = rect; |
| 164 float contents_scale = contents_scale_x(); |
| 182 | 165 |
| 183 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 166 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 184 quad->SetNew(shared_quad_state, | 167 quad->SetNew(shared_quad_state, |
| 185 geometry_rect, | 168 geometry_rect, |
| 186 opaque_rect, | 169 opaque_rect, |
| 187 visible_geometry_rect, | 170 visible_geometry_rect, |
| 188 texture_rect, | 171 texture_rect, |
| 189 texture_size, | 172 texture_size, |
| 190 RGBA_8888, | 173 RGBA_8888, |
| 191 quad_content_rect, | 174 quad_content_rect, |
| 192 max_contents_scale, | 175 contents_scale, |
| 193 pile_); | 176 pile_); |
| 194 quad_sink->Append(quad.PassAs<DrawQuad>()); | 177 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 195 append_quads_data->num_missing_tiles++; | 178 append_quads_data->num_missing_tiles++; |
| 196 return; | 179 return; |
| 197 } | 180 } |
| 198 | 181 |
| 199 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 182 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 200 | 183 |
| 201 if (ShowDebugBorders()) { | 184 if (ShowDebugBorders()) { |
| 202 for (PictureLayerTilingSet::CoverageIterator iter( | 185 for (PictureLayerTilingSet::CoverageIterator iter( |
| 203 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); | 186 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
| 204 iter; | 187 iter; |
| 205 ++iter) { | 188 ++iter) { |
| 206 SkColor color; | 189 SkColor color; |
| 207 float width; | 190 float width; |
| 208 if (*iter && iter->IsReadyToDraw()) { | 191 if (*iter && iter->IsReadyToDraw()) { |
| 209 ManagedTileState::TileVersion::Mode mode = | 192 ManagedTileState::TileVersion::Mode mode = |
| 210 iter->GetTileVersionForDrawing().mode(); | 193 iter->GetTileVersionForDrawing().mode(); |
| 211 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | 194 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { |
| 212 color = DebugColors::SolidColorTileBorderColor(); | 195 color = DebugColors::SolidColorTileBorderColor(); |
| 213 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 196 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| 214 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { | 197 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { |
| 215 color = DebugColors::PictureTileBorderColor(); | 198 color = DebugColors::PictureTileBorderColor(); |
| 216 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 199 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
| 217 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 200 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
| 218 color = DebugColors::HighResTileBorderColor(); | 201 color = DebugColors::HighResTileBorderColor(); |
| 219 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 202 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
| 220 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 203 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
| 221 color = DebugColors::LowResTileBorderColor(); | 204 color = DebugColors::LowResTileBorderColor(); |
| 222 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 205 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
| 223 } else if (iter->contents_scale() > max_contents_scale) { | 206 } else if (iter->contents_scale() > contents_scale_x()) { |
| 224 color = DebugColors::ExtraHighResTileBorderColor(); | 207 color = DebugColors::ExtraHighResTileBorderColor(); |
| 225 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 208 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
| 226 } else { | 209 } else { |
| 227 color = DebugColors::ExtraLowResTileBorderColor(); | 210 color = DebugColors::ExtraLowResTileBorderColor(); |
| 228 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 211 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
| 229 } | 212 } |
| 230 } else { | 213 } else { |
| 231 color = DebugColors::MissingTileBorderColor(); | 214 color = DebugColors::MissingTileBorderColor(); |
| 232 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); | 215 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); |
| 233 } | 216 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 245 } | 228 } |
| 246 } | 229 } |
| 247 | 230 |
| 248 // Keep track of the tilings that were used so that tilings that are | 231 // Keep track of the tilings that were used so that tilings that are |
| 249 // unused can be considered for removal. | 232 // unused can be considered for removal. |
| 250 std::vector<PictureLayerTiling*> seen_tilings; | 233 std::vector<PictureLayerTiling*> seen_tilings; |
| 251 | 234 |
| 252 size_t missing_tile_count = 0u; | 235 size_t missing_tile_count = 0u; |
| 253 size_t on_demand_missing_tile_count = 0u; | 236 size_t on_demand_missing_tile_count = 0u; |
| 254 for (PictureLayerTilingSet::CoverageIterator iter( | 237 for (PictureLayerTilingSet::CoverageIterator iter( |
| 255 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); | 238 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
| 256 iter; | 239 iter; |
| 257 ++iter) { | 240 ++iter) { |
| 258 gfx::Rect geometry_rect = iter.geometry_rect(); | 241 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 259 gfx::Rect visible_geometry_rect = | 242 gfx::Rect visible_geometry_rect = |
| 260 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 243 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); |
| 261 if (visible_geometry_rect.IsEmpty()) | 244 if (visible_geometry_rect.IsEmpty()) |
| 262 continue; | 245 continue; |
| 263 | 246 |
| 264 append_quads_data->visible_content_area += | 247 append_quads_data->visible_content_area += |
| 265 visible_geometry_rect.width() * visible_geometry_rect.height(); | 248 visible_geometry_rect.width() * visible_geometry_rect.height(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 // Aggressively remove any tilings that are not seen to save memory. Note | 365 // Aggressively remove any tilings that are not seen to save memory. Note |
| 383 // that this is at the expense of doing cause more frequent re-painting. A | 366 // that this is at the expense of doing cause more frequent re-painting. A |
| 384 // better scheme would be to maintain a tighter visible_content_rect for the | 367 // better scheme would be to maintain a tighter visible_content_rect for the |
| 385 // finer tilings. | 368 // finer tilings. |
| 386 CleanUpTilingsOnActiveLayer(seen_tilings); | 369 CleanUpTilingsOnActiveLayer(seen_tilings); |
| 387 } | 370 } |
| 388 | 371 |
| 389 void PictureLayerImpl::UpdateTilePriorities() { | 372 void PictureLayerImpl::UpdateTilePriorities() { |
| 390 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 373 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
| 391 | 374 |
| 392 DoPostCommitInitializationIfNeeded(); | 375 DCHECK(!needs_post_commit_initialization_); |
| 393 UpdateIdealScales(); | 376 CHECK(should_update_tile_priorities_); |
| 394 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a | |
| 395 // non-updated tree which will then be updated immediately afterwards. | |
| 396 should_update_tile_priorities_ = true; | |
| 397 if (CanHaveTilings()) { | |
| 398 ManageTilings(draw_properties().screen_space_transform_is_animating, | |
| 399 draw_properties().maximum_animation_contents_scale); | |
| 400 } | |
| 401 | 377 |
| 402 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 378 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
| 403 visible_rect_for_tile_priority_ = visible_content_rect(); | 379 visible_rect_for_tile_priority_ = visible_content_rect(); |
| 404 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 380 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
| 405 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 381 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
| 406 } | 382 } |
| 407 | 383 |
| 408 if (!tilings_->num_tilings()) | 384 if (!tilings_->num_tilings()) |
| 409 return; | 385 return; |
| 410 | 386 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 430 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); | 406 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); |
| 431 if (screen_space_transform_for_tile_priority_.GetInverse( | 407 if (screen_space_transform_for_tile_priority_.GetInverse( |
| 432 &screen_to_layer)) { | 408 &screen_to_layer)) { |
| 433 visible_rect_in_content_space = | 409 visible_rect_in_content_space = |
| 434 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 410 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 435 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); | 411 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); |
| 436 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); | 412 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); |
| 437 } | 413 } |
| 438 } | 414 } |
| 439 | 415 |
| 440 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( | |
| 441 visible_rect_in_content_space, 1.f / contents_scale_x()); | |
| 442 WhichTree tree = | 416 WhichTree tree = |
| 443 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 417 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 444 // TODO(sohanjg): Passing MaximumContentsScale as layer contents scale | 418 |
| 445 // in UpdateTilePriorities is wrong and should be ideal contents scale. | |
| 446 tilings_->UpdateTilePriorities(tree, | 419 tilings_->UpdateTilePriorities(tree, |
| 447 visible_layer_rect, | 420 visible_rect_in_content_space, |
| 448 MaximumTilingContentsScale(), | 421 contents_scale_x(), |
| 449 current_frame_time_in_seconds); | 422 current_frame_time_in_seconds); |
| 450 | 423 |
| 451 if (layer_tree_impl()->IsPendingTree()) | 424 if (layer_tree_impl()->IsPendingTree()) |
| 452 MarkVisibleResourcesAsRequired(); | 425 MarkVisibleResourcesAsRequired(); |
| 453 | 426 |
| 454 // Tile priorities were modified. | 427 // Tile priorities were modified. |
| 455 layer_tree_impl()->DidModifyTilePriorities(); | 428 layer_tree_impl()->DidModifyTilePriorities(); |
| 456 } | 429 } |
| 457 | 430 |
| 458 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 431 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 478 RemoveAllTilings(); | 451 RemoveAllTilings(); |
| 479 | 452 |
| 480 ResetRasterScale(); | 453 ResetRasterScale(); |
| 481 | 454 |
| 482 // To avoid an edge case after lost context where the tree is up to date but | 455 // To avoid an edge case after lost context where the tree is up to date but |
| 483 // the tilings have not been managed, request an update draw properties | 456 // the tilings have not been managed, request an update draw properties |
| 484 // to force tilings to get managed. | 457 // to force tilings to get managed. |
| 485 layer_tree_impl()->set_needs_update_draw_properties(); | 458 layer_tree_impl()->set_needs_update_draw_properties(); |
| 486 } | 459 } |
| 487 | 460 |
| 461 void PictureLayerImpl::CalculateContentsScale( |
| 462 float ideal_contents_scale, |
| 463 float device_scale_factor, |
| 464 float page_scale_factor, |
| 465 float maximum_animation_contents_scale, |
| 466 bool animating_transform_to_screen, |
| 467 float* contents_scale_x, |
| 468 float* contents_scale_y, |
| 469 gfx::Size* content_bounds) { |
| 470 DoPostCommitInitializationIfNeeded(); |
| 471 |
| 472 // This function sets valid raster scales and manages tilings, so tile |
| 473 // priorities can now be updated. |
| 474 should_update_tile_priorities_ = true; |
| 475 |
| 476 if (!CanHaveTilings()) { |
| 477 ideal_page_scale_ = page_scale_factor; |
| 478 ideal_device_scale_ = device_scale_factor; |
| 479 ideal_contents_scale_ = ideal_contents_scale; |
| 480 ideal_source_scale_ = |
| 481 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; |
| 482 *contents_scale_x = ideal_contents_scale_; |
| 483 *contents_scale_y = ideal_contents_scale_; |
| 484 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), |
| 485 ideal_contents_scale_, |
| 486 ideal_contents_scale_)); |
| 487 return; |
| 488 } |
| 489 |
| 490 float min_contents_scale = MinimumContentsScale(); |
| 491 DCHECK_GT(min_contents_scale, 0.f); |
| 492 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); |
| 493 DCHECK_GT(min_page_scale, 0.f); |
| 494 float min_device_scale = 1.f; |
| 495 float min_source_scale = |
| 496 min_contents_scale / min_page_scale / min_device_scale; |
| 497 |
| 498 float ideal_page_scale = page_scale_factor; |
| 499 float ideal_device_scale = device_scale_factor; |
| 500 float ideal_source_scale = |
| 501 ideal_contents_scale / ideal_page_scale / ideal_device_scale; |
| 502 |
| 503 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); |
| 504 ideal_page_scale_ = ideal_page_scale; |
| 505 ideal_device_scale_ = ideal_device_scale; |
| 506 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); |
| 507 |
| 508 ManageTilings(animating_transform_to_screen, |
| 509 maximum_animation_contents_scale); |
| 510 |
| 511 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. |
| 512 // There are (usually) several tilings at different scales. However, the |
| 513 // content bounds is the (integer!) space in which quads are generated. |
| 514 // In order to guarantee that we can fill this integer space with any set of |
| 515 // tilings (and then map back to floating point texture coordinates), the |
| 516 // contents scale must be at least as large as the largest of the tilings. |
| 517 float max_contents_scale = min_contents_scale; |
| 518 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 519 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 520 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); |
| 521 } |
| 522 |
| 523 *contents_scale_x = max_contents_scale; |
| 524 *contents_scale_y = max_contents_scale; |
| 525 *content_bounds = gfx::ToCeiledSize( |
| 526 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); |
| 527 } |
| 528 |
| 488 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 529 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
| 489 return pile_->GetFlattenedPicture(); | 530 return pile_->GetFlattenedPicture(); |
| 490 } | 531 } |
| 491 | 532 |
| 492 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 533 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
| 493 const gfx::Rect& content_rect) { | 534 const gfx::Rect& content_rect) { |
| 494 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) | 535 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) |
| 495 return scoped_refptr<Tile>(); | 536 return scoped_refptr<Tile>(); |
| 496 | 537 |
| 497 int flags = 0; | 538 int flags = 0; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 void PictureLayerImpl::SetIsMask(bool is_mask) { | 743 void PictureLayerImpl::SetIsMask(bool is_mask) { |
| 703 if (is_mask_ == is_mask) | 744 if (is_mask_ == is_mask) |
| 704 return; | 745 return; |
| 705 is_mask_ = is_mask; | 746 is_mask_ = is_mask; |
| 706 if (tilings_) | 747 if (tilings_) |
| 707 tilings_->RemoveAllTiles(); | 748 tilings_->RemoveAllTiles(); |
| 708 } | 749 } |
| 709 | 750 |
| 710 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 751 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
| 711 gfx::Rect content_rect(content_bounds()); | 752 gfx::Rect content_rect(content_bounds()); |
| 712 float scale = MaximumTilingContentsScale(); | 753 float scale = contents_scale_x(); |
| 713 PictureLayerTilingSet::CoverageIterator iter( | 754 PictureLayerTilingSet::CoverageIterator iter( |
| 714 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 755 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
| 715 | 756 |
| 716 // Mask resource not ready yet. | 757 // Mask resource not ready yet. |
| 717 if (!iter || !*iter) | 758 if (!iter || !*iter) |
| 718 return 0; | 759 return 0; |
| 719 | 760 |
| 720 // Masks only supported if they fit on exactly one tile. | 761 // Masks only supported if they fit on exactly one tile. |
| 721 if (iter.geometry_rect() != content_rect) | 762 if (iter.geometry_rect() != content_rect) |
| 722 return 0; | 763 return 0; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 } | 1312 } |
| 1272 if (tilings_->num_tilings() == 0) | 1313 if (tilings_->num_tilings() == 0) |
| 1273 return; | 1314 return; |
| 1274 | 1315 |
| 1275 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1316 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
| 1276 // tiling to mark its tiles as being required for activation. | 1317 // tiling to mark its tiles as being required for activation. |
| 1277 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1318 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
| 1278 #endif | 1319 #endif |
| 1279 } | 1320 } |
| 1280 | 1321 |
| 1281 float PictureLayerImpl::MaximumTilingContentsScale() const { | |
| 1282 float max_contents_scale = MinimumContentsScale(); | |
| 1283 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
| 1284 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | |
| 1285 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | |
| 1286 } | |
| 1287 return max_contents_scale; | |
| 1288 } | |
| 1289 | |
| 1290 void PictureLayerImpl::UpdateIdealScales() { | |
| 1291 if (!CanHaveTilings()) { | |
| 1292 ideal_page_scale_ = draw_properties().page_scale_factor; | |
| 1293 ideal_device_scale_ = draw_properties().device_scale_factor; | |
| 1294 ideal_contents_scale_ = draw_properties().ideal_contents_scale; | |
| 1295 ideal_source_scale_ = | |
| 1296 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | |
| 1297 return; | |
| 1298 } | |
| 1299 | |
| 1300 float min_contents_scale = MinimumContentsScale(); | |
| 1301 DCHECK_GT(min_contents_scale, 0.f); | |
| 1302 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | |
| 1303 DCHECK_GT(min_page_scale, 0.f); | |
| 1304 float min_device_scale = 1.f; | |
| 1305 float min_source_scale = | |
| 1306 min_contents_scale / min_page_scale / min_device_scale; | |
| 1307 | |
| 1308 float ideal_page_scale = draw_properties().page_scale_factor; | |
| 1309 float ideal_device_scale = draw_properties().device_scale_factor; | |
| 1310 float ideal_source_scale = draw_properties().ideal_contents_scale / | |
| 1311 ideal_page_scale / ideal_device_scale; | |
| 1312 ideal_contents_scale_ = | |
| 1313 std::max(draw_properties().ideal_contents_scale, min_contents_scale); | |
| 1314 ideal_page_scale_ = draw_properties().page_scale_factor; | |
| 1315 ideal_device_scale_ = draw_properties().device_scale_factor; | |
| 1316 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | |
| 1317 } | |
| 1318 | |
| 1319 void PictureLayerImpl::GetDebugBorderProperties( | 1322 void PictureLayerImpl::GetDebugBorderProperties( |
| 1320 SkColor* color, | 1323 SkColor* color, |
| 1321 float* width) const { | 1324 float* width) const { |
| 1322 *color = DebugColors::TiledContentLayerBorderColor(); | 1325 *color = DebugColors::TiledContentLayerBorderColor(); |
| 1323 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); | 1326 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); |
| 1324 } | 1327 } |
| 1325 | 1328 |
| 1326 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1329 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
| 1327 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1330 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
| 1328 LayerImpl::AsValueInto(state); | 1331 LayerImpl::AsValueInto(state); |
| 1329 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 1332 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 1330 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); | 1333 state->SetDouble("geometry_contents_scale", contents_scale_x()); |
| 1331 state->Set("tilings", tilings_->AsValue().release()); | 1334 state->Set("tilings", tilings_->AsValue().release()); |
| 1332 state->Set("pictures", pile_->AsValue().release()); | 1335 state->Set("pictures", pile_->AsValue().release()); |
| 1333 state->Set("invalidation", invalidation_.AsValue().release()); | 1336 state->Set("invalidation", invalidation_.AsValue().release()); |
| 1334 | 1337 |
| 1335 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); | 1338 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); |
| 1336 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), | 1339 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), |
| 1337 contents_scale_x(), | 1340 contents_scale_x(), |
| 1338 gfx::Rect(content_bounds()), | 1341 gfx::Rect(content_bounds()), |
| 1339 ideal_contents_scale_); | 1342 ideal_contents_scale_); |
| 1340 iter; | 1343 iter; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 return iterator_index_ < iterators_.size(); | 1640 return iterator_index_ < iterators_.size(); |
| 1638 } | 1641 } |
| 1639 | 1642 |
| 1640 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1643 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
| 1641 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1644 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
| 1642 return it->get_type() == iteration_stage_ && | 1645 return it->get_type() == iteration_stage_ && |
| 1643 (**it)->required_for_activation() == required_for_activation_; | 1646 (**it)->required_for_activation() == required_for_activation_; |
| 1644 } | 1647 } |
| 1645 | 1648 |
| 1646 } // namespace cc | 1649 } // namespace cc |
| OLD | NEW |