| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/client/core/compositor/blimp_compositor.h" | 5 #include "blimp/client/core/compositor/blimp_compositor.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 std::unique_ptr<cc::CopyOutputRequest> copy_request, | 66 std::unique_ptr<cc::CopyOutputRequest> copy_request, |
| 67 base::WeakPtr<BlimpCompositor> compositor, | 67 base::WeakPtr<BlimpCompositor> compositor, |
| 68 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) | 68 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) |
| 69 : copy_request_(std::move(copy_request)), | 69 : copy_request_(std::move(copy_request)), |
| 70 compositor_weak_ptr_(compositor), | 70 compositor_weak_ptr_(compositor), |
| 71 main_task_runner_(std::move(main_task_runner)) {} | 71 main_task_runner_(std::move(main_task_runner)) {} |
| 72 ~FrameTrackingSwapPromise() override = default; | 72 ~FrameTrackingSwapPromise() override = default; |
| 73 | 73 |
| 74 // cc::SwapPromise implementation. | 74 // cc::SwapPromise implementation. |
| 75 void DidActivate() override {} | 75 void DidActivate() override {} |
| 76 void DidSwap(cc::CompositorFrameMetadata* metadata) override { | 76 void WillSwap(cc::CompositorFrameMetadata* metadata) override {} |
| 77 // DidSwap is called right before the CompositorFrame is submitted to the | 77 void DidSwap() override { |
| 78 // CompositorFrameSink, so we make sure to delay the copy request till that | 78 // DidSwap could be called on compositor thread and we need this to run on |
| 79 // frame is submitted. | 79 // the main thread. |
| 80 main_task_runner_->PostTask( | 80 main_task_runner_->PostTask( |
| 81 FROM_HERE, | 81 FROM_HERE, |
| 82 base::Bind(&BlimpCompositor::MakeCopyRequestOnNextSwap, | 82 base::Bind(&BlimpCompositor::MakeCopyRequestOnNextSwap, |
| 83 compositor_weak_ptr_, base::Passed(©_request_))); | 83 compositor_weak_ptr_, base::Passed(©_request_))); |
| 84 } | 84 } |
| 85 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { | 85 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { |
| 86 switch (reason) { | 86 switch (reason) { |
| 87 case DidNotSwapReason::SWAP_FAILS: | 87 case DidNotSwapReason::SWAP_FAILS: |
| 88 // The swap will fail if there is no frame damage, we can queue the | 88 // The swap will fail if there is no frame damage, we can queue the |
| 89 // request right away. | 89 // request right away. |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // Destroy the old LayerTreeHost state. | 460 // Destroy the old LayerTreeHost state. |
| 461 host_.reset(); | 461 host_.reset(); |
| 462 | 462 |
| 463 // Cancel any outstanding CompositorFrameSink requests. That way if we get an | 463 // Cancel any outstanding CompositorFrameSink requests. That way if we get an |
| 464 // async callback related to the old request we know to drop it. | 464 // async callback related to the old request we know to drop it. |
| 465 compositor_frame_sink_request_pending_ = false; | 465 compositor_frame_sink_request_pending_ = false; |
| 466 } | 466 } |
| 467 | 467 |
| 468 } // namespace client | 468 } // namespace client |
| 469 } // namespace blimp | 469 } // namespace blimp |
| OLD | NEW |