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

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

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

Powered by Google App Engine
This is Rietveld 408576698