| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 float width; | 172 float width; |
| 173 if (*iter && iter->IsReadyToDraw()) { | 173 if (*iter && iter->IsReadyToDraw()) { |
| 174 ManagedTileState::TileVersion::Mode mode = | 174 ManagedTileState::TileVersion::Mode mode = |
| 175 iter->GetTileVersionForDrawing().mode(); | 175 iter->GetTileVersionForDrawing().mode(); |
| 176 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | 176 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { |
| 177 color = DebugColors::SolidColorTileBorderColor(); | 177 color = DebugColors::SolidColorTileBorderColor(); |
| 178 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 178 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| 179 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { | 179 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { |
| 180 color = DebugColors::PictureTileBorderColor(); | 180 color = DebugColors::PictureTileBorderColor(); |
| 181 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 181 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
| 182 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 182 } else if (iter.priority().resolution == HIGH_RESOLUTION) { |
| 183 color = DebugColors::HighResTileBorderColor(); | 183 color = DebugColors::HighResTileBorderColor(); |
| 184 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 184 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
| 185 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 185 } else if (iter.priority().resolution == LOW_RESOLUTION) { |
| 186 color = DebugColors::LowResTileBorderColor(); | 186 color = DebugColors::LowResTileBorderColor(); |
| 187 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 187 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
| 188 } else if (iter->contents_scale() > contents_scale_x()) { | 188 } else if (iter->contents_scale() > contents_scale_x()) { |
| 189 color = DebugColors::ExtraHighResTileBorderColor(); | 189 color = DebugColors::ExtraHighResTileBorderColor(); |
| 190 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 190 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
| 191 } else { | 191 } else { |
| 192 color = DebugColors::ExtraLowResTileBorderColor(); | 192 color = DebugColors::ExtraLowResTileBorderColor(); |
| 193 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 193 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
| 194 } | 194 } |
| 195 } else { | 195 } else { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 pile_.get(), | 472 pile_.get(), |
| 473 content_rect.size(), | 473 content_rect.size(), |
| 474 content_rect, | 474 content_rect, |
| 475 contents_opaque() ? content_rect : gfx::Rect(), | 475 contents_opaque() ? content_rect : gfx::Rect(), |
| 476 tiling->contents_scale(), | 476 tiling->contents_scale(), |
| 477 id(), | 477 id(), |
| 478 layer_tree_impl()->source_frame_number(), | 478 layer_tree_impl()->source_frame_number(), |
| 479 is_using_lcd_text_); | 479 is_using_lcd_text_); |
| 480 } | 480 } |
| 481 | 481 |
| 482 scoped_refptr<TileBundle> PictureLayerImpl::CreateTileBundle(int offset_x, |
| 483 int offset_y, |
| 484 int width, |
| 485 int height) { |
| 486 return layer_tree_impl()->tile_manager()->CreateTileBundle( |
| 487 offset_x, offset_y, width, height); |
| 488 } |
| 489 |
| 482 void PictureLayerImpl::UpdatePile(Tile* tile) { | 490 void PictureLayerImpl::UpdatePile(Tile* tile) { |
| 483 tile->set_picture_pile(pile_); | 491 tile->set_picture_pile(pile_); |
| 484 } | 492 } |
| 485 | 493 |
| 486 const Region* PictureLayerImpl::GetInvalidation() { | 494 const Region* PictureLayerImpl::GetInvalidation() { |
| 487 return &invalidation_; | 495 return &invalidation_; |
| 488 } | 496 } |
| 489 | 497 |
| 490 const PictureLayerTiling* PictureLayerImpl::GetTwinTiling( | 498 const PictureLayerTiling* PictureLayerImpl::GetTwinTiling( |
| 491 const PictureLayerTiling* tiling) const { | 499 const PictureLayerTiling* tiling) const { |
| 492 | 500 |
| 493 if (!twin_layer_) | 501 if (!twin_layer_) |
| 494 return NULL; | 502 return NULL; |
| 495 for (size_t i = 0; i < twin_layer_->tilings_->num_tilings(); ++i) | 503 for (size_t i = 0; i < twin_layer_->tilings_->num_tilings(); ++i) |
| 496 if (twin_layer_->tilings_->tiling_at(i)->contents_scale() == | 504 if (twin_layer_->tilings_->tiling_at(i)->contents_scale() == |
| 497 tiling->contents_scale()) | 505 tiling->contents_scale()) |
| 498 return twin_layer_->tilings_->tiling_at(i); | 506 return twin_layer_->tilings_->tiling_at(i); |
| 499 return NULL; | 507 return NULL; |
| 500 } | 508 } |
| 501 | 509 |
| 510 bool PictureLayerImpl::IsActive() const { |
| 511 return layer_tree_impl()->IsActiveTree(); |
| 512 } |
| 513 |
| 514 bool PictureLayerImpl::IsPending() const { |
| 515 return layer_tree_impl()->IsPendingTree(); |
| 516 } |
| 517 |
| 502 gfx::Size PictureLayerImpl::CalculateTileSize( | 518 gfx::Size PictureLayerImpl::CalculateTileSize( |
| 503 gfx::Size content_bounds) const { | 519 gfx::Size content_bounds) const { |
| 504 if (is_mask_) { | 520 if (is_mask_) { |
| 505 int max_size = layer_tree_impl()->MaxTextureSize(); | 521 int max_size = layer_tree_impl()->MaxTextureSize(); |
| 506 return gfx::Size( | 522 return gfx::Size( |
| 507 std::min(max_size, content_bounds.width()), | 523 std::min(max_size, content_bounds.width()), |
| 508 std::min(max_size, content_bounds.height())); | 524 std::min(max_size, content_bounds.height())); |
| 509 } | 525 } |
| 510 | 526 |
| 511 int max_texture_size = | 527 int max_texture_size = |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 contents_scale_x(), | 721 contents_scale_x(), |
| 706 rect); | 722 rect); |
| 707 iter; | 723 iter; |
| 708 ++iter) { | 724 ++iter) { |
| 709 if (!*iter || !iter->IsReadyToDraw()) | 725 if (!*iter || !iter->IsReadyToDraw()) |
| 710 continue; | 726 continue; |
| 711 | 727 |
| 712 // This iteration is over the visible content rect which is potentially | 728 // This iteration is over the visible content rect which is potentially |
| 713 // less conservative than projecting the viewport into the layer. | 729 // less conservative than projecting the viewport into the layer. |
| 714 // Ignore tiles that are know to be outside the viewport. | 730 // Ignore tiles that are know to be outside the viewport. |
| 715 if (iter->priority(PENDING_TREE).distance_to_visible_in_pixels != 0) | 731 if (iter.priority().distance_to_visible_in_pixels != 0) |
| 716 continue; | 732 continue; |
| 717 | 733 |
| 718 missing_region.Subtract(iter.geometry_rect()); | 734 missing_region.Subtract(iter.geometry_rect()); |
| 719 iter->MarkRequiredForActivation(); | 735 iter->MarkRequiredForActivation(); |
| 720 } | 736 } |
| 721 } | 737 } |
| 722 DCHECK(high_res) << "There must be one high res tiling"; | 738 DCHECK(high_res) << "There must be one high res tiling"; |
| 723 | 739 |
| 724 // If these pointers are null (because no twin, no matching tiling, or the | 740 // If these pointers are null (because no twin, no matching tiling, or the |
| 725 // simpification just below), then high res tiles will be required to fill any | 741 // simpification just below), then high res tiles will be required to fill any |
| (...skipping 29 matching lines...) Expand all Loading... |
| 755 low_res, twin_low_res, contents_scale_x(), rect, &missing_region); | 771 low_res, twin_low_res, contents_scale_x(), rect, &missing_region); |
| 756 } | 772 } |
| 757 } | 773 } |
| 758 | 774 |
| 759 bool PictureLayerImpl::MarkVisibleTilesAsRequired( | 775 bool PictureLayerImpl::MarkVisibleTilesAsRequired( |
| 760 PictureLayerTiling* tiling, | 776 PictureLayerTiling* tiling, |
| 761 const PictureLayerTiling* optional_twin_tiling, | 777 const PictureLayerTiling* optional_twin_tiling, |
| 762 float contents_scale, | 778 float contents_scale, |
| 763 gfx::Rect rect, | 779 gfx::Rect rect, |
| 764 Region* missing_region) const { | 780 Region* missing_region) const { |
| 781 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 782 |
| 765 bool twin_had_missing_tile = false; | 783 bool twin_had_missing_tile = false; |
| 766 for (PictureLayerTiling::CoverageIterator iter(tiling, | 784 for (PictureLayerTiling::CoverageIterator iter(tiling, |
| 767 contents_scale, | 785 contents_scale, |
| 768 rect); | 786 rect); |
| 769 iter; | 787 iter; |
| 770 ++iter) { | 788 ++iter) { |
| 771 Tile* tile = *iter; | 789 Tile* tile = *iter; |
| 772 // A null tile (i.e. missing recording) can just be skipped. | 790 // A null tile (i.e. missing recording) can just be skipped. |
| 773 if (!tile) | 791 if (!tile) |
| 774 continue; | 792 continue; |
| 775 | 793 |
| 776 // This iteration is over the visible content rect which is potentially | 794 // This iteration is over the visible content rect which is potentially |
| 777 // less conservative than projecting the viewport into the layer. | 795 // less conservative than projecting the viewport into the layer. |
| 778 // Ignore tiles that are know to be outside the viewport. | 796 // Ignore tiles that are know to be outside the viewport. |
| 779 if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels != 0) | 797 if (iter.priority().distance_to_visible_in_pixels != 0) |
| 780 continue; | 798 continue; |
| 781 | 799 |
| 782 // If the missing region doesn't cover it, this tile is fully | 800 // If the missing region doesn't cover it, this tile is fully |
| 783 // covered by acceptable tiles at other scales. | 801 // covered by acceptable tiles at other scales. |
| 784 if (!missing_region->Intersects(iter.geometry_rect())) | 802 if (!missing_region->Intersects(iter.geometry_rect())) |
| 785 continue; | 803 continue; |
| 786 | 804 |
| 787 // If the twin tile isn't ready to draw, then this tile isn't | 805 // If the twin tile isn't ready to draw, then this tile isn't |
| 788 // required to prevent flashing. | 806 // required to prevent flashing. |
| 789 if (optional_twin_tiling) { | 807 if (optional_twin_tiling) { |
| 790 Tile* twin_tile = optional_twin_tiling->TileAt(iter.i(), iter.j()); | 808 Tile* twin_tile = |
| 809 optional_twin_tiling->TileAt(ACTIVE_TREE, iter.i(), iter.j()); |
| 791 if (!twin_tile || !twin_tile->IsReadyToDraw()) { | 810 if (!twin_tile || !twin_tile->IsReadyToDraw()) { |
| 792 twin_had_missing_tile = true; | 811 twin_had_missing_tile = true; |
| 793 continue; | 812 continue; |
| 794 } | 813 } |
| 795 } | 814 } |
| 796 | 815 |
| 797 missing_region->Subtract(iter.geometry_rect()); | 816 missing_region->Subtract(iter.geometry_rect()); |
| 798 tile->MarkRequiredForActivation(); | 817 tile->MarkRequiredForActivation(); |
| 799 } | 818 } |
| 800 return twin_had_missing_tile; | 819 return twin_had_missing_tile; |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { | 1226 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { |
| 1208 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1227 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
| 1209 return tilings_->GPUMemoryUsageInBytes(); | 1228 return tilings_->GPUMemoryUsageInBytes(); |
| 1210 } | 1229 } |
| 1211 | 1230 |
| 1212 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1231 void PictureLayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
| 1213 benchmark->RunOnLayer(this); | 1232 benchmark->RunOnLayer(this); |
| 1214 } | 1233 } |
| 1215 | 1234 |
| 1216 } // namespace cc | 1235 } // namespace cc |
| OLD | NEW |