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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 |
| 45 scoped_refptr<SurfaceLayer> SurfaceLayer::Create( | 45 scoped_refptr<SurfaceLayer> SurfaceLayer::Create( |
| 46 const SatisfyCallback& satisfy_callback, | 46 const SatisfyCallback& satisfy_callback, |
| 47 const RequireCallback& require_callback) { | 47 const RequireCallback& require_callback) { |
| 48 return make_scoped_refptr( | 48 return make_scoped_refptr( |
| 49 new SurfaceLayer(satisfy_callback, require_callback)); | 49 new SurfaceLayer(satisfy_callback, require_callback)); |
| 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), |
|
danakj
2016/11/28 22:26:22
can you put this in the header? the new var is uni
xlai (Olivia)
2016/12/13 17:29:17
Done.
| |
| 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_valid()); | 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 bool scale_layer_bounds_with_surface_size) { | |
| 66 SatisfyDestroySequence(); | 67 SatisfyDestroySequence(); |
| 67 surface_id_ = surface_id; | 68 surface_id_ = surface_id; |
| 68 surface_size_ = size; | 69 surface_size_ = size; |
| 69 surface_scale_ = scale; | 70 surface_scale_ = scale; |
| 71 scale_layer_bounds_with_surface_size_ = scale_layer_bounds_with_surface_size; | |
| 70 CreateNewDestroySequence(); | 72 CreateNewDestroySequence(); |
| 71 | 73 |
| 72 UpdateDrawsContent(HasDrawableContent()); | 74 UpdateDrawsContent(HasDrawableContent()); |
| 73 SetNeedsPushProperties(); | 75 SetNeedsPushProperties(); |
| 74 } | 76 } |
| 75 | 77 |
| 76 std::unique_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl( | 78 std::unique_ptr<LayerImpl> SurfaceLayer::CreateLayerImpl( |
| 77 LayerTreeImpl* tree_impl) { | 79 LayerTreeImpl* tree_impl) { |
| 78 return SurfaceLayerImpl::Create(tree_impl, id()); | 80 return SurfaceLayerImpl::Create(tree_impl, id()); |
| 79 } | 81 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 94 } | 96 } |
| 95 | 97 |
| 96 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { | 98 void SurfaceLayer::PushPropertiesTo(LayerImpl* layer) { |
| 97 Layer::PushPropertiesTo(layer); | 99 Layer::PushPropertiesTo(layer); |
| 98 TRACE_EVENT0("cc", "SurfaceLayer::PushPropertiesTo"); | 100 TRACE_EVENT0("cc", "SurfaceLayer::PushPropertiesTo"); |
| 99 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); | 101 SurfaceLayerImpl* layer_impl = static_cast<SurfaceLayerImpl*>(layer); |
| 100 | 102 |
| 101 layer_impl->SetSurfaceId(surface_id_); | 103 layer_impl->SetSurfaceId(surface_id_); |
| 102 layer_impl->SetSurfaceSize(surface_size_); | 104 layer_impl->SetSurfaceSize(surface_size_); |
| 103 layer_impl->SetSurfaceScale(surface_scale_); | 105 layer_impl->SetSurfaceScale(surface_scale_); |
| 106 layer_impl->SetScaleLayerBoundsWithSurfaceSize( | |
| 107 scale_layer_bounds_with_surface_size_); | |
| 104 } | 108 } |
| 105 | 109 |
| 106 void SurfaceLayer::CreateNewDestroySequence() { | 110 void SurfaceLayer::CreateNewDestroySequence() { |
| 107 DCHECK(!destroy_sequence_.is_valid()); | 111 DCHECK(!destroy_sequence_.is_valid()); |
| 108 if (layer_tree_host()) { | 112 if (layer_tree_host()) { |
| 109 destroy_sequence_ = layer_tree_host() | 113 destroy_sequence_ = layer_tree_host() |
| 110 ->GetSurfaceSequenceGenerator() | 114 ->GetSurfaceSequenceGenerator() |
| 111 ->CreateSurfaceSequence(); | 115 ->CreateSurfaceSequence(); |
| 112 require_callback_.Run(surface_id_, destroy_sequence_); | 116 require_callback_.Run(surface_id_, destroy_sequence_); |
| 113 } | 117 } |
| 114 } | 118 } |
| 115 | 119 |
| 116 void SurfaceLayer::SatisfyDestroySequence() { | 120 void SurfaceLayer::SatisfyDestroySequence() { |
| 117 if (!layer_tree_host()) | 121 if (!layer_tree_host()) |
| 118 return; | 122 return; |
| 119 DCHECK(destroy_sequence_.is_valid()); | 123 DCHECK(destroy_sequence_.is_valid()); |
| 120 std::unique_ptr<SatisfySwapPromise> satisfy( | 124 std::unique_ptr<SatisfySwapPromise> satisfy( |
| 121 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_)); | 125 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_)); |
| 122 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( | 126 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( |
| 123 std::move(satisfy)); | 127 std::move(satisfy)); |
| 124 destroy_sequence_ = SurfaceSequence(); | 128 destroy_sequence_ = SurfaceSequence(); |
| 125 } | 129 } |
| 126 | 130 |
| 127 } // namespace cc | 131 } // namespace cc |
| OLD | NEW |