| 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 "content/renderer/gpu/queue_message_swap_promise.h" | 5 #include "content/renderer/gpu/queue_message_swap_promise.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 8 #include "content/public/common/content_switches.h" |
| 9 #include "content/public/renderer/render_thread.h" |
| 7 #include "content/renderer/gpu/frame_swap_message_queue.h" | 10 #include "content/renderer/gpu/frame_swap_message_queue.h" |
| 8 #include "ipc/ipc_sync_message_filter.h" | 11 #include "ipc/ipc_sync_message_filter.h" |
| 9 | 12 |
| 10 namespace content { | 13 namespace content { |
| 11 | 14 |
| 12 QueueMessageSwapPromise::QueueMessageSwapPromise( | 15 QueueMessageSwapPromise::QueueMessageSwapPromise( |
| 13 scoped_refptr<IPC::SyncMessageFilter> message_sender, | 16 scoped_refptr<IPC::SyncMessageFilter> message_sender, |
| 14 scoped_refptr<content::FrameSwapMessageQueue> message_queue, | 17 scoped_refptr<content::FrameSwapMessageQueue> message_queue, |
| 15 int source_frame_number) | 18 int source_frame_number) |
| 16 : message_sender_(message_sender), | 19 : message_sender_(message_sender), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 DCHECK(completed_); | 34 DCHECK(completed_); |
| 32 #endif | 35 #endif |
| 33 } | 36 } |
| 34 | 37 |
| 35 void QueueMessageSwapPromise::DidActivate() { | 38 void QueueMessageSwapPromise::DidActivate() { |
| 36 #if DCHECK_IS_ON() | 39 #if DCHECK_IS_ON() |
| 37 DCHECK(!completed_); | 40 DCHECK(!completed_); |
| 38 #endif | 41 #endif |
| 39 message_queue_->DidActivate(source_frame_number_); | 42 message_queue_->DidActivate(source_frame_number_); |
| 40 // The OutputSurface will take care of the Drain+Send. | 43 // The OutputSurface will take care of the Drain+Send. |
| 44 |
| 45 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 46 switches::kUseRemoteCompositing)) { |
| 47 // The remote compositing mode doesn't have an output surface, so we need to |
| 48 // Drain+Send on activation. Also, we can't use the SyncMessageFilter, since |
| 49 // this call is actually made on the main thread. |
| 50 std::vector<std::unique_ptr<IPC::Message>> messages_to_deliver; |
| 51 std::unique_ptr<FrameSwapMessageQueue::SendMessageScope> |
| 52 send_message_scope = message_queue_->AcquireSendMessageScope(); |
| 53 message_queue_->DrainMessages(&messages_to_deliver); |
| 54 for (auto& message : messages_to_deliver) |
| 55 RenderThread::Get()->Send(message.release()); |
| 56 PromiseCompleted(); |
| 57 } |
| 41 } | 58 } |
| 42 | 59 |
| 43 void QueueMessageSwapPromise::DidSwap(cc::CompositorFrameMetadata* metadata) { | 60 void QueueMessageSwapPromise::DidSwap(cc::CompositorFrameMetadata* metadata) { |
| 44 #if DCHECK_IS_ON() | 61 #if DCHECK_IS_ON() |
| 45 DCHECK(!completed_); | 62 DCHECK(!completed_); |
| 46 #endif | 63 #endif |
| 47 message_queue_->DidSwap(source_frame_number_); | 64 message_queue_->DidSwap(source_frame_number_); |
| 48 // The OutputSurface will take care of the Drain+Send. | 65 // The OutputSurface will take care of the Drain+Send. |
| 49 PromiseCompleted(); | 66 PromiseCompleted(); |
| 50 } | 67 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 #if DCHECK_IS_ON() | 82 #if DCHECK_IS_ON() |
| 66 completed_ = true; | 83 completed_ = true; |
| 67 #endif | 84 #endif |
| 68 } | 85 } |
| 69 | 86 |
| 70 int64_t QueueMessageSwapPromise::TraceId() const { | 87 int64_t QueueMessageSwapPromise::TraceId() const { |
| 71 return 0; | 88 return 0; |
| 72 } | 89 } |
| 73 | 90 |
| 74 } // namespace content | 91 } // namespace content |
| OLD | NEW |