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

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

Issue 1129943006: Implement StreamTexture::BindTexImage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CreateStreamTexture Flow Change. Created 5 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
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/location.h" 8 #include "base/location.h"
9 #include "base/profiler/scoped_tracker.h" 9 #include "base/profiler/scoped_tracker.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 14 matching lines...) Expand all
25 #include "ipc/ipc_forwarding_message_filter.h" 25 #include "ipc/ipc_forwarding_message_filter.h"
26 #include "ipc/message_filter.h" 26 #include "ipc/message_filter.h"
27 27
28 namespace content { 28 namespace content {
29 29
30 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; 30 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL;
31 31
32 struct BrowserGpuChannelHostFactory::CreateRequest { 32 struct BrowserGpuChannelHostFactory::CreateRequest {
33 CreateRequest(int32 route_id) 33 CreateRequest(int32 route_id)
34 : event(true, false), 34 : event(true, false),
35 gpu_host_id(0),
36 route_id(route_id), 35 route_id(route_id),
37 result(CREATE_COMMAND_BUFFER_FAILED) {} 36 result(CREATE_COMMAND_BUFFER_FAILED) {}
38 ~CreateRequest() {} 37 ~CreateRequest() {}
39 base::WaitableEvent event; 38 base::WaitableEvent event;
40 int gpu_host_id; 39 int gpu_host_id;
41 int32 route_id; 40 int32 route_id;
42 CreateCommandBufferResult result; 41 CreateCommandBufferResult result;
43 }; 42 };
44 43
44 struct BrowserGpuChannelHostFactory::CreateStreamTextureRequest {
45 CreateStreamTextureRequest(int32 image_id, int32 stream_id, int32 route_id)
46 : event(true, false),
47 image_id(image_id),
48 stream_id(stream_id),
49 route_id(route_id) {}
50 ~CreateStreamTextureRequest() {}
51 base::WaitableEvent event;
52 int32 image_id;
53 int32 stream_id;
54 int32 route_id;
55 bool result;
56 };
57
45 class BrowserGpuChannelHostFactory::EstablishRequest 58 class BrowserGpuChannelHostFactory::EstablishRequest
46 : public base::RefCountedThreadSafe<EstablishRequest> { 59 : public base::RefCountedThreadSafe<EstablishRequest> {
47 public: 60 public:
48 static scoped_refptr<EstablishRequest> Create(CauseForGpuLaunch cause, 61 static scoped_refptr<EstablishRequest> Create(CauseForGpuLaunch cause,
49 int gpu_client_id, 62 int gpu_client_id,
50 int gpu_host_id); 63 int gpu_host_id);
51 void Wait(); 64 void Wait();
52 void Cancel(); 65 void Cancel();
53 66
54 int gpu_host_id() { return gpu_host_id_; } 67 int gpu_host_id() { return gpu_host_id_; }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 host->CreateViewCommandBuffer( 290 host->CreateViewCommandBuffer(
278 surface, 291 surface,
279 surface_id, 292 surface_id,
280 gpu_client_id_, 293 gpu_client_id_,
281 init_params, 294 init_params,
282 request->route_id, 295 request->route_id,
283 base::Bind(&BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO, 296 base::Bind(&BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO,
284 request)); 297 request));
285 } 298 }
286 299
300 void BrowserGpuChannelHostFactory::CreateStreamTextureOnIO(
301 CreateStreamTextureRequest* request) {
302 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_);
303 if (!host) {
304 request->event.Signal();
305 return;
306 }
307 host->CreateStreamTexture(
308 request->image_id, gpu_client_id_, request->route_id, request->stream_id,
309 base::Bind(&BrowserGpuChannelHostFactory::StreamTextureCreatedOnIO,
310 request));
311 }
312
287 IPC::AttachmentBroker* BrowserGpuChannelHostFactory::GetAttachmentBroker() { 313 IPC::AttachmentBroker* BrowserGpuChannelHostFactory::GetAttachmentBroker() {
288 return content::ChildProcessHost::GetAttachmentBroker(); 314 return content::ChildProcessHost::GetAttachmentBroker();
289 } 315 }
290 316
291 // static 317 // static
292 void BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO( 318 void BrowserGpuChannelHostFactory::CommandBufferCreatedOnIO(
293 CreateRequest* request, CreateCommandBufferResult result) { 319 CreateRequest* request, CreateCommandBufferResult result) {
294 request->result = result; 320 request->result = result;
295 request->event.Signal(); 321 request->event.Signal();
296 } 322 }
297 323
324 // static
325 void BrowserGpuChannelHostFactory::StreamTextureCreatedOnIO(
326 CreateStreamTextureRequest* request,
327 bool result) {
328 request->result = result;
329 request->event.Signal();
330 }
331
298 CreateCommandBufferResult BrowserGpuChannelHostFactory::CreateViewCommandBuffer( 332 CreateCommandBufferResult BrowserGpuChannelHostFactory::CreateViewCommandBuffer(
299 int32 surface_id, 333 int32 surface_id,
300 const GPUCreateCommandBufferConfig& init_params, 334 const GPUCreateCommandBufferConfig& init_params,
301 int32 route_id) { 335 int32 route_id) {
302 CreateRequest request(route_id); 336 CreateRequest request(route_id);
303 GetIOThreadTaskRunner()->PostTask( 337 GetIOThreadTaskRunner()->PostTask(
304 FROM_HERE, 338 FROM_HERE,
305 base::Bind(&BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO, 339 base::Bind(&BrowserGpuChannelHostFactory::CreateViewCommandBufferOnIO,
306 base::Unretained(this), &request, surface_id, init_params)); 340 base::Unretained(this), &request, surface_id, init_params));
307 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. 341 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed.
308 tracked_objects::ScopedTracker tracking_profile( 342 tracked_objects::ScopedTracker tracking_profile(
309 FROM_HERE_WITH_EXPLICIT_FUNCTION( 343 FROM_HERE_WITH_EXPLICIT_FUNCTION(
310 "125248 BrowserGpuChannelHostFactory::CreateViewCommandBuffer")); 344 "125248 BrowserGpuChannelHostFactory::CreateViewCommandBuffer"));
311 345
312 // We're blocking the UI thread, which is generally undesirable. 346 // We're blocking the UI thread, which is generally undesirable.
313 // In this case we need to wait for this before we can show any UI /anyway/, 347 // In this case we need to wait for this before we can show any UI /anyway/,
314 // so it won't cause additional jank. 348 // so it won't cause additional jank.
315 // TODO(piman): Make this asynchronous (http://crbug.com/125248). 349 // TODO(piman): Make this asynchronous (http://crbug.com/125248).
316 TRACE_EVENT0("browser", 350 TRACE_EVENT0("browser",
317 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); 351 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer");
318 base::ThreadRestrictions::ScopedAllowWait allow_wait; 352 base::ThreadRestrictions::ScopedAllowWait allow_wait;
319 request.event.Wait(); 353 request.event.Wait();
320 return request.result; 354 return request.result;
321 } 355 }
322 356
357 bool BrowserGpuChannelHostFactory::CreateStreamTexture(int32 image_id,
358 int32 route_id,
359 int32 stream_id) {
360 CreateStreamTextureRequest request(image_id, stream_id, route_id);
361
362 GetIOThreadTaskRunner()->PostTask(
363 FROM_HERE,
364 base::Bind(&BrowserGpuChannelHostFactory::CreateStreamTextureOnIO,
365 base::Unretained(this), &request));
366 TRACE_EVENT0("browser",
367 "BrowserGpuChannelHostFactory::CreateStreamTextureOnIO");
368
369 base::ThreadRestrictions::ScopedAllowWait allow_wait;
370 request.event.Wait();
371 return request.result;
372 }
373
323 // Blocking the UI thread to open a GPU channel is not supported on Android. 374 // Blocking the UI thread to open a GPU channel is not supported on Android.
324 // (Opening the initial channel to a child process involves handling a reply 375 // (Opening the initial channel to a child process involves handling a reply
325 // task on the UI thread first, so we cannot block here.) 376 // task on the UI thread first, so we cannot block here.)
326 #if !defined(OS_ANDROID) 377 #if !defined(OS_ANDROID)
327 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( 378 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync(
328 CauseForGpuLaunch cause_for_gpu_launch) { 379 CauseForGpuLaunch cause_for_gpu_launch) {
329 EstablishGpuChannel(cause_for_gpu_launch, base::Closure()); 380 EstablishGpuChannel(cause_for_gpu_launch, base::Closure());
330 381
331 if (pending_request_.get()) 382 if (pending_request_.get())
332 pending_request_->Wait(); 383 pending_request_->Wait();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 int host_id, 453 int host_id,
403 scoped_refptr<IPC::MessageFilter> filter) { 454 scoped_refptr<IPC::MessageFilter> filter) {
404 DCHECK_CURRENTLY_ON(BrowserThread::IO); 455 DCHECK_CURRENTLY_ON(BrowserThread::IO);
405 456
406 GpuProcessHost* host = GpuProcessHost::FromID(host_id); 457 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
407 if (host) 458 if (host)
408 host->AddFilter(filter.get()); 459 host->AddFilter(filter.get());
409 } 460 }
410 461
411 } // namespace content 462 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698