| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 return make_scoped_refptr(new SurfaceLayer(std::move(ref_factory))); | 55 return make_scoped_refptr(new SurfaceLayer(std::move(ref_factory))); |
| 56 } | 56 } |
| 57 | 57 |
| 58 SurfaceLayer::SurfaceLayer(scoped_refptr<SurfaceReferenceFactory> ref_factory) | 58 SurfaceLayer::SurfaceLayer(scoped_refptr<SurfaceReferenceFactory> ref_factory) |
| 59 : ref_factory_(std::move(ref_factory)) {} | 59 : ref_factory_(std::move(ref_factory)) {} |
| 60 | 60 |
| 61 SurfaceLayer::~SurfaceLayer() { | 61 SurfaceLayer::~SurfaceLayer() { |
| 62 DCHECK(!layer_tree_host()); | 62 DCHECK(!layer_tree_host()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void SurfaceLayer::SetSurfaceInfo(const SurfaceInfo& surface_info, | 65 void SurfaceLayer::SetSurfaceInfo(const SurfaceInfo& surface_info) { |
| 66 bool stretch_content_to_fill_bounds) { | |
| 67 RemoveCurrentReference(); | 66 RemoveCurrentReference(); |
| 68 surface_info_ = surface_info; | 67 surface_info_ = surface_info; |
| 69 if (layer_tree_host()) { | 68 if (layer_tree_host()) { |
| 70 current_ref_ = | 69 current_ref_ = |
| 71 ref_factory_->CreateReference(layer_tree_host(), surface_info_.id()); | 70 ref_factory_->CreateReference(layer_tree_host(), surface_info_.id()); |
| 72 } | 71 } |
| 72 UpdateDrawsContent(HasDrawableContent()); |
| 73 SetNeedsPushProperties(); |
| 74 } |
| 75 |
| 76 void SurfaceLayer::SetStretchContentToFillBounds( |
| 77 bool stretch_content_to_fill_bounds) { |
| 73 stretch_content_to_fill_bounds_ = stretch_content_to_fill_bounds; | 78 stretch_content_to_fill_bounds_ = stretch_content_to_fill_bounds; |
| 74 UpdateDrawsContent(HasDrawableContent()); | |
| 75 SetNeedsPushProperties(); | 79 SetNeedsPushProperties(); |
| 76 } | 80 } |
| 77 | 81 |
| 78 std::unique_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl( | 82 std::unique_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl( |
| 79 LayerTreeImpl* tree_impl) { | 83 LayerTreeImpl* tree_impl) { |
| 80 return SurfaceLayerImpl::Create(tree_impl, id()); | 84 return SurfaceLayerImpl::Create(tree_impl, id()); |
| 81 } | 85 } |
| 82 | 86 |
| 83 bool SurfaceLayer::HasDrawableContent() const { | 87 bool SurfaceLayer::HasDrawableContent() const { |
| 84 return surface_info_.id().is_valid() && Layer::HasDrawableContent(); | 88 return surface_info_.id().is_valid() && Layer::HasDrawableContent(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 108 void SurfaceLayer::RemoveCurrentReference() { | 112 void SurfaceLayer::RemoveCurrentReference() { |
| 109 if (!current_ref_) | 113 if (!current_ref_) |
| 110 return; | 114 return; |
| 111 auto swap_promise = base::MakeUnique<SatisfySwapPromise>( | 115 auto swap_promise = base::MakeUnique<SatisfySwapPromise>( |
| 112 std::move(current_ref_), base::ThreadTaskRunnerHandle::Get()); | 116 std::move(current_ref_), base::ThreadTaskRunnerHandle::Get()); |
| 113 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( | 117 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( |
| 114 std::move(swap_promise)); | 118 std::move(swap_promise)); |
| 115 } | 119 } |
| 116 | 120 |
| 117 } // namespace cc | 121 } // namespace cc |
| OLD | NEW |