| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 raster_page_scale_(0.f), | 78 raster_page_scale_(0.f), |
| 79 raster_device_scale_(0.f), | 79 raster_device_scale_(0.f), |
| 80 raster_source_scale_(0.f), | 80 raster_source_scale_(0.f), |
| 81 raster_contents_scale_(0.f), | 81 raster_contents_scale_(0.f), |
| 82 low_res_raster_contents_scale_(0.f), | 82 low_res_raster_contents_scale_(0.f), |
| 83 raster_source_scale_is_fixed_(false), | 83 raster_source_scale_is_fixed_(false), |
| 84 was_screen_space_transform_animating_(false), | 84 was_screen_space_transform_animating_(false), |
| 85 needs_post_commit_initialization_(true), | 85 needs_post_commit_initialization_(true), |
| 86 should_update_tile_priorities_(false), | 86 should_update_tile_priorities_(false), |
| 87 only_used_low_res_last_append_quads_(false), | 87 only_used_low_res_last_append_quads_(false), |
| 88 is_mask_(is_mask) { | 88 is_mask_(is_mask), |
| 89 nearest_neighbor_(false) { |
| 89 layer_tree_impl()->RegisterPictureLayerImpl(this); | 90 layer_tree_impl()->RegisterPictureLayerImpl(this); |
| 90 } | 91 } |
| 91 | 92 |
| 92 PictureLayerImpl::~PictureLayerImpl() { | 93 PictureLayerImpl::~PictureLayerImpl() { |
| 93 if (twin_layer_) | 94 if (twin_layer_) |
| 94 twin_layer_->twin_layer_ = nullptr; | 95 twin_layer_->twin_layer_ = nullptr; |
| 95 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 96 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
| 96 } | 97 } |
| 97 | 98 |
| 98 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue( | 99 scoped_ptr<TilingSetEvictionQueue> PictureLayerImpl::CreateEvictionQueue( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Twin relationships should never change once established. | 133 // Twin relationships should never change once established. |
| 133 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); | 134 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); |
| 134 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); | 135 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); |
| 135 // The twin relationship does not need to exist before the first | 136 // The twin relationship does not need to exist before the first |
| 136 // PushPropertiesTo from pending to active layer since before that the active | 137 // PushPropertiesTo from pending to active layer since before that the active |
| 137 // layer can not have a pile or tilings, it has only been created and inserted | 138 // layer can not have a pile or tilings, it has only been created and inserted |
| 138 // into the tree at that point. | 139 // into the tree at that point. |
| 139 twin_layer_ = layer_impl; | 140 twin_layer_ = layer_impl; |
| 140 layer_impl->twin_layer_ = this; | 141 layer_impl->twin_layer_ = this; |
| 141 | 142 |
| 143 layer_impl->SetNearestNeighbor(nearest_neighbor_); |
| 144 |
| 142 // Solid color layers have no tilings. | 145 // Solid color layers have no tilings. |
| 143 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); | 146 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); |
| 144 // The pending tree should only have a high res (and possibly low res) tiling. | 147 // The pending tree should only have a high res (and possibly low res) tiling. |
| 145 DCHECK_LE(tilings_->num_tilings(), | 148 DCHECK_LE(tilings_->num_tilings(), |
| 146 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); | 149 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); |
| 147 | 150 |
| 148 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, | 151 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, |
| 149 tilings_.get()); | 152 tilings_.get()); |
| 150 DCHECK(invalidation_.IsEmpty()); | 153 DCHECK(invalidation_.IsEmpty()); |
| 151 | 154 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 if (visible_geometry_rect.IsEmpty()) | 235 if (visible_geometry_rect.IsEmpty()) |
| 233 return; | 236 return; |
| 234 | 237 |
| 235 gfx::Size texture_size = scaled_visible_content_rect.size(); | 238 gfx::Size texture_size = scaled_visible_content_rect.size(); |
| 236 gfx::RectF texture_rect = gfx::RectF(texture_size); | 239 gfx::RectF texture_rect = gfx::RectF(texture_size); |
| 237 gfx::Rect quad_content_rect = scaled_visible_content_rect; | 240 gfx::Rect quad_content_rect = scaled_visible_content_rect; |
| 238 | 241 |
| 239 PictureDrawQuad* quad = | 242 PictureDrawQuad* quad = |
| 240 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 243 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
| 241 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 244 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
| 242 visible_geometry_rect, texture_rect, texture_size, RGBA_8888, | 245 visible_geometry_rect, texture_rect, texture_size, |
| 243 quad_content_rect, max_contents_scale, raster_source_); | 246 nearest_neighbor_, RGBA_8888, quad_content_rect, |
| 247 max_contents_scale, raster_source_); |
| 244 return; | 248 return; |
| 245 } | 249 } |
| 246 | 250 |
| 247 AppendDebugBorderQuad( | 251 AppendDebugBorderQuad( |
| 248 render_pass, scaled_content_bounds, shared_quad_state, append_quads_data); | 252 render_pass, scaled_content_bounds, shared_quad_state, append_quads_data); |
| 249 | 253 |
| 250 if (ShowDebugBorders()) { | 254 if (ShowDebugBorders()) { |
| 251 for (PictureLayerTilingSet::CoverageIterator iter( | 255 for (PictureLayerTilingSet::CoverageIterator iter( |
| 252 tilings_.get(), | 256 tilings_.get(), |
| 253 max_contents_scale, | 257 max_contents_scale, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 349 |
| 346 TileDrawQuad* quad = | 350 TileDrawQuad* quad = |
| 347 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 351 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 348 quad->SetNew(shared_quad_state, | 352 quad->SetNew(shared_quad_state, |
| 349 geometry_rect, | 353 geometry_rect, |
| 350 opaque_rect, | 354 opaque_rect, |
| 351 visible_geometry_rect, | 355 visible_geometry_rect, |
| 352 draw_info.get_resource_id(), | 356 draw_info.get_resource_id(), |
| 353 texture_rect, | 357 texture_rect, |
| 354 iter.texture_size(), | 358 iter.texture_size(), |
| 355 draw_info.contents_swizzled()); | 359 draw_info.contents_swizzled(), |
| 360 nearest_neighbor_); |
| 356 has_draw_quad = true; | 361 has_draw_quad = true; |
| 357 break; | 362 break; |
| 358 } | 363 } |
| 359 case ManagedTileState::DrawInfo::PICTURE_PILE_MODE: { | 364 case ManagedTileState::DrawInfo::PICTURE_PILE_MODE: { |
| 360 if (!layer_tree_impl() | 365 if (!layer_tree_impl() |
| 361 ->GetRendererCapabilities() | 366 ->GetRendererCapabilities() |
| 362 .allow_rasterize_on_demand) { | 367 .allow_rasterize_on_demand) { |
| 363 ++on_demand_missing_tile_count; | 368 ++on_demand_missing_tile_count; |
| 364 break; | 369 break; |
| 365 } | 370 } |
| 366 | 371 |
| 367 gfx::RectF texture_rect = iter.texture_rect(); | 372 gfx::RectF texture_rect = iter.texture_rect(); |
| 368 | 373 |
| 369 ResourceProvider* resource_provider = | 374 ResourceProvider* resource_provider = |
| 370 layer_tree_impl()->resource_provider(); | 375 layer_tree_impl()->resource_provider(); |
| 371 ResourceFormat format = | 376 ResourceFormat format = |
| 372 resource_provider->memory_efficient_texture_format(); | 377 resource_provider->memory_efficient_texture_format(); |
| 373 PictureDrawQuad* quad = | 378 PictureDrawQuad* quad = |
| 374 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 379 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
| 375 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 380 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
| 376 visible_geometry_rect, texture_rect, iter.texture_size(), | 381 visible_geometry_rect, texture_rect, iter.texture_size(), |
| 377 format, iter->content_rect(), iter->contents_scale(), | 382 nearest_neighbor_, format, iter->content_rect(), |
| 378 raster_source_); | 383 iter->contents_scale(), raster_source_); |
| 379 has_draw_quad = true; | 384 has_draw_quad = true; |
| 380 break; | 385 break; |
| 381 } | 386 } |
| 382 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: { | 387 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: { |
| 383 SolidColorDrawQuad* quad = | 388 SolidColorDrawQuad* quad = |
| 384 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 389 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 385 quad->SetNew(shared_quad_state, | 390 quad->SetNew(shared_quad_state, |
| 386 geometry_rect, | 391 geometry_rect, |
| 387 visible_geometry_rect, | 392 visible_geometry_rect, |
| 388 draw_info.get_solid_color(), | 393 draw_info.get_solid_color(), |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 if (!draw_info.IsReadyToDraw() || | 819 if (!draw_info.IsReadyToDraw() || |
| 815 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { | 820 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { |
| 816 *resource_id = 0; | 821 *resource_id = 0; |
| 817 return; | 822 return; |
| 818 } | 823 } |
| 819 | 824 |
| 820 *resource_id = draw_info.get_resource_id(); | 825 *resource_id = draw_info.get_resource_id(); |
| 821 *resource_size = iter.texture_size(); | 826 *resource_size = iter.texture_size(); |
| 822 } | 827 } |
| 823 | 828 |
| 829 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { |
| 830 if (nearest_neighbor_ == nearest_neighbor) |
| 831 return; |
| 832 |
| 833 nearest_neighbor_ = nearest_neighbor; |
| 834 NoteLayerPropertyChanged(); |
| 835 } |
| 836 |
| 824 void PictureLayerImpl::DoPostCommitInitialization() { | 837 void PictureLayerImpl::DoPostCommitInitialization() { |
| 825 // TODO(danakj): Remove this. | 838 // TODO(danakj): Remove this. |
| 826 DCHECK(needs_post_commit_initialization_); | 839 DCHECK(needs_post_commit_initialization_); |
| 827 DCHECK(layer_tree_impl()->IsPendingTree()); | 840 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 828 needs_post_commit_initialization_ = false; | 841 needs_post_commit_initialization_ = false; |
| 829 } | 842 } |
| 830 | 843 |
| 831 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 844 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
| 832 DCHECK(CanHaveTilingWithScale(contents_scale)) << | 845 DCHECK(CanHaveTilingWithScale(contents_scale)) << |
| 833 "contents_scale: " << contents_scale; | 846 "contents_scale: " << contents_scale; |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 | 1326 |
| 1314 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { | 1327 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { |
| 1315 if (!layer_tree_impl()->IsActiveTree()) | 1328 if (!layer_tree_impl()->IsActiveTree()) |
| 1316 return true; | 1329 return true; |
| 1317 | 1330 |
| 1318 return AllTilesRequiredAreReadyToDraw( | 1331 return AllTilesRequiredAreReadyToDraw( |
| 1319 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); | 1332 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); |
| 1320 } | 1333 } |
| 1321 | 1334 |
| 1322 } // namespace cc | 1335 } // namespace cc |
| OLD | NEW |