Chromium Code Reviews| 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/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 } | 50 } |
| 51 | 51 |
| 52 SurfaceLayer::SurfaceLayer(const SatisfyCallback& satisfy_callback, | 52 SurfaceLayer::SurfaceLayer(const SatisfyCallback& satisfy_callback, |
| 53 const RequireCallback& require_callback) | 53 const RequireCallback& require_callback) |
| 54 : surface_scale_(1.f), | 54 : surface_scale_(1.f), |
| 55 satisfy_callback_(satisfy_callback), | 55 satisfy_callback_(satisfy_callback), |
| 56 require_callback_(require_callback) {} | 56 require_callback_(require_callback) {} |
| 57 | 57 |
| 58 SurfaceLayer::~SurfaceLayer() { | 58 SurfaceLayer::~SurfaceLayer() { |
| 59 DCHECK(!layer_tree_host()); | 59 DCHECK(!layer_tree_host()); |
| 60 DCHECK(destroy_sequence_.is_null()); | 60 DCHECK(!destroy_sequence_.is_valid()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void SurfaceLayer::SetSurfaceId(const SurfaceId& surface_id, | 63 void SurfaceLayer::SetSurfaceId(const SurfaceId& surface_id, |
| 64 float scale, | 64 float scale, |
| 65 const gfx::Size& size) { | 65 const gfx::Size& size) { |
| 66 SatisfyDestroySequence(); | 66 SatisfyDestroySequence(); |
| 67 surface_id_ = surface_id; | 67 surface_id_ = surface_id; |
| 68 surface_size_ = size; | 68 surface_size_ = size; |
| 69 surface_scale_ = scale; | 69 surface_scale_ = scale; |
| 70 CreateNewDestroySequence(); | 70 CreateNewDestroySequence(); |
| 71 | 71 |
| 72 UpdateDrawsContent(HasDrawableContent()); | 72 UpdateDrawsContent(HasDrawableContent()); |
| 73 SetNeedsPushProperties(); | 73 SetNeedsPushProperties(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 std::unique_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl( | 76 std::unique_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl( |
| 77 LayerTreeImpl* tree_impl) { | 77 LayerTreeImpl* tree_impl) { |
| 78 return SurfaceLayerImpl::Create(tree_impl, id()); | 78 return SurfaceLayerImpl::Create(tree_impl, id()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool SurfaceLayer::HasDrawableContent() const { | 81 bool SurfaceLayer::HasDrawableContent() const { |
| 82 return !surface_id_.is_null() && Layer::HasDrawableContent(); | 82 return surface_id_.is_valid() && Layer::HasDrawableContent(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void SurfaceLayer::SetLayerTreeHost(LayerTreeHost* host) { | 85 void SurfaceLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| 86 if (layer_tree_host() == host) { | 86 if (layer_tree_host() == host) { |
| 87 Layer::SetLayerTreeHost(host); | 87 Layer::SetLayerTreeHost(host); |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 | 90 |
| 91 SatisfyDestroySequence(); | 91 SatisfyDestroySequence(); |
| 92 Layer::SetLayerTreeHost(host); | 92 Layer::SetLayerTreeHost(host); |
| 93 CreateNewDestroySequence(); | 93 CreateNewDestroySequence(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { | 96 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { |
| 97 Layer::PushPropertiesTo(layer); | 97 Layer::PushPropertiesTo(layer); |
| 98 TRACE_EVENT0("cc", "SurfaceLayer::PushPropertiesTo"); | 98 TRACE_EVENT0("cc", "SurfaceLayer::PushPropertiesTo"); |
| 99 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 99 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
| 100 | 100 |
| 101 layer_impl->SetSurfaceId(surface_id_); | 101 layer_impl->SetSurfaceId(surface_id_); |
| 102 layer_impl->SetSurfaceSize(surface_size_); | 102 layer_impl->SetSurfaceSize(surface_size_); |
| 103 layer_impl->SetSurfaceScale(surface_scale_); | 103 layer_impl->SetSurfaceScale(surface_scale_); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void SurfaceLayer::CreateNewDestroySequence() { | 106 void SurfaceLayer::CreateNewDestroySequence() { |
| 107 DCHECK(destroy_sequence_.is_null()); | 107 DCHECK(!destroy_sequence_.is_valid()); |
| 108 if (layer_tree_host()) { | 108 if (layer_tree_host()) { |
| 109 destroy_sequence_ = layer_tree_host() | 109 destroy_sequence_ = layer_tree_host() |
| 110 ->GetSurfaceSequenceGenerator() | 110 ->GetSurfaceSequenceGenerator() |
| 111 ->CreateSurfaceSequence(); | 111 ->CreateSurfaceSequence(); |
| 112 require_callback_.Run(surface_id_, destroy_sequence_); | 112 require_callback_.Run(surface_id_, destroy_sequence_); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 void SurfaceLayer::SatisfyDestroySequence() { | 116 void SurfaceLayer::SatisfyDestroySequence() { |
| 117 if (!layer_tree_host()) | 117 if (!layer_tree_host()) |
| 118 return; | 118 return; |
| 119 DCHECK(!destroy_sequence_.is_null()); | 119 // Sometime frame_sink_id_ is null |
|
piman
2016/11/08 23:16:34
What does this comment refer to? There's no frame_
Alex Z.
2016/11/09 15:29:15
Sorry about the confusion.
That was one of the not
| |
| 120 DCHECK(destroy_sequence_.is_valid()); | |
| 120 std::unique_ptr<SatisfySwapPromise> satisfy( | 121 std::unique_ptr<SatisfySwapPromise> satisfy( |
| 121 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_)); | 122 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_)); |
| 122 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( | 123 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( |
| 123 std::move(satisfy)); | 124 std::move(satisfy)); |
| 124 destroy_sequence_ = SurfaceSequence(); | 125 destroy_sequence_ = SurfaceSequence(); |
| 125 } | 126 } |
| 126 | 127 |
| 127 } // namespace cc | 128 } // namespace cc |
| OLD | NEW |