OLD | NEW |
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" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // 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/, |
291 // so it won't cause additional jank. | 291 // so it won't cause additional jank. |
292 // TODO(piman): Make this asynchronous (http://crbug.com/125248). | 292 // TODO(piman): Make this asynchronous (http://crbug.com/125248). |
293 TRACE_EVENT0("browser", | 293 TRACE_EVENT0("browser", |
294 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); | 294 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); |
295 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 295 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
296 request.event.Wait(); | 296 request.event.Wait(); |
297 return request.result; | 297 return request.result; |
298 } | 298 } |
299 | 299 |
300 void BrowserGpuChannelHostFactory::CreateImageOnIO( | |
301 gfx::PluginWindowHandle window, | |
302 int32 image_id, | |
303 const CreateImageCallback& callback) { | |
304 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | |
305 if (!host) { | |
306 ImageCreatedOnIO(callback, gfx::Size()); | |
307 return; | |
308 } | |
309 | |
310 host->CreateImage( | |
311 window, | |
312 gpu_client_id_, | |
313 image_id, | |
314 base::Bind(&BrowserGpuChannelHostFactory::ImageCreatedOnIO, callback)); | |
315 } | |
316 | |
317 // static | |
318 void BrowserGpuChannelHostFactory::ImageCreatedOnIO( | |
319 const CreateImageCallback& callback, const gfx::Size size) { | |
320 BrowserThread::PostTask( | |
321 BrowserThread::UI, | |
322 FROM_HERE, | |
323 base::Bind(&BrowserGpuChannelHostFactory::OnImageCreated, | |
324 callback, size)); | |
325 } | |
326 | |
327 // static | |
328 void BrowserGpuChannelHostFactory::OnImageCreated( | |
329 const CreateImageCallback& callback, const gfx::Size size) { | |
330 callback.Run(size); | |
331 } | |
332 | |
333 void BrowserGpuChannelHostFactory::CreateImage( | |
334 gfx::PluginWindowHandle window, | |
335 int32 image_id, | |
336 const CreateImageCallback& callback) { | |
337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
338 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( | |
339 &BrowserGpuChannelHostFactory::CreateImageOnIO, | |
340 base::Unretained(this), | |
341 window, | |
342 image_id, | |
343 callback)); | |
344 } | |
345 | |
346 void BrowserGpuChannelHostFactory::DeleteImageOnIO( | |
347 int32 image_id, int32 sync_point) { | |
348 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | |
349 if (!host) { | |
350 return; | |
351 } | |
352 | |
353 host->DeleteImage(gpu_client_id_, image_id, sync_point); | |
354 } | |
355 | |
356 void BrowserGpuChannelHostFactory::DeleteImage( | |
357 int32 image_id, int32 sync_point) { | |
358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
359 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( | |
360 &BrowserGpuChannelHostFactory::DeleteImageOnIO, | |
361 base::Unretained(this), | |
362 image_id, | |
363 sync_point)); | |
364 } | |
365 | |
366 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( | 300 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( |
367 CauseForGpuLaunch cause_for_gpu_launch) { | 301 CauseForGpuLaunch cause_for_gpu_launch) { |
368 EstablishGpuChannel(cause_for_gpu_launch, base::Closure()); | 302 EstablishGpuChannel(cause_for_gpu_launch, base::Closure()); |
369 | 303 |
370 if (pending_request_) | 304 if (pending_request_) |
371 pending_request_->Wait(); | 305 pending_request_->Wait(); |
372 | 306 |
373 return gpu_channel_.get(); | 307 return gpu_channel_.get(); |
374 } | 308 } |
375 | 309 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 const gfx::GpuMemoryBufferHandle& handle, | 486 const gfx::GpuMemoryBufferHandle& handle, |
553 int32 sync_point) { | 487 int32 sync_point) { |
554 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | 488 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
555 if (!host) | 489 if (!host) |
556 return; | 490 return; |
557 | 491 |
558 host->DestroyGpuMemoryBuffer(handle, sync_point); | 492 host->DestroyGpuMemoryBuffer(handle, sync_point); |
559 } | 493 } |
560 | 494 |
561 } // namespace content | 495 } // namespace content |
OLD | NEW |