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 <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 const int kMinHeightForGpuRasteredTile = 256; | 47 const int kMinHeightForGpuRasteredTile = 256; |
| 48 | 48 |
| 49 // When making odd-sized tiles, round them up to increase the chances | 49 // When making odd-sized tiles, round them up to increase the chances |
| 50 // of using the same tile size. | 50 // of using the same tile size. |
| 51 const int kTileRoundUp = 64; | 51 const int kTileRoundUp = 64; |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 namespace cc { | 55 namespace cc { |
| 56 | 56 |
| 57 PictureLayerImpl::Pair::Pair() : active(nullptr), pending(nullptr) { | |
| 58 } | |
| 59 | |
| 60 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer, | |
| 61 PictureLayerImpl* pending_layer) | |
| 62 : active(active_layer), pending(pending_layer) { | |
| 63 } | |
| 64 | |
| 65 PictureLayerImpl::Pair::~Pair() { | |
| 66 } | |
| 67 | |
| 68 PictureLayerImpl::PictureLayerImpl( | 57 PictureLayerImpl::PictureLayerImpl( |
| 69 LayerTreeImpl* tree_impl, | 58 LayerTreeImpl* tree_impl, |
| 70 int id, | 59 int id, |
| 71 bool is_mask, | 60 bool is_mask, |
| 72 scoped_refptr<SyncedScrollOffset> scroll_offset) | 61 scoped_refptr<SyncedScrollOffset> scroll_offset) |
| 73 : LayerImpl(tree_impl, id, scroll_offset), | 62 : LayerImpl(tree_impl, id, scroll_offset), |
| 74 twin_layer_(nullptr), | 63 twin_layer_(nullptr), |
| 75 tilings_(CreatePictureLayerTilingSet()), | 64 tilings_(CreatePictureLayerTilingSet()), |
| 76 ideal_page_scale_(0.f), | 65 ideal_page_scale_(0.f), |
| 77 ideal_device_scale_(0.f), | 66 ideal_device_scale_(0.f), |
| 78 ideal_source_scale_(0.f), | 67 ideal_source_scale_(0.f), |
| 79 ideal_contents_scale_(0.f), | 68 ideal_contents_scale_(0.f), |
| 80 raster_page_scale_(0.f), | 69 raster_page_scale_(0.f), |
| 81 raster_device_scale_(0.f), | 70 raster_device_scale_(0.f), |
| 82 raster_source_scale_(0.f), | 71 raster_source_scale_(0.f), |
| 83 raster_contents_scale_(0.f), | 72 raster_contents_scale_(0.f), |
| 84 low_res_raster_contents_scale_(0.f), | 73 low_res_raster_contents_scale_(0.f), |
| 85 raster_source_scale_is_fixed_(false), | 74 raster_source_scale_is_fixed_(false), |
| 86 was_screen_space_transform_animating_(false), | 75 was_screen_space_transform_animating_(false), |
| 87 only_used_low_res_last_append_quads_(false), | 76 only_used_low_res_last_append_quads_(false), |
| 88 is_mask_(is_mask), | 77 is_mask_(is_mask), |
| 89 nearest_neighbor_(false) { | 78 nearest_neighbor_(false) { |
| 90 layer_tree_impl()->RegisterPictureLayerImpl(this); | 79 // If this layer is created while we have no tile manager, then we will get a |
| 80 // call to ReleaseResources and RecreateResources when we get a tile manager, | |
| 81 // so we will be able to register a tiling set into it at that time. | |
| 82 // Otherwise, if tile manager already exists, then register the tiling set | |
| 83 // right now. | |
| 84 if (tree_impl->tile_manager()) { | |
| 85 WhichTree tree = tree_impl->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; | |
| 86 tree_impl->tile_manager()->RegisterPictureLayerTilingSet(id, tree, | |
| 87 tilings_.get()); | |
| 88 } | |
| 91 } | 89 } |
| 92 | 90 |
| 93 PictureLayerImpl::~PictureLayerImpl() { | 91 PictureLayerImpl::~PictureLayerImpl() { |
| 94 if (twin_layer_) | 92 if (twin_layer_) |
| 95 twin_layer_->twin_layer_ = nullptr; | 93 twin_layer_->twin_layer_ = nullptr; |
| 96 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 94 |
| 95 if (layer_tree_impl()->tile_manager()) { | |
| 96 layer_tree_impl()->tile_manager()->UnregisterPictureLayerTilingSet( | |
| 97 id(), GetTree()); | |
| 98 } | |
| 97 } | 99 } |
| 98 | 100 |
| 99 const char* PictureLayerImpl::LayerTypeAsString() const { | 101 const char* PictureLayerImpl::LayerTypeAsString() const { |
| 100 return "cc::PictureLayerImpl"; | 102 return "cc::PictureLayerImpl"; |
| 101 } | 103 } |
| 102 | 104 |
| 103 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( | 105 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( |
| 104 LayerTreeImpl* tree_impl) { | 106 LayerTreeImpl* tree_impl) { |
| 105 return PictureLayerImpl::Create(tree_impl, id(), is_mask_, | 107 return PictureLayerImpl::Create(tree_impl, id(), is_mask_, |
| 106 synced_scroll_offset()); | 108 synced_scroll_offset()); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 595 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
| 594 AddDamageRect(layer_damage_rect); | 596 AddDamageRect(layer_damage_rect); |
| 595 } | 597 } |
| 596 } | 598 } |
| 597 | 599 |
| 598 void PictureLayerImpl::DidBeginTracing() { | 600 void PictureLayerImpl::DidBeginTracing() { |
| 599 raster_source_->DidBeginTracing(); | 601 raster_source_->DidBeginTracing(); |
| 600 } | 602 } |
| 601 | 603 |
| 602 void PictureLayerImpl::ReleaseResources() { | 604 void PictureLayerImpl::ReleaseResources() { |
| 603 // Recreate tilings with new settings, since some of those might change when | 605 if (layer_tree_impl()->tile_manager()) { |
|
enne (OOO)
2015/02/10 21:28:31
When can you not have a TileManager during this ca
vmpstr
2015/02/11 21:37:16
Several unittests aren't too happy without this if
enne (OOO)
2015/02/11 21:46:16
Ok! Thanks for the explanation.
| |
| 604 // we release resources. | 606 layer_tree_impl()->tile_manager()->UnregisterPictureLayerTilingSet( |
| 607 id(), GetTree()); | |
| 608 } | |
| 605 tilings_ = nullptr; | 609 tilings_ = nullptr; |
| 606 ResetRasterScale(); | 610 ResetRasterScale(); |
| 607 } | 611 } |
| 608 | 612 |
| 609 void PictureLayerImpl::RecreateResources() { | 613 void PictureLayerImpl::RecreateResources() { |
| 614 DCHECK(!tilings_); | |
| 615 DCHECK(layer_tree_impl()->tile_manager()); | |
| 610 tilings_ = CreatePictureLayerTilingSet(); | 616 tilings_ = CreatePictureLayerTilingSet(); |
| 617 layer_tree_impl()->tile_manager()->RegisterPictureLayerTilingSet( | |
| 618 id(), GetTree(), tilings_.get()); | |
| 611 | 619 |
| 612 // To avoid an edge case after lost context where the tree is up to date but | 620 // To avoid an edge case after lost context where the tree is up to date but |
| 613 // the tilings have not been managed, request an update draw properties | 621 // the tilings have not been managed, request an update draw properties |
| 614 // to force tilings to get managed. | 622 // to force tilings to get managed. |
| 615 layer_tree_impl()->set_needs_update_draw_properties(); | 623 layer_tree_impl()->set_needs_update_draw_properties(); |
| 616 } | 624 } |
| 617 | 625 |
| 618 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 626 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
| 619 return raster_source_->GetFlattenedPicture(); | 627 return raster_source_->GetFlattenedPicture(); |
| 620 } | 628 } |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1232 | 1240 |
| 1233 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1241 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
| 1234 return !layer_tree_impl()->IsRecycleTree(); | 1242 return !layer_tree_impl()->IsRecycleTree(); |
| 1235 } | 1243 } |
| 1236 | 1244 |
| 1237 bool PictureLayerImpl::HasValidTilePriorities() const { | 1245 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1238 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1246 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
| 1239 } | 1247 } |
| 1240 | 1248 |
| 1241 } // namespace cc | 1249 } // namespace cc |
| OLD | NEW |