| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 needs_post_commit_initialization_ = true; | 135 needs_post_commit_initialization_ = true; |
| 136 | 136 |
| 137 // We always need to push properties. | 137 // We always need to push properties. |
| 138 // See http://crbug.com/303943 | 138 // See http://crbug.com/303943 |
| 139 needs_push_properties_ = true; | 139 needs_push_properties_ = true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, | 142 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
| 143 AppendQuadsData* append_quads_data) { | 143 AppendQuadsData* append_quads_data) { |
| 144 DCHECK(!needs_post_commit_initialization_); | 144 DCHECK(!needs_post_commit_initialization_); |
| 145 gfx::Rect rect(visible_content_rect()); | 145 |
| 146 float max_contents_scale = MaximumTilingContentsScale(); |
| 147 gfx::Transform scaled_draw_transform = draw_transform(); |
| 148 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
| 149 SK_MScalar1 / max_contents_scale); |
| 150 gfx::Size scaled_content_bounds = |
| 151 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); |
| 152 |
| 153 gfx::Rect scaled_visible_content_rect = |
| 154 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); |
| 155 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); |
| 146 | 156 |
| 147 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 157 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); |
| 148 PopulateSharedQuadState(shared_quad_state); | 158 shared_quad_state->SetAll(scaled_draw_transform, |
| 159 scaled_content_bounds, |
| 160 scaled_visible_content_rect, |
| 161 draw_properties().clip_rect, |
| 162 draw_properties().is_clipped, |
| 163 draw_properties().opacity, |
| 164 blend_mode()); |
| 165 |
| 166 gfx::Rect rect = scaled_visible_content_rect; |
| 149 | 167 |
| 150 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 168 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 151 AppendDebugBorderQuad( | 169 AppendDebugBorderQuad( |
| 152 quad_sink, | 170 quad_sink, |
| 153 shared_quad_state, | 171 shared_quad_state, |
| 154 append_quads_data, | 172 append_quads_data, |
| 155 DebugColors::DirectPictureBorderColor(), | 173 DebugColors::DirectPictureBorderColor(), |
| 156 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 174 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
| 157 | 175 |
| 158 gfx::Rect geometry_rect = rect; | 176 gfx::Rect geometry_rect = rect; |
| 159 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 177 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
| 160 gfx::Rect visible_geometry_rect = | 178 gfx::Rect visible_geometry_rect = |
| 161 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 179 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); |
| 162 if (visible_geometry_rect.IsEmpty()) | 180 if (visible_geometry_rect.IsEmpty()) |
| 163 return; | 181 return; |
| 164 | 182 |
| 165 gfx::Size texture_size = rect.size(); | 183 gfx::Size texture_size = rect.size(); |
| 166 gfx::RectF texture_rect = gfx::RectF(texture_size); | 184 gfx::RectF texture_rect = gfx::RectF(texture_size); |
| 167 gfx::Rect quad_content_rect = rect; | 185 gfx::Rect quad_content_rect = rect; |
| 168 float contents_scale = contents_scale_x(); | |
| 169 | 186 |
| 170 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 187 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 171 quad->SetNew(shared_quad_state, | 188 quad->SetNew(shared_quad_state, |
| 172 geometry_rect, | 189 geometry_rect, |
| 173 opaque_rect, | 190 opaque_rect, |
| 174 visible_geometry_rect, | 191 visible_geometry_rect, |
| 175 texture_rect, | 192 texture_rect, |
| 176 texture_size, | 193 texture_size, |
| 177 RGBA_8888, | 194 RGBA_8888, |
| 178 quad_content_rect, | 195 quad_content_rect, |
| 179 contents_scale, | 196 max_contents_scale, |
| 180 pile_); | 197 pile_); |
| 181 quad_sink->Append(quad.PassAs<DrawQuad>()); | 198 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 182 append_quads_data->num_missing_tiles++; | 199 append_quads_data->num_missing_tiles++; |
| 183 return; | 200 return; |
| 184 } | 201 } |
| 185 | 202 |
| 186 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 203 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 187 | 204 |
| 188 if (ShowDebugBorders()) { | 205 if (ShowDebugBorders()) { |
| 189 for (PictureLayerTilingSet::CoverageIterator iter( | 206 for (PictureLayerTilingSet::CoverageIterator iter( |
| 190 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 207 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); |
| 191 iter; | 208 iter; |
| 192 ++iter) { | 209 ++iter) { |
| 193 SkColor color; | 210 SkColor color; |
| 194 float width; | 211 float width; |
| 195 if (*iter && iter->IsReadyToDraw()) { | 212 if (*iter && iter->IsReadyToDraw()) { |
| 196 ManagedTileState::TileVersion::Mode mode = | 213 ManagedTileState::TileVersion::Mode mode = |
| 197 iter->GetTileVersionForDrawing().mode(); | 214 iter->GetTileVersionForDrawing().mode(); |
| 198 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | 215 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { |
| 199 color = DebugColors::SolidColorTileBorderColor(); | 216 color = DebugColors::SolidColorTileBorderColor(); |
| 200 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 217 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| 201 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { | 218 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { |
| 202 color = DebugColors::PictureTileBorderColor(); | 219 color = DebugColors::PictureTileBorderColor(); |
| 203 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 220 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
| 204 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 221 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
| 205 color = DebugColors::HighResTileBorderColor(); | 222 color = DebugColors::HighResTileBorderColor(); |
| 206 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 223 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
| 207 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 224 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
| 208 color = DebugColors::LowResTileBorderColor(); | 225 color = DebugColors::LowResTileBorderColor(); |
| 209 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 226 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
| 210 } else if (iter->contents_scale() > contents_scale_x()) { | 227 } else if (iter->contents_scale() > max_contents_scale) { |
| 211 color = DebugColors::ExtraHighResTileBorderColor(); | 228 color = DebugColors::ExtraHighResTileBorderColor(); |
| 212 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 229 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
| 213 } else { | 230 } else { |
| 214 color = DebugColors::ExtraLowResTileBorderColor(); | 231 color = DebugColors::ExtraLowResTileBorderColor(); |
| 215 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 232 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
| 216 } | 233 } |
| 217 } else { | 234 } else { |
| 218 color = DebugColors::MissingTileBorderColor(); | 235 color = DebugColors::MissingTileBorderColor(); |
| 219 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); | 236 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); |
| 220 } | 237 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 232 } | 249 } |
| 233 } | 250 } |
| 234 | 251 |
| 235 // Keep track of the tilings that were used so that tilings that are | 252 // Keep track of the tilings that were used so that tilings that are |
| 236 // unused can be considered for removal. | 253 // unused can be considered for removal. |
| 237 std::vector<PictureLayerTiling*> seen_tilings; | 254 std::vector<PictureLayerTiling*> seen_tilings; |
| 238 | 255 |
| 239 size_t missing_tile_count = 0u; | 256 size_t missing_tile_count = 0u; |
| 240 size_t on_demand_missing_tile_count = 0u; | 257 size_t on_demand_missing_tile_count = 0u; |
| 241 for (PictureLayerTilingSet::CoverageIterator iter( | 258 for (PictureLayerTilingSet::CoverageIterator iter( |
| 242 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 259 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); |
| 243 iter; | 260 iter; |
| 244 ++iter) { | 261 ++iter) { |
| 245 gfx::Rect geometry_rect = iter.geometry_rect(); | 262 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 246 gfx::Rect visible_geometry_rect = | 263 gfx::Rect visible_geometry_rect = |
| 247 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 264 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); |
| 248 if (visible_geometry_rect.IsEmpty()) | 265 if (visible_geometry_rect.IsEmpty()) |
| 249 continue; | 266 continue; |
| 250 | 267 |
| 251 append_quads_data->visible_content_area += | 268 append_quads_data->visible_content_area += |
| 252 visible_geometry_rect.width() * visible_geometry_rect.height(); | 269 visible_geometry_rect.width() * visible_geometry_rect.height(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 392 |
| 376 void PictureLayerImpl::DidUnregisterLayer() { | 393 void PictureLayerImpl::DidUnregisterLayer() { |
| 377 TRACE_EVENT0("cc", "PictureLayerImpl::DidUnregisterLayer"); | 394 TRACE_EVENT0("cc", "PictureLayerImpl::DidUnregisterLayer"); |
| 378 | 395 |
| 379 layer_needs_to_register_itself_ = true; | 396 layer_needs_to_register_itself_ = true; |
| 380 } | 397 } |
| 381 | 398 |
| 382 void PictureLayerImpl::UpdateTilePriorities() { | 399 void PictureLayerImpl::UpdateTilePriorities() { |
| 383 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 400 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
| 384 | 401 |
| 385 DCHECK(!needs_post_commit_initialization_); | 402 DoPostCommitInitializationIfNeeded(); |
| 386 CHECK(should_update_tile_priorities_); | 403 UpdateIdealScales(); |
| 404 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a |
| 405 // non-updated tree which will then be updated immediately afterwards. |
| 406 should_update_tile_priorities_ = true; |
| 407 if (CanHaveTilings()) { |
| 408 ManageTilings(draw_properties().screen_space_transform_is_animating, |
| 409 draw_properties().maximum_animation_contents_scale); |
| 410 } |
| 387 | 411 |
| 388 if (layer_needs_to_register_itself_) { | 412 if (layer_needs_to_register_itself_) { |
| 389 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); | 413 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); |
| 390 layer_needs_to_register_itself_ = false; | 414 layer_needs_to_register_itself_ = false; |
| 391 } | 415 } |
| 392 | 416 |
| 393 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 417 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
| 394 visible_rect_for_tile_priority_ = visible_content_rect(); | 418 visible_rect_for_tile_priority_ = visible_content_rect(); |
| 395 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 419 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
| 396 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 420 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 423 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); | 447 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); |
| 424 if (screen_space_transform_for_tile_priority_.GetInverse( | 448 if (screen_space_transform_for_tile_priority_.GetInverse( |
| 425 &screen_to_layer)) { | 449 &screen_to_layer)) { |
| 426 visible_rect_in_content_space = | 450 visible_rect_in_content_space = |
| 427 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 451 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 428 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); | 452 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); |
| 429 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); | 453 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); |
| 430 } | 454 } |
| 431 } | 455 } |
| 432 | 456 |
| 457 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect( |
| 458 visible_rect_in_content_space, 1.f / contents_scale_x()); |
| 433 WhichTree tree = | 459 WhichTree tree = |
| 434 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 460 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 435 | 461 // TODO(sohanjg): Passing MaximumContentsScale as layer contents scale |
| 462 // in UpdateTilePriorities is wrong and should be ideal contents scale. |
| 436 tilings_->UpdateTilePriorities(tree, | 463 tilings_->UpdateTilePriorities(tree, |
| 437 visible_rect_in_content_space, | 464 visible_layer_rect, |
| 438 contents_scale_x(), | 465 MaximumTilingContentsScale(), |
| 439 current_frame_time_in_seconds); | 466 current_frame_time_in_seconds); |
| 440 | 467 |
| 441 if (layer_tree_impl()->IsPendingTree()) | 468 if (layer_tree_impl()->IsPendingTree()) |
| 442 MarkVisibleResourcesAsRequired(); | 469 MarkVisibleResourcesAsRequired(); |
| 443 | 470 |
| 444 // Tile priorities were modified. | 471 // Tile priorities were modified. |
| 445 layer_tree_impl()->DidModifyTilePriorities(); | 472 layer_tree_impl()->DidModifyTilePriorities(); |
| 446 } | 473 } |
| 447 | 474 |
| 448 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 475 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 468 RemoveAllTilings(); | 495 RemoveAllTilings(); |
| 469 | 496 |
| 470 ResetRasterScale(); | 497 ResetRasterScale(); |
| 471 | 498 |
| 472 // To avoid an edge case after lost context where the tree is up to date but | 499 // To avoid an edge case after lost context where the tree is up to date but |
| 473 // the tilings have not been managed, request an update draw properties | 500 // the tilings have not been managed, request an update draw properties |
| 474 // to force tilings to get managed. | 501 // to force tilings to get managed. |
| 475 layer_tree_impl()->set_needs_update_draw_properties(); | 502 layer_tree_impl()->set_needs_update_draw_properties(); |
| 476 } | 503 } |
| 477 | 504 |
| 478 void PictureLayerImpl::CalculateContentsScale( | |
| 479 float ideal_contents_scale, | |
| 480 float device_scale_factor, | |
| 481 float page_scale_factor, | |
| 482 float maximum_animation_contents_scale, | |
| 483 bool animating_transform_to_screen, | |
| 484 float* contents_scale_x, | |
| 485 float* contents_scale_y, | |
| 486 gfx::Size* content_bounds) { | |
| 487 DoPostCommitInitializationIfNeeded(); | |
| 488 | |
| 489 // This function sets valid raster scales and manages tilings, so tile | |
| 490 // priorities can now be updated. | |
| 491 should_update_tile_priorities_ = true; | |
| 492 | |
| 493 if (!CanHaveTilings()) { | |
| 494 ideal_page_scale_ = page_scale_factor; | |
| 495 ideal_device_scale_ = device_scale_factor; | |
| 496 ideal_contents_scale_ = ideal_contents_scale; | |
| 497 ideal_source_scale_ = | |
| 498 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | |
| 499 *contents_scale_x = ideal_contents_scale_; | |
| 500 *contents_scale_y = ideal_contents_scale_; | |
| 501 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), | |
| 502 ideal_contents_scale_, | |
| 503 ideal_contents_scale_)); | |
| 504 return; | |
| 505 } | |
| 506 | |
| 507 float min_contents_scale = MinimumContentsScale(); | |
| 508 DCHECK_GT(min_contents_scale, 0.f); | |
| 509 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | |
| 510 DCHECK_GT(min_page_scale, 0.f); | |
| 511 float min_device_scale = 1.f; | |
| 512 float min_source_scale = | |
| 513 min_contents_scale / min_page_scale / min_device_scale; | |
| 514 | |
| 515 float ideal_page_scale = page_scale_factor; | |
| 516 float ideal_device_scale = device_scale_factor; | |
| 517 float ideal_source_scale = | |
| 518 ideal_contents_scale / ideal_page_scale / ideal_device_scale; | |
| 519 | |
| 520 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); | |
| 521 ideal_page_scale_ = ideal_page_scale; | |
| 522 ideal_device_scale_ = ideal_device_scale; | |
| 523 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | |
| 524 | |
| 525 ManageTilings(animating_transform_to_screen, | |
| 526 maximum_animation_contents_scale); | |
| 527 | |
| 528 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. | |
| 529 // There are (usually) several tilings at different scales. However, the | |
| 530 // content bounds is the (integer!) space in which quads are generated. | |
| 531 // In order to guarantee that we can fill this integer space with any set of | |
| 532 // tilings (and then map back to floating point texture coordinates), the | |
| 533 // contents scale must be at least as large as the largest of the tilings. | |
| 534 float max_contents_scale = min_contents_scale; | |
| 535 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
| 536 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | |
| 537 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | |
| 538 } | |
| 539 | |
| 540 *contents_scale_x = max_contents_scale; | |
| 541 *contents_scale_y = max_contents_scale; | |
| 542 *content_bounds = gfx::ToCeiledSize( | |
| 543 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); | |
| 544 } | |
| 545 | |
| 546 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 505 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
| 547 return pile_->GetFlattenedPicture(); | 506 return pile_->GetFlattenedPicture(); |
| 548 } | 507 } |
| 549 | 508 |
| 550 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 509 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
| 551 const gfx::Rect& content_rect) { | 510 const gfx::Rect& content_rect) { |
| 552 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) | 511 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) |
| 553 return scoped_refptr<Tile>(); | 512 return scoped_refptr<Tile>(); |
| 554 | 513 |
| 555 int flags = 0; | 514 int flags = 0; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 void PictureLayerImpl::SetIsMask(bool is_mask) { | 724 void PictureLayerImpl::SetIsMask(bool is_mask) { |
| 766 if (is_mask_ == is_mask) | 725 if (is_mask_ == is_mask) |
| 767 return; | 726 return; |
| 768 is_mask_ = is_mask; | 727 is_mask_ = is_mask; |
| 769 if (tilings_) | 728 if (tilings_) |
| 770 tilings_->RemoveAllTiles(); | 729 tilings_->RemoveAllTiles(); |
| 771 } | 730 } |
| 772 | 731 |
| 773 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 732 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
| 774 gfx::Rect content_rect(content_bounds()); | 733 gfx::Rect content_rect(content_bounds()); |
| 775 float scale = contents_scale_x(); | 734 float scale = MaximumTilingContentsScale(); |
| 776 PictureLayerTilingSet::CoverageIterator iter( | 735 PictureLayerTilingSet::CoverageIterator iter( |
| 777 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 736 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
| 778 | 737 |
| 779 // Mask resource not ready yet. | 738 // Mask resource not ready yet. |
| 780 if (!iter || !*iter) | 739 if (!iter || !*iter) |
| 781 return 0; | 740 return 0; |
| 782 | 741 |
| 783 // Masks only supported if they fit on exactly one tile. | 742 // Masks only supported if they fit on exactly one tile. |
| 784 if (iter.geometry_rect() != content_rect) | 743 if (iter.geometry_rect() != content_rect) |
| 785 return 0; | 744 return 0; |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 } | 1305 } |
| 1347 if (tilings_->num_tilings() == 0) | 1306 if (tilings_->num_tilings() == 0) |
| 1348 return; | 1307 return; |
| 1349 | 1308 |
| 1350 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1309 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
| 1351 // tiling to mark its tiles as being required for activation. | 1310 // tiling to mark its tiles as being required for activation. |
| 1352 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1311 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
| 1353 #endif | 1312 #endif |
| 1354 } | 1313 } |
| 1355 | 1314 |
| 1315 float PictureLayerImpl::MaximumTilingContentsScale() const { |
| 1316 float max_contents_scale = MinimumContentsScale(); |
| 1317 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 1318 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 1319 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); |
| 1320 } |
| 1321 return max_contents_scale; |
| 1322 } |
| 1323 |
| 1324 void PictureLayerImpl::UpdateIdealScales() { |
| 1325 if (!CanHaveTilings()) { |
| 1326 ideal_page_scale_ = draw_properties().page_scale_factor; |
| 1327 ideal_device_scale_ = draw_properties().device_scale_factor; |
| 1328 ideal_contents_scale_ = draw_properties().ideal_contents_scale; |
| 1329 ideal_source_scale_ = |
| 1330 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; |
| 1331 return; |
| 1332 } |
| 1333 |
| 1334 float min_contents_scale = MinimumContentsScale(); |
| 1335 DCHECK_GT(min_contents_scale, 0.f); |
| 1336 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); |
| 1337 DCHECK_GT(min_page_scale, 0.f); |
| 1338 float min_device_scale = 1.f; |
| 1339 float min_source_scale = |
| 1340 min_contents_scale / min_page_scale / min_device_scale; |
| 1341 |
| 1342 float ideal_page_scale = draw_properties().page_scale_factor; |
| 1343 float ideal_device_scale = draw_properties().device_scale_factor; |
| 1344 float ideal_source_scale = draw_properties().ideal_contents_scale / |
| 1345 ideal_page_scale / ideal_device_scale; |
| 1346 ideal_contents_scale_ = |
| 1347 std::max(draw_properties().ideal_contents_scale, min_contents_scale); |
| 1348 ideal_page_scale_ = draw_properties().page_scale_factor; |
| 1349 ideal_device_scale_ = draw_properties().device_scale_factor; |
| 1350 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); |
| 1351 } |
| 1352 |
| 1356 void PictureLayerImpl::GetDebugBorderProperties( | 1353 void PictureLayerImpl::GetDebugBorderProperties( |
| 1357 SkColor* color, | 1354 SkColor* color, |
| 1358 float* width) const { | 1355 float* width) const { |
| 1359 *color = DebugColors::TiledContentLayerBorderColor(); | 1356 *color = DebugColors::TiledContentLayerBorderColor(); |
| 1360 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); | 1357 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); |
| 1361 } | 1358 } |
| 1362 | 1359 |
| 1363 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1360 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
| 1364 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1361 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
| 1365 LayerImpl::AsValueInto(state); | 1362 LayerImpl::AsValueInto(state); |
| 1366 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 1363 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 1367 state->SetDouble("geometry_contents_scale", contents_scale_x()); | 1364 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); |
| 1368 state->Set("tilings", tilings_->AsValue().release()); | 1365 state->Set("tilings", tilings_->AsValue().release()); |
| 1369 state->Set("pictures", pile_->AsValue().release()); | 1366 state->Set("pictures", pile_->AsValue().release()); |
| 1370 state->Set("invalidation", invalidation_.AsValue().release()); | 1367 state->Set("invalidation", invalidation_.AsValue().release()); |
| 1371 | 1368 |
| 1372 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); | 1369 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); |
| 1373 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), | 1370 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), |
| 1374 contents_scale_x(), | 1371 contents_scale_x(), |
| 1375 gfx::Rect(content_bounds()), | 1372 gfx::Rect(content_bounds()), |
| 1376 ideal_contents_scale_); | 1373 ideal_contents_scale_); |
| 1377 iter; | 1374 iter; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 return iterator_index_ < iterators_.size(); | 1652 return iterator_index_ < iterators_.size(); |
| 1656 } | 1653 } |
| 1657 | 1654 |
| 1658 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1655 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
| 1659 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1656 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
| 1660 return it->get_type() == iteration_stage_ && | 1657 return it->get_type() == iteration_stage_ && |
| 1661 (**it)->required_for_activation() == required_for_activation_; | 1658 (**it)->required_for_activation() == required_for_activation_; |
| 1662 } | 1659 } |
| 1663 | 1660 |
| 1664 } // namespace cc | 1661 } // namespace cc |
| OLD | NEW |