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/threading/thread_task_runner_handle.h" | |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "cc/layers/surface_layer_impl.h" | 12 #include "cc/layers/surface_layer_impl.h" |
| 12 #include "cc/output/swap_promise.h" | 13 #include "cc/output/swap_promise.h" |
| 13 #include "cc/surfaces/surface_sequence_generator.h" | 14 #include "cc/surfaces/surface_sequence_generator.h" |
| 14 #include "cc/trees/layer_tree_host.h" | 15 #include "cc/trees/layer_tree_host.h" |
| 15 #include "cc/trees/swap_promise_manager.h" | 16 #include "cc/trees/swap_promise_manager.h" |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 | 19 |
| 19 class SatisfySwapPromise : public SwapPromise { | 20 class SatisfySwapPromise : public SwapPromise { |
| 20 public: | 21 public: |
| 21 SatisfySwapPromise(SurfaceSequence sequence, | 22 SatisfySwapPromise( |
| 22 const SurfaceLayer::SatisfyCallback& satisfy_callback) | 23 SurfaceSequence sequence, |
|
Fady Samuel
2016/12/08 18:01:33
nit: const SurfaceSequence& sequence
| |
| 23 : sequence_(sequence), satisfy_callback_(satisfy_callback) {} | 24 const SurfaceLayer::SatisfyCallback& satisfy_callback, |
| 25 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) | |
| 26 : sequence_(sequence), | |
| 27 satisfy_callback_(satisfy_callback), | |
| 28 main_task_runner_(main_task_runner) {} | |
|
dcheng
2016/12/08 19:25:38
NIt: std::move() this
| |
| 24 | 29 |
| 25 ~SatisfySwapPromise() override {} | 30 ~SatisfySwapPromise() override {} |
| 26 | 31 |
| 27 private: | 32 private: |
| 28 void DidActivate() override {} | 33 void DidActivate() override {} |
| 29 void DidSwap(CompositorFrameMetadata* metadata) override { | 34 void DidSwap(CompositorFrameMetadata* metadata) override { |
| 30 metadata->satisfies_sequences.push_back(sequence_.sequence); | 35 main_task_runner_->PostTask(FROM_HERE, |
| 36 base::Bind(satisfy_callback_, sequence_)); | |
| 31 } | 37 } |
| 32 | 38 |
| 33 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { | 39 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { |
| 34 satisfy_callback_.Run(sequence_); | 40 satisfy_callback_.Run(sequence_); |
| 35 return DidNotSwapAction::BREAK_PROMISE; | 41 return DidNotSwapAction::BREAK_PROMISE; |
| 36 } | 42 } |
| 37 int64_t TraceId() const override { return 0; } | 43 int64_t TraceId() const override { return 0; } |
| 38 | 44 |
| 39 SurfaceSequence sequence_; | 45 SurfaceSequence sequence_; |
| 40 SurfaceLayer::SatisfyCallback satisfy_callback_; | 46 SurfaceLayer::SatisfyCallback satisfy_callback_; |
| 47 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
| 41 | 48 |
| 42 DISALLOW_COPY_AND_ASSIGN(SatisfySwapPromise); | 49 DISALLOW_COPY_AND_ASSIGN(SatisfySwapPromise); |
| 43 }; | 50 }; |
| 44 | 51 |
| 45 scoped_refptr<SurfaceLayer> SurfaceLayer::Create( | 52 scoped_refptr<SurfaceLayer> SurfaceLayer::Create( |
| 46 const SatisfyCallback& satisfy_callback, | 53 const SatisfyCallback& satisfy_callback, |
| 47 const RequireCallback& require_callback) { | 54 const RequireCallback& require_callback) { |
| 48 return make_scoped_refptr( | 55 return make_scoped_refptr( |
| 49 new SurfaceLayer(satisfy_callback, require_callback)); | 56 new SurfaceLayer(satisfy_callback, require_callback)); |
| 50 } | 57 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 ->CreateSurfaceSequence(); | 118 ->CreateSurfaceSequence(); |
| 112 require_callback_.Run(surface_id_, destroy_sequence_); | 119 require_callback_.Run(surface_id_, destroy_sequence_); |
| 113 } | 120 } |
| 114 } | 121 } |
| 115 | 122 |
| 116 void SurfaceLayer::SatisfyDestroySequence() { | 123 void SurfaceLayer::SatisfyDestroySequence() { |
| 117 if (!layer_tree_host()) | 124 if (!layer_tree_host()) |
| 118 return; | 125 return; |
| 119 DCHECK(destroy_sequence_.is_valid()); | 126 DCHECK(destroy_sequence_.is_valid()); |
| 120 std::unique_ptr<SatisfySwapPromise> satisfy( | 127 std::unique_ptr<SatisfySwapPromise> satisfy( |
| 121 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_)); | 128 new SatisfySwapPromise(destroy_sequence_, satisfy_callback_, |
| 129 base::ThreadTaskRunnerHandle::Get())); | |
| 122 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( | 130 layer_tree_host()->GetSwapPromiseManager()->QueueSwapPromise( |
| 123 std::move(satisfy)); | 131 std::move(satisfy)); |
| 124 destroy_sequence_ = SurfaceSequence(); | 132 destroy_sequence_ = SurfaceSequence(); |
| 125 } | 133 } |
| 126 | 134 |
| 127 } // namespace cc | 135 } // namespace cc |
| OLD | NEW |