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

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

Issue 383303004: Added more detailed result codes for CreateViewCommandBuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deleted commented-out code from test. Created 6 years, 5 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 surface_id, 262 surface_id,
262 gpu_client_id_, 263 gpu_client_id_,
263 init_params, 264 init_params,
264 request->route_id, 265 request->route_id,
265 base::Bind(&BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO, 266 base::Bind(&BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO,
266 request)); 267 request));
267 } 268 }
268 269
269 // static 270 // static
270 void BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO( 271 void BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO(
271 CreateRequest* request, bool succeeded) { 272 CreateRequest* request, CreateCommandBufferResult result) {
272 request->succeeded = succeeded; 273 request->result = result;
273 request->event.Signal(); 274 request->event.Signal();
274 } 275 }
275 276
276 bool BrowserGpuChannelHostFactory::CreateViewCommandBuffer( 277 CreateCommandBufferResult BrowserGpuChannelHostFactory::CreateViewCommandBuffer(
277 int32 surface_id, 278 int32 surface_id,
278 const GPUCreateCommandBufferConfig& init_params, 279 const GPUCreateCommandBufferConfig& init_params,
279 int32 route_id) { 280 int32 route_id) {
280 CreateRequest request; 281 CreateRequest request;
281 request.route_id = route_id; 282 request.route_id = route_id;
282 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( 283 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind(
283 &BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO, 284 &BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO,
284 base::Unretained(this), 285 base::Unretained(this),
285 &request, 286 &request,
286 surface_id, 287 surface_id,
287 init_params)); 288 init_params));
288 // We're blocking the UI thread, which is generally undesirable. 289 // We're blocking the UI thread, which is generally undesirable.
289 // In this case we need to wait for this before we can show any UI /anyway/, 290 // In this case we need to wait for this before we can show any UI /anyway/,
290 // so it won't cause additional jank. 291 // so it won't cause additional jank.
291 // TODO(piman): Make this asynchronous (http://crbug.com/125248). 292 // TODO(piman): Make this asynchronous (http://crbug.com/125248).
292 TRACE_EVENT0("browser", 293 TRACE_EVENT0("browser",
293 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); 294 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer");
294 base::ThreadRestrictions::ScopedAllowWait allow_wait; 295 base::ThreadRestrictions::ScopedAllowWait allow_wait;
295 request.event.Wait(); 296 request.event.Wait();
296 return request.succeeded; 297 return request.result;
297 } 298 }
298 299
299 void BrowserGpuChannelHostFactory::CreateImageOnIO( 300 void BrowserGpuChannelHostFactory::CreateImageOnIO(
300 gfx::PluginWindowHandle window, 301 gfx::PluginWindowHandle window,
301 int32 image_id, 302 int32 image_id,
302 const CreateImageCallback& callback) { 303 const CreateImageCallback& callback) {
303 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 304 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
304 if (!host) { 305 if (!host) {
305 ImageCreatedOnIO(callback, gfx::Size()); 306 ImageCreatedOnIO(callback, gfx::Size());
306 return; 307 return;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 const gfx::GpuMemoryBufferHandle& handle, 552 const gfx::GpuMemoryBufferHandle& handle,
552 int32 sync_point) { 553 int32 sync_point) {
553 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); 554 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
554 if (!host) 555 if (!host)
555 return; 556 return;
556 557
557 host->DestroyGpuMemoryBuffer(handle, sync_point); 558 host->DestroyGpuMemoryBuffer(handle, sync_point);
558 } 559 }
559 560
560 } // namespace content 561 } // 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