| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surface_layer.h" | 5 #include "cc/layers/surface_layer.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 stretch_content_to_fill_bounds_ = stretch_content_to_fill_bounds; | 88 stretch_content_to_fill_bounds_ = stretch_content_to_fill_bounds; |
| 89 SetNeedsPushProperties(); | 89 SetNeedsPushProperties(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 std::unique_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl( | 92 std::unique_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl( |
| 93 LayerTreeImpl* tree_impl) { | 93 LayerTreeImpl* tree_impl) { |
| 94 return SurfaceLayerImpl::Create(tree_impl, id()); | 94 return SurfaceLayerImpl::Create(tree_impl, id()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool SurfaceLayer::HasDrawableContent() const { | 97 bool SurfaceLayer::HasDrawableContent() const { |
| 98 return primary_surface_info_.id().is_valid() && Layer::HasDrawableContent(); | 98 return primary_surface_info_.is_valid() && Layer::HasDrawableContent(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void SurfaceLayer::SetLayerTreeHost(LayerTreeHost* host) { | 101 void SurfaceLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 102 if (layer_tree_host() == host) { | 102 if (layer_tree_host() == host) { |
| 103 Layer::SetLayerTreeHost(host); | 103 Layer::SetLayerTreeHost(host); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 RemoveReference(std::move(primary_reference_returner_)); | 106 RemoveReference(std::move(primary_reference_returner_)); |
| 107 RemoveReference(std::move(fallback_reference_returner_)); | 107 RemoveReference(std::move(fallback_reference_returner_)); |
| 108 Layer::SetLayerTreeHost(host); | 108 Layer::SetLayerTreeHost(host); |
| 109 if (layer_tree_host()) { | 109 if (layer_tree_host()) { |
| 110 if (primary_surface_info_.id().is_valid()) { | 110 if (primary_surface_info_.is_valid()) { |
| 111 primary_reference_returner_ = ref_factory_->CreateReference( | 111 primary_reference_returner_ = ref_factory_->CreateReference( |
| 112 layer_tree_host(), primary_surface_info_.id()); | 112 layer_tree_host(), primary_surface_info_.id()); |
| 113 } | 113 } |
| 114 if (fallback_surface_info_.id().is_valid()) { | 114 if (fallback_surface_info_.is_valid()) { |
| 115 fallback_reference_returner_ = ref_factory_->CreateReference( | 115 fallback_reference_returner_ = ref_factory_->CreateReference( |
| 116 layer_tree_host(), fallback_surface_info_.id()); | 116 layer_tree_host(), fallback_surface_info_.id()); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { | 121 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { |
| 122 Layer::PushPropertiesTo(layer); | 122 Layer::PushPropertiesTo(layer); |
| 123 TRACE_EVENT0("cc", "SurfaceLayer::PushPropertiesTo"); | 123 TRACE_EVENT0("cc", "SurfaceLayer::PushPropertiesTo"); |
| 124 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 124 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
| 125 layer_impl->SetPrimarySurfaceInfo(primary_surface_info_); | 125 layer_impl->SetPrimarySurfaceInfo(primary_surface_info_); |
| 126 layer_impl->SetFallbackSurfaceInfo(fallback_surface_info_); | 126 layer_impl->SetFallbackSurfaceInfo(fallback_surface_info_); |
| 127 layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_); | 127 layer_impl->SetStretchContentToFillBounds(stretch_content_to_fill_bounds_); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void SurfaceLayer::RemoveReference(base::Closure reference_returner) { | 130 void SurfaceLayer::RemoveReference(base::Closure reference_returner) { |
| 131 if (!reference_returner) | 131 if (!reference_returner) |
| 132 return; | 132 return; |
| 133 auto swap_promise = base::MakeUnique<SatisfySwapPromise>( | 133 auto swap_promise = base::MakeUnique<SatisfySwapPromise>( |
| 134 std::move(reference_returner), | 134 std::move(reference_returner), |
| 135 layer_tree_host()->GetTaskRunnerProvider()->MainThreadTaskRunner()); | 135 layer_tree_host()->GetTaskRunnerProvider()->MainThreadTaskRunner()); |
| 136 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( | 136 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( |
| 137 std::move(swap_promise)); | 137 std::move(swap_promise)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace cc | 140 } // namespace cc |
| OLD | NEW |