| 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 layer_tree_impl()->RegisterPictureLayerImpl(this); |
| 80 |
| 81 // If this layer is created while we have no tile manager, then we will get a |
| 82 // call to ReleaseResources and RecreateResources when we get a tile manager, |
| 83 // so we will be able to register a tiling set into it at that time. |
| 84 // Otherwise, if tile manager already exists, then register the tiling set |
| 85 // right now. |
| 86 if (tree_impl->tile_manager()) { |
| 87 WhichTree tree = tree_impl->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; |
| 88 tree_impl->tile_manager()->RegisterPictureLayerTilingSet(id, tree, |
| 89 tilings_.get()); |
| 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 PictureLayerImpl::~PictureLayerImpl() { | 93 PictureLayerImpl::~PictureLayerImpl() { |
| 94 if (twin_layer_) | 94 if (twin_layer_) |
| 95 twin_layer_->twin_layer_ = nullptr; | 95 twin_layer_->twin_layer_ = nullptr; |
| 96 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 96 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
| 97 |
| 98 if (layer_tree_impl()->tile_manager()) { |
| 99 layer_tree_impl()->tile_manager()->UnregisterPictureLayerTilingSet( |
| 100 id(), GetTree()); |
| 101 } |
| 97 } | 102 } |
| 98 | 103 |
| 99 const char* PictureLayerImpl::LayerTypeAsString() const { | 104 const char* PictureLayerImpl::LayerTypeAsString() const { |
| 100 return "cc::PictureLayerImpl"; | 105 return "cc::PictureLayerImpl"; |
| 101 } | 106 } |
| 102 | 107 |
| 103 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( | 108 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl( |
| 104 LayerTreeImpl* tree_impl) { | 109 LayerTreeImpl* tree_impl) { |
| 105 return PictureLayerImpl::Create(tree_impl, id(), is_mask_, | 110 return PictureLayerImpl::Create(tree_impl, id(), is_mask_, |
| 106 synced_scroll_offset()); | 111 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()); | 598 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
| 594 AddDamageRect(layer_damage_rect); | 599 AddDamageRect(layer_damage_rect); |
| 595 } | 600 } |
| 596 } | 601 } |
| 597 | 602 |
| 598 void PictureLayerImpl::DidBeginTracing() { | 603 void PictureLayerImpl::DidBeginTracing() { |
| 599 raster_source_->DidBeginTracing(); | 604 raster_source_->DidBeginTracing(); |
| 600 } | 605 } |
| 601 | 606 |
| 602 void PictureLayerImpl::ReleaseResources() { | 607 void PictureLayerImpl::ReleaseResources() { |
| 603 // Recreate tilings with new settings, since some of those might change when | 608 if (layer_tree_impl()->tile_manager()) { |
| 604 // we release resources. | 609 layer_tree_impl()->tile_manager()->UnregisterPictureLayerTilingSet( |
| 610 id(), GetTree()); |
| 611 } |
| 605 tilings_ = nullptr; | 612 tilings_ = nullptr; |
| 606 ResetRasterScale(); | 613 ResetRasterScale(); |
| 607 } | 614 } |
| 608 | 615 |
| 609 void PictureLayerImpl::RecreateResources() { | 616 void PictureLayerImpl::RecreateResources() { |
| 617 DCHECK(!tilings_); |
| 618 DCHECK(layer_tree_impl()->tile_manager()); |
| 610 tilings_ = CreatePictureLayerTilingSet(); | 619 tilings_ = CreatePictureLayerTilingSet(); |
| 620 layer_tree_impl()->tile_manager()->RegisterPictureLayerTilingSet( |
| 621 id(), GetTree(), tilings_.get()); |
| 611 | 622 |
| 612 // To avoid an edge case after lost context where the tree is up to date but | 623 // 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 | 624 // the tilings have not been managed, request an update draw properties |
| 614 // to force tilings to get managed. | 625 // to force tilings to get managed. |
| 615 layer_tree_impl()->set_needs_update_draw_properties(); | 626 layer_tree_impl()->set_needs_update_draw_properties(); |
| 616 } | 627 } |
| 617 | 628 |
| 618 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 629 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
| 619 return raster_source_->GetFlattenedPicture(); | 630 return raster_source_->GetFlattenedPicture(); |
| 620 } | 631 } |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 | 1244 |
| 1234 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1245 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
| 1235 return !layer_tree_impl()->IsRecycleTree(); | 1246 return !layer_tree_impl()->IsRecycleTree(); |
| 1236 } | 1247 } |
| 1237 | 1248 |
| 1238 bool PictureLayerImpl::HasValidTilePriorities() const { | 1249 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1239 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1250 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
| 1240 } | 1251 } |
| 1241 | 1252 |
| 1242 } // namespace cc | 1253 } // namespace cc |
| OLD | NEW |