| 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 "cc/layers/surface_layer_impl.h" | 11 #include "cc/layers/surface_layer_impl.h" |
| 11 #include "cc/output/swap_promise.h" | 12 #include "cc/output/swap_promise.h" |
| 12 #include "cc/trees/layer_tree_host.h" | 13 #include "cc/trees/layer_tree_host.h" |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 class SatisfySwapPromise : public SwapPromise { | 17 class SatisfySwapPromise : public SwapPromise { |
| 17 public: | 18 public: |
| 18 SatisfySwapPromise(SurfaceSequence sequence, | 19 SatisfySwapPromise(SurfaceSequence sequence, |
| 19 const SurfaceLayer::SatisfyCallback& satisfy_callback) | 20 const SurfaceLayer::SatisfyCallback& satisfy_callback) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return; | 88 return; |
| 88 } | 89 } |
| 89 | 90 |
| 90 SatisfyDestroySequence(); | 91 SatisfyDestroySequence(); |
| 91 Layer::SetLayerTreeHost(host); | 92 Layer::SetLayerTreeHost(host); |
| 92 CreateNewDestroySequence(); | 93 CreateNewDestroySequence(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { | 96 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { |
| 96 Layer::PushPropertiesTo(layer); | 97 Layer::PushPropertiesTo(layer); |
| 98 TRACE_EVENT0("cc", "SurfaceLayer::PushPropertiesTo"); |
| 97 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 99 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
| 98 | 100 |
| 99 layer_impl->SetSurfaceId(surface_id_); | 101 layer_impl->SetSurfaceId(surface_id_); |
| 100 layer_impl->SetSurfaceSize(surface_size_); | 102 layer_impl->SetSurfaceSize(surface_size_); |
| 101 layer_impl->SetSurfaceScale(surface_scale_); | 103 layer_impl->SetSurfaceScale(surface_scale_); |
| 102 } | 104 } |
| 103 | 105 |
| 104 void SurfaceLayer::CreateNewDestroySequence() { | 106 void SurfaceLayer::CreateNewDestroySequence() { |
| 105 DCHECK(destroy_sequence_.is_null()); | 107 DCHECK(destroy_sequence_.is_null()); |
| 106 if (layer_tree_host()) { | 108 if (layer_tree_host()) { |
| 107 destroy_sequence_ = layer_tree_host()->CreateSurfaceSequence(); | 109 destroy_sequence_ = layer_tree_host()->CreateSurfaceSequence(); |
| 108 require_callback_.Run(surface_id_, destroy_sequence_); | 110 require_callback_.Run(surface_id_, destroy_sequence_); |
| 109 } | 111 } |
| 110 } | 112 } |
| 111 | 113 |
| 112 void SurfaceLayer::SatisfyDestroySequence() { | 114 void SurfaceLayer::SatisfyDestroySequence() { |
| 113 if (!layer_tree_host()) | 115 if (!layer_tree_host()) |
| 114 return; | 116 return; |
| 115 DCHECK(!destroy_sequence_.is_null()); | 117 DCHECK(!destroy_sequence_.is_null()); |
| 116 scoped_ptr<SatisfySwapPromise> satisfy( | 118 scoped_ptr<SatisfySwapPromise> satisfy( |
| 117 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_)); | 119 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_)); |
| 118 layer_tree_host()->QueueSwapPromise(std::move(satisfy)); | 120 layer_tree_host()->QueueSwapPromise(std::move(satisfy)); |
| 119 destroy_sequence_ = SurfaceSequence(); | 121 destroy_sequence_ = SurfaceSequence(); |
| 120 } | 122 } |
| 121 | 123 |
| 122 } // namespace cc | 124 } // namespace cc |
| OLD | NEW |