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

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.cc

Issue 440203002: Merge 283085 "Added more detailed result codes for CreateViewCom..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 4 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 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "content/browser/gpu/gpu_data_manager_impl.h" 11 #include "content/browser/gpu/gpu_data_manager_impl.h"
12 #include "content/browser/gpu/gpu_process_host.h" 12 #include "content/browser/gpu/gpu_process_host.h"
13 #include "content/browser/gpu/gpu_surface_tracker.h" 13 #include "content/browser/gpu/gpu_surface_tracker.h"
14 #include "content/common/child_process_host_impl.h" 14 #include "content/common/child_process_host_impl.h"
15 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" 15 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
16 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/gpu_data_manager.h" 18 #include "content/public/browser/gpu_data_manager.h"
19 #include "content/public/common/content_client.h" 19 #include "content/public/common/content_client.h"
20 #include "ipc/ipc_channel_handle.h" 20 #include "ipc/ipc_channel_handle.h"
21 #include "ipc/ipc_forwarding_message_filter.h" 21 #include "ipc/ipc_forwarding_message_filter.h"
22 #include "ipc/message_filter.h" 22 #include "ipc/message_filter.h"
23 23
24 namespace content { 24 namespace content {
25 25
26 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; 26 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL;
27 27
28 struct BrowserGpuChannelHostFactory::CreateRequest { 28 struct BrowserGpuChannelHostFactory::CreateRequest {
29 CreateRequest() 29 CreateRequest()
30 : event(true, false), gpu_host_id(0), route_id(MSG_ROUTING_NONE) {} 30 : event(true, false), gpu_host_id(0), route_id(MSG_ROUTING_NONE),
31 result(CREATE_COMMAND_BUFFER_FAILED) {}
31 ~CreateRequest() {} 32 ~CreateRequest() {}
32 base::WaitableEvent event; 33 base::WaitableEvent event;
33 int gpu_host_id; 34 int gpu_host_id;
34 int32 route_id; 35 int32 route_id;
35 bool succeeded; 36 CreateCommandBufferResult result;
36 }; 37 };
37 38
38 class BrowserGpuChannelHostFactory::EstablishRequest 39 class BrowserGpuChannelHostFactory::EstablishRequest
39 : public base::RefCountedThreadSafe<EstablishRequest> { 40 : public base::RefCountedThreadSafe<EstablishRequest> {
40 public: 41 public:
41 static scoped_refptr<EstablishRequest> Create(CauseForGpuLaunch cause, 42 static scoped_refptr<EstablishRequest> Create(CauseForGpuLaunch cause,
42 int gpu_client_id, 43 int gpu_client_id,
43 int gpu_host_id); 44 int gpu_host_id);
44 void Wait(); 45 void Wait();
45 void Cancel(); 46 void Cancel();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 surface_id, 261 surface_id,
261 gpu_client_id_, 262 gpu_client_id_,
262 init_params, 263 init_params,
263 request->route_id, 264 request->route_id,
264 base::Bind(&BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO, 265 base::Bind(&BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO,
265 request)); 266 request));
266 } 267 }
267 268
268 // static 269 // static
269 void BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO( 270 void BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO(
270 CreateRequest* request, bool succeeded) { 271 CreateRequest* request, CreateCommandBufferResult result) {
271 request->succeeded = succeeded; 272 request->result = result;
272 request->event.Signal(); 273 request->event.Signal();
273 } 274 }
274 275
275 bool BrowserGpuChannelHostFactory::CreateViewCommandBuffer( 276 CreateCommandBufferResult BrowserGpuChannelHostFactory::CreateViewCommandBuffer(
276 int32 surface_id, 277 int32 surface_id,
277 const GPUCreateCommandBufferConfig& init_params, 278 const GPUCreateCommandBufferConfig& init_params,
278 int32 route_id) { 279 int32 route_id) {
279 CreateRequest request; 280 CreateRequest request;
280 request.route_id = route_id; 281 request.route_id = route_id;
281 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( 282 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind(
282 &BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO, 283 &BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO,
283 base::Unretained(this), 284 base::Unretained(this),
284 &request, 285 &request,
285 surface_id, 286 surface_id,
286 init_params)); 287 init_params));
287 // We're blocking the UI thread, which is generally undesirable. 288 // We're blocking the UI thread, which is generally undesirable.
288 // In this case we need to wait for this before we can show any UI /anyway/, 289 // In this case we need to wait for this before we can show any UI /anyway/,
289 // so it won't cause additional jank. 290 // so it won't cause additional jank.
290 // TODO(piman): Make this asynchronous (http://crbug.com/125248). 291 // TODO(piman): Make this asynchronous (http://crbug.com/125248).
291 TRACE_EVENT0("browser", 292 TRACE_EVENT0("browser",
292 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); 293 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer");
293 base::ThreadRestrictions::ScopedAllowWait allow_wait; 294 base::ThreadRestrictions::ScopedAllowWait allow_wait;
294 request.event.Wait(); 295 request.event.Wait();
295 return request.succeeded; 296 return request.result;
296 } 297 }
297 298
298 void BrowserGpuChannelHostFactory::CreateImageOnIO( 299 void BrowserGpuChannelHostFactory::CreateImageOnIO(
299 gfx::PluginWindowHandle window, 300 gfx::PluginWindowHandle window,
300 int32 image_id, 301 int32 image_id,
301 const CreateImageCallback& callback) { 302 const CreateImageCallback& callback) {
302 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 303 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
303 if (!host) { 304 if (!host) {
304 ImageCreatedOnIO(callback, gfx::Size()); 305 ImageCreatedOnIO(callback, gfx::Size());
305 return; 306 return;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 const gfx::GpuMemoryBufferHandle& handle, 551 const gfx::GpuMemoryBufferHandle& handle,
551 int32 sync_point) { 552 int32 sync_point) {
552 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 553 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
553 if (!host) 554 if (!host)
554 return; 555 return;
555 556
556 host->DestroyGpuMemoryBuffer(handle, sync_point); 557 host->DestroyGpuMemoryBuffer(handle, sync_point);
557 } 558 }
558 559
559 } // namespace content 560 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/browser_gpu_channel_host_factory.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698