Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: content/common/gpu/gpu_channel.cc

Issue 165393003: gpu: Generate mailboxes on client side (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 10
11 #include <queue> 11 #include <queue>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/debug/trace_event.h" 16 #include "base/debug/trace_event.h"
17 #include "base/message_loop/message_loop_proxy.h" 17 #include "base/message_loop/message_loop_proxy.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
20 #include "content/common/gpu/devtools_gpu_agent.h" 20 #include "content/common/gpu/devtools_gpu_agent.h"
21 #include "content/common/gpu/gpu_channel_manager.h" 21 #include "content/common/gpu/gpu_channel_manager.h"
22 #include "content/common/gpu/gpu_messages.h" 22 #include "content/common/gpu/gpu_messages.h"
23 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" 23 #include "content/common/gpu/media/gpu_video_encode_accelerator.h"
24 #include "content/common/gpu/sync_point_manager.h" 24 #include "content/common/gpu/sync_point_manager.h"
25 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
26 #include "crypto/random.h"
27 #include "gpu/command_buffer/common/mailbox.h" 26 #include "gpu/command_buffer/common/mailbox.h"
28 #include "gpu/command_buffer/service/gpu_scheduler.h" 27 #include "gpu/command_buffer/service/gpu_scheduler.h"
29 #include "gpu/command_buffer/service/image_manager.h" 28 #include "gpu/command_buffer/service/image_manager.h"
30 #include "gpu/command_buffer/service/mailbox_manager.h" 29 #include "gpu/command_buffer/service/mailbox_manager.h"
31 #include "ipc/ipc_channel.h" 30 #include "ipc/ipc_channel.h"
32 #include "ipc/ipc_channel_proxy.h" 31 #include "ipc/ipc_channel_proxy.h"
33 #include "ui/gl/gl_context.h" 32 #include "ui/gl/gl_context.h"
34 #include "ui/gl/gl_image.h" 33 #include "ui/gl/gl_image.h"
35 #include "ui/gl/gl_surface.h" 34 #include "ui/gl/gl_surface.h"
36 35
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 91 }
93 92
94 virtual void OnFilterRemoved() OVERRIDE { 93 virtual void OnFilterRemoved() OVERRIDE {
95 DCHECK(channel_); 94 DCHECK(channel_);
96 channel_ = NULL; 95 channel_ = NULL;
97 } 96 }
98 97
99 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { 98 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
100 DCHECK(channel_); 99 DCHECK(channel_);
101 100
102 bool handled = true; 101 bool handled = false;
103 IPC_BEGIN_MESSAGE_MAP(GpuChannelMessageFilter, message)
104 IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNames,
105 OnGenerateMailboxNames)
106 IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNamesAsync,
107 OnGenerateMailboxNamesAsync)
108 IPC_MESSAGE_UNHANDLED(handled = false)
109 IPC_END_MESSAGE_MAP()
110
111 if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) { 102 if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) {
112 // This message should not be sent explicitly by the renderer. 103 // This message should not be sent explicitly by the renderer.
113 NOTREACHED(); 104 DLOG(ERROR) << "Client should not send "
105 "GpuCommandBufferMsg_RetireSyncPoint message";
114 handled = true; 106 handled = true;
115 } 107 }
116 108
117 // All other messages get processed by the GpuChannel. 109 // All other messages get processed by the GpuChannel.
118 if (!handled) { 110 if (!handled) {
119 messages_forwarded_to_channel_++; 111 messages_forwarded_to_channel_++;
120 if (preempting_flag_.get()) 112 if (preempting_flag_.get())
121 pending_messages_.push(PendingMessage(messages_forwarded_to_channel_)); 113 pending_messages_.push(PendingMessage(messages_forwarded_to_channel_));
122 UpdatePreemptionState(); 114 UpdatePreemptionState();
123 } 115 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 return channel_->Send(message); 153 return channel_->Send(message);
162 } 154 }
163 155
164 protected: 156 protected:
165 virtual ~GpuChannelMessageFilter() { 157 virtual ~GpuChannelMessageFilter() {
166 message_loop_->PostTask(FROM_HERE, base::Bind( 158 message_loop_->PostTask(FROM_HERE, base::Bind(
167 &GpuChannelMessageFilter::DeleteWeakPtrOnMainThread, gpu_channel_)); 159 &GpuChannelMessageFilter::DeleteWeakPtrOnMainThread, gpu_channel_));
168 } 160 }
169 161
170 private: 162 private:
171 // Message handlers.
172 void OnGenerateMailboxNames(unsigned num, std::vector<gpu::Mailbox>* result) {
173 TRACE_EVENT1("gpu", "OnGenerateMailboxNames", "num", num);
174
175 result->resize(num);
176
177 for (unsigned i = 0; i < num; ++i)
178 crypto::RandBytes((*result)[i].name, sizeof((*result)[i].name));
179 }
180
181 void OnGenerateMailboxNamesAsync(unsigned num) {
182 std::vector<gpu::Mailbox> names;
183 OnGenerateMailboxNames(num, &names);
184 Send(new GpuChannelMsg_GenerateMailboxNamesReply(names));
185 }
186
187 enum PreemptionState { 163 enum PreemptionState {
188 // Either there's no other channel to preempt, there are no messages 164 // Either there's no other channel to preempt, there are no messages
189 // pending processing, or we just finished preempting and have to wait 165 // pending processing, or we just finished preempting and have to wait
190 // before preempting again. 166 // before preempting again.
191 IDLE, 167 IDLE,
192 // We are waiting kPreemptWaitTimeMs before checking if we should preempt. 168 // We are waiting kPreemptWaitTimeMs before checking if we should preempt.
193 WAITING, 169 WAITING,
194 // We can preempt whenever any IPC processing takes more than 170 // We can preempt whenever any IPC processing takes more than
195 // kPreemptWaitTimeMs. 171 // kPreemptWaitTimeMs.
196 CHECKING, 172 CHECKING,
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 892
917 void GpuChannel::AddFilter(IPC::ChannelProxy::MessageFilter* filter) { 893 void GpuChannel::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
918 channel_->AddFilter(filter); 894 channel_->AddFilter(filter);
919 } 895 }
920 896
921 void GpuChannel::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) { 897 void GpuChannel::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
922 channel_->RemoveFilter(filter); 898 channel_->RemoveFilter(filter);
923 } 899 }
924 900
925 } // namespace content 901 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698