| 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 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 for (PictureLayerTilingSet::CoverageIterator iter( | 241 for (PictureLayerTilingSet::CoverageIterator iter( |
| 242 tilings_.get(), | 242 tilings_.get(), |
| 243 max_contents_scale, | 243 max_contents_scale, |
| 244 scaled_visible_content_rect, | 244 scaled_visible_content_rect, |
| 245 ideal_contents_scale_); | 245 ideal_contents_scale_); |
| 246 iter; | 246 iter; |
| 247 ++iter) { | 247 ++iter) { |
| 248 SkColor color; | 248 SkColor color; |
| 249 float width; | 249 float width; |
| 250 if (*iter && iter->IsReadyToDraw()) { | 250 if (*iter && iter->IsReadyToDraw()) { |
| 251 ManagedTileState::TileVersion::Mode mode = | 251 ManagedTileState::DrawInfo::Mode mode = iter->draw_info().mode(); |
| 252 iter->GetTileVersionForDrawing().mode(); | 252 if (mode == ManagedTileState::DrawInfo::SOLID_COLOR_MODE) { |
| 253 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | |
| 254 color = DebugColors::SolidColorTileBorderColor(); | 253 color = DebugColors::SolidColorTileBorderColor(); |
| 255 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 254 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| 256 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { | 255 } else if (mode == ManagedTileState::DrawInfo::PICTURE_PILE_MODE) { |
| 257 color = DebugColors::PictureTileBorderColor(); | 256 color = DebugColors::PictureTileBorderColor(); |
| 258 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 257 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
| 259 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 258 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
| 260 color = DebugColors::HighResTileBorderColor(); | 259 color = DebugColors::HighResTileBorderColor(); |
| 261 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 260 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
| 262 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 261 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
| 263 color = DebugColors::LowResTileBorderColor(); | 262 color = DebugColors::LowResTileBorderColor(); |
| 264 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 263 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
| 265 } else if (iter->contents_scale() > max_contents_scale) { | 264 } else if (iter->contents_scale() > max_contents_scale) { |
| 266 color = DebugColors::ExtraHighResTileBorderColor(); | 265 color = DebugColors::ExtraHighResTileBorderColor(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 gfx::Rect visible_geometry_rect = | 308 gfx::Rect visible_geometry_rect = |
| 310 occlusion.GetUnoccludedContentRect(geometry_rect); | 309 occlusion.GetUnoccludedContentRect(geometry_rect); |
| 311 if (visible_geometry_rect.IsEmpty()) | 310 if (visible_geometry_rect.IsEmpty()) |
| 312 continue; | 311 continue; |
| 313 | 312 |
| 314 append_quads_data->visible_content_area += | 313 append_quads_data->visible_content_area += |
| 315 visible_geometry_rect.width() * visible_geometry_rect.height(); | 314 visible_geometry_rect.width() * visible_geometry_rect.height(); |
| 316 | 315 |
| 317 bool has_draw_quad = false; | 316 bool has_draw_quad = false; |
| 318 if (*iter && iter->IsReadyToDraw()) { | 317 if (*iter && iter->IsReadyToDraw()) { |
| 319 const ManagedTileState::TileVersion& tile_version = | 318 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); |
| 320 iter->GetTileVersionForDrawing(); | 319 switch (draw_info.mode()) { |
| 321 switch (tile_version.mode()) { | 320 case ManagedTileState::DrawInfo::RESOURCE_MODE: { |
| 322 case ManagedTileState::TileVersion::RESOURCE_MODE: { | |
| 323 gfx::RectF texture_rect = iter.texture_rect(); | 321 gfx::RectF texture_rect = iter.texture_rect(); |
| 324 | 322 |
| 325 // The raster_contents_scale_ is the best scale that the layer is | 323 // The raster_contents_scale_ is the best scale that the layer is |
| 326 // trying to produce, even though it may not be ideal. Since that's | 324 // trying to produce, even though it may not be ideal. Since that's |
| 327 // the best the layer can promise in the future, consider those as | 325 // the best the layer can promise in the future, consider those as |
| 328 // complete. But if a tile is ideal scale, we don't want to consider | 326 // complete. But if a tile is ideal scale, we don't want to consider |
| 329 // it incomplete and trying to replace it with a tile at a worse | 327 // it incomplete and trying to replace it with a tile at a worse |
| 330 // scale. | 328 // scale. |
| 331 if (iter->contents_scale() != raster_contents_scale_ && | 329 if (iter->contents_scale() != raster_contents_scale_ && |
| 332 iter->contents_scale() != ideal_contents_scale_ && | 330 iter->contents_scale() != ideal_contents_scale_ && |
| 333 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { | 331 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { |
| 334 append_quads_data->num_incomplete_tiles++; | 332 append_quads_data->num_incomplete_tiles++; |
| 335 } | 333 } |
| 336 | 334 |
| 337 TileDrawQuad* quad = | 335 TileDrawQuad* quad = |
| 338 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 336 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 339 quad->SetNew(shared_quad_state, | 337 quad->SetNew(shared_quad_state, |
| 340 geometry_rect, | 338 geometry_rect, |
| 341 opaque_rect, | 339 opaque_rect, |
| 342 visible_geometry_rect, | 340 visible_geometry_rect, |
| 343 tile_version.get_resource_id(), | 341 draw_info.get_resource_id(), |
| 344 texture_rect, | 342 texture_rect, |
| 345 iter.texture_size(), | 343 iter.texture_size(), |
| 346 tile_version.contents_swizzled()); | 344 draw_info.contents_swizzled()); |
| 347 has_draw_quad = true; | 345 has_draw_quad = true; |
| 348 break; | 346 break; |
| 349 } | 347 } |
| 350 case ManagedTileState::TileVersion::PICTURE_PILE_MODE: { | 348 case ManagedTileState::DrawInfo::PICTURE_PILE_MODE: { |
| 351 if (!layer_tree_impl() | 349 if (!layer_tree_impl() |
| 352 ->GetRendererCapabilities() | 350 ->GetRendererCapabilities() |
| 353 .allow_rasterize_on_demand) { | 351 .allow_rasterize_on_demand) { |
| 354 ++on_demand_missing_tile_count; | 352 ++on_demand_missing_tile_count; |
| 355 break; | 353 break; |
| 356 } | 354 } |
| 357 | 355 |
| 358 gfx::RectF texture_rect = iter.texture_rect(); | 356 gfx::RectF texture_rect = iter.texture_rect(); |
| 359 | 357 |
| 360 ResourceProvider* resource_provider = | 358 ResourceProvider* resource_provider = |
| 361 layer_tree_impl()->resource_provider(); | 359 layer_tree_impl()->resource_provider(); |
| 362 ResourceFormat format = | 360 ResourceFormat format = |
| 363 resource_provider->memory_efficient_texture_format(); | 361 resource_provider->memory_efficient_texture_format(); |
| 364 PictureDrawQuad* quad = | 362 PictureDrawQuad* quad = |
| 365 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 363 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
| 366 quad->SetNew(shared_quad_state, | 364 quad->SetNew(shared_quad_state, |
| 367 geometry_rect, | 365 geometry_rect, |
| 368 opaque_rect, | 366 opaque_rect, |
| 369 visible_geometry_rect, | 367 visible_geometry_rect, |
| 370 texture_rect, | 368 texture_rect, |
| 371 iter.texture_size(), | 369 iter.texture_size(), |
| 372 format, | 370 format, |
| 373 iter->content_rect(), | 371 iter->content_rect(), |
| 374 iter->contents_scale(), | 372 iter->contents_scale(), |
| 375 pile_); | 373 pile_); |
| 376 has_draw_quad = true; | 374 has_draw_quad = true; |
| 377 break; | 375 break; |
| 378 } | 376 } |
| 379 case ManagedTileState::TileVersion::SOLID_COLOR_MODE: { | 377 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: { |
| 380 SolidColorDrawQuad* quad = | 378 SolidColorDrawQuad* quad = |
| 381 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 379 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 382 quad->SetNew(shared_quad_state, | 380 quad->SetNew(shared_quad_state, |
| 383 geometry_rect, | 381 geometry_rect, |
| 384 visible_geometry_rect, | 382 visible_geometry_rect, |
| 385 tile_version.get_solid_color(), | 383 draw_info.get_solid_color(), |
| 386 false); | 384 false); |
| 387 has_draw_quad = true; | 385 has_draw_quad = true; |
| 388 break; | 386 break; |
| 389 } | 387 } |
| 390 } | 388 } |
| 391 } | 389 } |
| 392 | 390 |
| 393 if (!has_draw_quad) { | 391 if (!has_draw_quad) { |
| 394 if (draw_checkerboard_for_missing_tiles()) { | 392 if (draw_checkerboard_for_missing_tiles()) { |
| 395 CheckerboardDrawQuad* quad = | 393 CheckerboardDrawQuad* quad = |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 781 |
| 784 // Mask resource not ready yet. | 782 // Mask resource not ready yet. |
| 785 if (!iter || !*iter) | 783 if (!iter || !*iter) |
| 786 return 0; | 784 return 0; |
| 787 | 785 |
| 788 // Masks only supported if they fit on exactly one tile. | 786 // Masks only supported if they fit on exactly one tile. |
| 789 DCHECK(iter.geometry_rect() == content_rect) | 787 DCHECK(iter.geometry_rect() == content_rect) |
| 790 << "iter rect " << iter.geometry_rect().ToString() << " content rect " | 788 << "iter rect " << iter.geometry_rect().ToString() << " content rect " |
| 791 << content_rect.ToString(); | 789 << content_rect.ToString(); |
| 792 | 790 |
| 793 const ManagedTileState::TileVersion& tile_version = | 791 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); |
| 794 iter->GetTileVersionForDrawing(); | 792 if (!draw_info.IsReadyToDraw() || |
| 795 if (!tile_version.IsReadyToDraw() || | 793 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) |
| 796 tile_version.mode() != ManagedTileState::TileVersion::RESOURCE_MODE) | |
| 797 return 0; | 794 return 0; |
| 798 | 795 |
| 799 return tile_version.get_resource_id(); | 796 return draw_info.get_resource_id(); |
| 800 } | 797 } |
| 801 | 798 |
| 802 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { | 799 void PictureLayerImpl::MarkVisibleResourcesAsRequired() const { |
| 803 DCHECK(layer_tree_impl()->IsPendingTree()); | 800 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 804 DCHECK(ideal_contents_scale_); | 801 DCHECK(ideal_contents_scale_); |
| 805 DCHECK_GT(tilings_->num_tilings(), 0u); | 802 DCHECK_GT(tilings_->num_tilings(), 0u); |
| 806 | 803 |
| 807 // The goal of this function is to find the minimum set of tiles that need to | 804 // The goal of this function is to find the minimum set of tiles that need to |
| 808 // be ready to draw in order to activate without flashing content from a | 805 // be ready to draw in order to activate without flashing content from a |
| 809 // higher res on the active tree to a lower res on the pending tree. | 806 // higher res on the active tree to a lower res on the pending tree. |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1785 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
| 1789 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1786 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
| 1790 return tiling_range.end - 1 - current_tiling_range_offset; | 1787 return tiling_range.end - 1 - current_tiling_range_offset; |
| 1791 } | 1788 } |
| 1792 } | 1789 } |
| 1793 NOTREACHED(); | 1790 NOTREACHED(); |
| 1794 return 0; | 1791 return 0; |
| 1795 } | 1792 } |
| 1796 | 1793 |
| 1797 } // namespace cc | 1794 } // namespace cc |
| OLD | NEW |