Chromium Code Reviews| 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 = MaximumTilingContentScale(); | |
| 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(); | 186 float contents_scale = max_contents_scale; |
|
enne (OOO)
2014/06/03 19:14:47
Can you remove this temporary to improve readabili
sohanjg
2014/06/04 10:32:41
Done.
| |
| 169 | 187 |
| 170 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 188 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 171 quad->SetNew(shared_quad_state, | 189 quad->SetNew(shared_quad_state, |
| 172 geometry_rect, | 190 geometry_rect, |
| 173 opaque_rect, | 191 opaque_rect, |
| 174 visible_geometry_rect, | 192 visible_geometry_rect, |
| 175 texture_rect, | 193 texture_rect, |
| 176 texture_size, | 194 texture_size, |
| 177 RGBA_8888, | 195 RGBA_8888, |
| 178 quad_content_rect, | 196 quad_content_rect, |
| 179 contents_scale, | 197 contents_scale, |
| 180 pile_); | 198 pile_); |
| 181 quad_sink->Append(quad.PassAs<DrawQuad>()); | 199 quad_sink->Append(quad.PassAs<DrawQuad>()); |
| 182 append_quads_data->num_missing_tiles++; | 200 append_quads_data->num_missing_tiles++; |
| 183 return; | 201 return; |
| 184 } | 202 } |
| 185 | 203 |
| 186 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 204 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 187 | 205 |
| 188 if (ShowDebugBorders()) { | 206 if (ShowDebugBorders()) { |
| 189 for (PictureLayerTilingSet::CoverageIterator iter( | 207 for (PictureLayerTilingSet::CoverageIterator iter( |
| 190 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 208 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); |
| 191 iter; | 209 iter; |
| 192 ++iter) { | 210 ++iter) { |
| 193 SkColor color; | 211 SkColor color; |
| 194 float width; | 212 float width; |
| 195 if (*iter && iter->IsReadyToDraw()) { | 213 if (*iter && iter->IsReadyToDraw()) { |
| 196 ManagedTileState::TileVersion::Mode mode = | 214 ManagedTileState::TileVersion::Mode mode = |
| 197 iter->GetTileVersionForDrawing().mode(); | 215 iter->GetTileVersionForDrawing().mode(); |
| 198 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | 216 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { |
| 199 color = DebugColors::SolidColorTileBorderColor(); | 217 color = DebugColors::SolidColorTileBorderColor(); |
| 200 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 218 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| 201 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { | 219 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { |
| 202 color = DebugColors::PictureTileBorderColor(); | 220 color = DebugColors::PictureTileBorderColor(); |
| 203 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 221 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
| 204 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 222 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
| 205 color = DebugColors::HighResTileBorderColor(); | 223 color = DebugColors::HighResTileBorderColor(); |
| 206 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 224 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
| 207 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 225 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
| 208 color = DebugColors::LowResTileBorderColor(); | 226 color = DebugColors::LowResTileBorderColor(); |
| 209 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 227 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
| 210 } else if (iter->contents_scale() > contents_scale_x()) { | 228 } else if (iter->contents_scale() > max_contents_scale) { |
| 211 color = DebugColors::ExtraHighResTileBorderColor(); | 229 color = DebugColors::ExtraHighResTileBorderColor(); |
| 212 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 230 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
| 213 } else { | 231 } else { |
| 214 color = DebugColors::ExtraLowResTileBorderColor(); | 232 color = DebugColors::ExtraLowResTileBorderColor(); |
| 215 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 233 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
| 216 } | 234 } |
| 217 } else { | 235 } else { |
| 218 color = DebugColors::MissingTileBorderColor(); | 236 color = DebugColors::MissingTileBorderColor(); |
| 219 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); | 237 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); |
| 220 } | 238 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 232 } | 250 } |
| 233 } | 251 } |
| 234 | 252 |
| 235 // Keep track of the tilings that were used so that tilings that are | 253 // Keep track of the tilings that were used so that tilings that are |
| 236 // unused can be considered for removal. | 254 // unused can be considered for removal. |
| 237 std::vector<PictureLayerTiling*> seen_tilings; | 255 std::vector<PictureLayerTiling*> seen_tilings; |
| 238 | 256 |
| 239 size_t missing_tile_count = 0u; | 257 size_t missing_tile_count = 0u; |
| 240 size_t on_demand_missing_tile_count = 0u; | 258 size_t on_demand_missing_tile_count = 0u; |
| 241 for (PictureLayerTilingSet::CoverageIterator iter( | 259 for (PictureLayerTilingSet::CoverageIterator iter( |
| 242 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 260 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); |
| 243 iter; | 261 iter; |
| 244 ++iter) { | 262 ++iter) { |
| 245 gfx::Rect geometry_rect = iter.geometry_rect(); | 263 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 246 gfx::Rect visible_geometry_rect = | 264 gfx::Rect visible_geometry_rect = |
| 247 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 265 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); |
| 248 if (visible_geometry_rect.IsEmpty()) | 266 if (visible_geometry_rect.IsEmpty()) |
| 249 continue; | 267 continue; |
| 250 | 268 |
| 251 append_quads_data->visible_content_area += | 269 append_quads_data->visible_content_area += |
| 252 visible_geometry_rect.width() * visible_geometry_rect.height(); | 270 visible_geometry_rect.width() * visible_geometry_rect.height(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 | 393 |
| 376 void PictureLayerImpl::DidUnregisterLayer() { | 394 void PictureLayerImpl::DidUnregisterLayer() { |
| 377 TRACE_EVENT0("cc", "PictureLayerImpl::DidUnregisterLayer"); | 395 TRACE_EVENT0("cc", "PictureLayerImpl::DidUnregisterLayer"); |
| 378 | 396 |
| 379 layer_needs_to_register_itself_ = true; | 397 layer_needs_to_register_itself_ = true; |
| 380 } | 398 } |
| 381 | 399 |
| 382 void PictureLayerImpl::UpdateTilePriorities() { | 400 void PictureLayerImpl::UpdateTilePriorities() { |
| 383 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); | 401 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); |
| 384 | 402 |
| 385 DCHECK(!needs_post_commit_initialization_); | 403 DoPostCommitInitializationIfNeeded(); |
| 386 CHECK(should_update_tile_priorities_); | 404 UpdateIdealScales(); |
| 405 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a | |
| 406 // non-updated tree which will then be updated immediately afterwards. | |
| 407 should_update_tile_priorities_ = true; | |
| 408 if (CanHaveTilings()) { | |
| 409 ManageTilings(draw_properties().screen_space_transform_is_animating, | |
| 410 draw_properties().maximum_animation_contents_scale); | |
| 411 } | |
| 387 | 412 |
| 388 if (layer_needs_to_register_itself_) { | 413 if (layer_needs_to_register_itself_) { |
| 389 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); | 414 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); |
| 390 layer_needs_to_register_itself_ = false; | 415 layer_needs_to_register_itself_ = false; |
| 391 } | 416 } |
| 392 | 417 |
| 393 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 418 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
| 394 visible_rect_for_tile_priority_ = visible_content_rect(); | 419 visible_rect_for_tile_priority_ = visible_content_rect(); |
| 395 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 420 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
| 396 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 421 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 425 &screen_to_layer)) { | 450 &screen_to_layer)) { |
| 426 visible_rect_in_content_space = | 451 visible_rect_in_content_space = |
| 427 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 452 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 428 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); | 453 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); |
| 429 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); | 454 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); |
| 430 } | 455 } |
| 431 } | 456 } |
| 432 | 457 |
| 433 WhichTree tree = | 458 WhichTree tree = |
| 434 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | 459 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 435 | |
| 436 tilings_->UpdateTilePriorities(tree, | 460 tilings_->UpdateTilePriorities(tree, |
| 437 visible_rect_in_content_space, | 461 visible_rect_in_content_space, |
| 438 contents_scale_x(), | 462 MaximumTilingContentScale(), |
|
enne (OOO)
2014/06/03 19:14:47
I think this is still wrong. visible_rect_in_conte
| |
| 439 current_frame_time_in_seconds); | 463 current_frame_time_in_seconds); |
| 440 | 464 |
| 441 if (layer_tree_impl()->IsPendingTree()) | 465 if (layer_tree_impl()->IsPendingTree()) |
| 442 MarkVisibleResourcesAsRequired(); | 466 MarkVisibleResourcesAsRequired(); |
| 443 | 467 |
| 444 // Tile priorities were modified. | 468 // Tile priorities were modified. |
| 445 layer_tree_impl()->DidModifyTilePriorities(); | 469 layer_tree_impl()->DidModifyTilePriorities(); |
| 446 } | 470 } |
| 447 | 471 |
| 448 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 472 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 468 RemoveAllTilings(); | 492 RemoveAllTilings(); |
| 469 | 493 |
| 470 ResetRasterScale(); | 494 ResetRasterScale(); |
| 471 | 495 |
| 472 // To avoid an edge case after lost context where the tree is up to date but | 496 // 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 | 497 // the tilings have not been managed, request an update draw properties |
| 474 // to force tilings to get managed. | 498 // to force tilings to get managed. |
| 475 layer_tree_impl()->set_needs_update_draw_properties(); | 499 layer_tree_impl()->set_needs_update_draw_properties(); |
| 476 } | 500 } |
| 477 | 501 |
| 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() { | 502 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
| 547 return pile_->GetFlattenedPicture(); | 503 return pile_->GetFlattenedPicture(); |
| 548 } | 504 } |
| 549 | 505 |
| 550 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 506 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
| 551 const gfx::Rect& content_rect) { | 507 const gfx::Rect& content_rect) { |
| 552 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) | 508 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) |
| 553 return scoped_refptr<Tile>(); | 509 return scoped_refptr<Tile>(); |
| 554 | 510 |
| 555 int flags = 0; | 511 int flags = 0; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 void PictureLayerImpl::SetIsMask(bool is_mask) { | 721 void PictureLayerImpl::SetIsMask(bool is_mask) { |
| 766 if (is_mask_ == is_mask) | 722 if (is_mask_ == is_mask) |
| 767 return; | 723 return; |
| 768 is_mask_ = is_mask; | 724 is_mask_ = is_mask; |
| 769 if (tilings_) | 725 if (tilings_) |
| 770 tilings_->RemoveAllTiles(); | 726 tilings_->RemoveAllTiles(); |
| 771 } | 727 } |
| 772 | 728 |
| 773 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 729 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
| 774 gfx::Rect content_rect(content_bounds()); | 730 gfx::Rect content_rect(content_bounds()); |
| 775 float scale = contents_scale_x(); | 731 float scale = MaximumTilingContentScale(); |
| 776 PictureLayerTilingSet::CoverageIterator iter( | 732 PictureLayerTilingSet::CoverageIterator iter( |
| 777 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 733 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
| 778 | 734 |
| 779 // Mask resource not ready yet. | 735 // Mask resource not ready yet. |
| 780 if (!iter || !*iter) | 736 if (!iter || !*iter) |
| 781 return 0; | 737 return 0; |
| 782 | 738 |
| 783 // Masks only supported if they fit on exactly one tile. | 739 // Masks only supported if they fit on exactly one tile. |
| 784 if (iter.geometry_rect() != content_rect) | 740 if (iter.geometry_rect() != content_rect) |
| 785 return 0; | 741 return 0; |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1333 } | 1289 } |
| 1334 if (tilings_->num_tilings() == 0) | 1290 if (tilings_->num_tilings() == 0) |
| 1335 return; | 1291 return; |
| 1336 | 1292 |
| 1337 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1293 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
| 1338 // tiling to mark its tiles as being required for activation. | 1294 // tiling to mark its tiles as being required for activation. |
| 1339 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1295 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
| 1340 #endif | 1296 #endif |
| 1341 } | 1297 } |
| 1342 | 1298 |
| 1299 float PictureLayerImpl::MaximumTilingContentScale() const { | |
| 1300 float max_contents_scale = MinimumContentsScale(); | |
| 1301 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
| 1302 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | |
| 1303 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | |
| 1304 } | |
| 1305 return max_contents_scale; | |
| 1306 } | |
| 1307 | |
| 1308 void PictureLayerImpl::UpdateIdealScales() { | |
| 1309 if (!CanHaveTilings()) { | |
| 1310 ideal_page_scale_ = draw_properties().page_scale_factor; | |
| 1311 ideal_device_scale_ = draw_properties().device_scale_factor; | |
| 1312 ideal_contents_scale_ = draw_properties().ideal_contents_scale; | |
| 1313 ideal_source_scale_ = | |
| 1314 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | |
| 1315 return; | |
| 1316 } | |
| 1317 | |
| 1318 float min_contents_scale = MinimumContentsScale(); | |
| 1319 DCHECK_GT(min_contents_scale, 0.f); | |
| 1320 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | |
| 1321 DCHECK_GT(min_page_scale, 0.f); | |
| 1322 float min_device_scale = 1.f; | |
| 1323 float min_source_scale = | |
| 1324 min_contents_scale / min_page_scale / min_device_scale; | |
| 1325 | |
| 1326 float ideal_page_scale = draw_properties().page_scale_factor; | |
| 1327 float ideal_device_scale = draw_properties().device_scale_factor; | |
| 1328 float ideal_source_scale = draw_properties().ideal_contents_scale / | |
| 1329 ideal_page_scale / ideal_device_scale; | |
| 1330 ideal_contents_scale_ = | |
| 1331 std::max(draw_properties().ideal_contents_scale, min_contents_scale); | |
| 1332 ideal_page_scale_ = draw_properties().page_scale_factor; | |
| 1333 ideal_device_scale_ = draw_properties().device_scale_factor; | |
| 1334 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | |
| 1335 } | |
| 1336 | |
| 1343 void PictureLayerImpl::GetDebugBorderProperties( | 1337 void PictureLayerImpl::GetDebugBorderProperties( |
| 1344 SkColor* color, | 1338 SkColor* color, |
| 1345 float* width) const { | 1339 float* width) const { |
| 1346 *color = DebugColors::TiledContentLayerBorderColor(); | 1340 *color = DebugColors::TiledContentLayerBorderColor(); |
| 1347 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); | 1341 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); |
| 1348 } | 1342 } |
| 1349 | 1343 |
| 1350 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1344 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
| 1351 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1345 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
| 1352 LayerImpl::AsValueInto(state); | 1346 LayerImpl::AsValueInto(state); |
| 1353 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 1347 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 1354 state->SetDouble("geometry_contents_scale", contents_scale_x()); | 1348 state->SetDouble("geometry_contents_scale", MaximumTilingContentScale()); |
| 1355 state->Set("tilings", tilings_->AsValue().release()); | 1349 state->Set("tilings", tilings_->AsValue().release()); |
| 1356 state->Set("pictures", pile_->AsValue().release()); | 1350 state->Set("pictures", pile_->AsValue().release()); |
| 1357 state->Set("invalidation", invalidation_.AsValue().release()); | 1351 state->Set("invalidation", invalidation_.AsValue().release()); |
| 1358 | 1352 |
| 1359 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); | 1353 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); |
| 1360 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), | 1354 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), |
| 1361 contents_scale_x(), | 1355 contents_scale_x(), |
| 1362 gfx::Rect(content_bounds()), | 1356 gfx::Rect(content_bounds()), |
| 1363 ideal_contents_scale_); | 1357 ideal_contents_scale_); |
| 1364 iter; | 1358 iter; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1639 return iterator_index_ < iterators_.size(); | 1633 return iterator_index_ < iterators_.size(); |
| 1640 } | 1634 } |
| 1641 | 1635 |
| 1642 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1636 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
| 1643 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1637 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
| 1644 return it->get_type() == iteration_stage_ && | 1638 return it->get_type() == iteration_stage_ && |
| 1645 (**it)->required_for_activation() == required_for_activation_; | 1639 (**it)->required_for_activation() == required_for_activation_; |
| 1646 } | 1640 } |
| 1647 | 1641 |
| 1648 } // namespace cc | 1642 } // namespace cc |
| OLD | NEW |