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

Side by Side Diff: content/common/gpu/gpu_channel.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: rebase 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
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_channel_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 10
11 #include <queue> 11 #include <queue>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/debug/trace_event.h" 16 #include "base/debug/trace_event.h"
17 #include "base/message_loop/message_loop_proxy.h" 17 #include "base/message_loop/message_loop_proxy.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/timer/timer.h" 20 #include "base/timer/timer.h"
21 #include "content/common/gpu/devtools_gpu_agent.h" 21 #include "content/common/gpu/devtools_gpu_agent.h"
22 #include "content/common/gpu/gpu_channel_manager.h" 22 #include "content/common/gpu/gpu_channel_manager.h"
23 #include "content/common/gpu/gpu_messages.h" 23 #include "content/common/gpu/gpu_messages.h"
24 #include "content/common/gpu/sync_point_manager.h" 24 #include "content/common/gpu/sync_point_manager.h"
25 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
26 #include "gpu/command_buffer/common/mailbox.h" 26 #include "gpu/command_buffer/common/mailbox.h"
27 #include "gpu/command_buffer/service/gpu_scheduler.h" 27 #include "gpu/command_buffer/service/gpu_scheduler.h"
28 #include "gpu/command_buffer/service/image_manager.h"
29 #include "gpu/command_buffer/service/mailbox_manager.h" 28 #include "gpu/command_buffer/service/mailbox_manager.h"
30 #include "ipc/ipc_channel.h" 29 #include "ipc/ipc_channel.h"
31 #include "ipc/message_filter.h" 30 #include "ipc/message_filter.h"
32 #include "ui/gl/gl_context.h" 31 #include "ui/gl/gl_context.h"
33 #include "ui/gl/gl_image.h"
34 #include "ui/gl/gl_surface.h" 32 #include "ui/gl/gl_surface.h"
35 33
36 #if defined(OS_POSIX) 34 #if defined(OS_POSIX)
37 #include "ipc/ipc_channel_posix.h" 35 #include "ipc/ipc_channel_posix.h"
38 #endif 36 #endif
39 37
40 namespace content { 38 namespace content {
41 namespace { 39 namespace {
42 40
43 // Number of milliseconds between successive vsync. Many GL commands block 41 // Number of milliseconds between successive vsync. Many GL commands block
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 gfx::GLShareGroup* share_group, 399 gfx::GLShareGroup* share_group,
402 gpu::gles2::MailboxManager* mailbox, 400 gpu::gles2::MailboxManager* mailbox,
403 int client_id, 401 int client_id,
404 bool software, 402 bool software,
405 bool allow_future_sync_points) 403 bool allow_future_sync_points)
406 : gpu_channel_manager_(gpu_channel_manager), 404 : gpu_channel_manager_(gpu_channel_manager),
407 messages_processed_(0), 405 messages_processed_(0),
408 client_id_(client_id), 406 client_id_(client_id),
409 share_group_(share_group ? share_group : new gfx::GLShareGroup), 407 share_group_(share_group ? share_group : new gfx::GLShareGroup),
410 mailbox_manager_(mailbox ? mailbox : new gpu::gles2::MailboxManager), 408 mailbox_manager_(mailbox ? mailbox : new gpu::gles2::MailboxManager),
411 image_manager_(new gpu::gles2::ImageManager),
412 watchdog_(watchdog), 409 watchdog_(watchdog),
413 software_(software), 410 software_(software),
414 handle_messages_scheduled_(false), 411 handle_messages_scheduled_(false),
415 currently_processing_message_(NULL), 412 currently_processing_message_(NULL),
416 weak_factory_(this), 413 weak_factory_(this),
417 num_stubs_descheduled_(0), 414 num_stubs_descheduled_(0),
418 allow_future_sync_points_(allow_future_sync_points) { 415 allow_future_sync_points_(allow_future_sync_points) {
419 DCHECK(gpu_channel_manager); 416 DCHECK(gpu_channel_manager);
420 DCHECK(client_id); 417 DCHECK(client_id);
421 418
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 bool use_virtualized_gl_context = false; 567 bool use_virtualized_gl_context = false;
571 #if defined(OS_MACOSX) 568 #if defined(OS_MACOSX)
572 use_virtualized_gl_context = true; 569 use_virtualized_gl_context = true;
573 #endif 570 #endif
574 571
575 scoped_ptr<GpuCommandBufferStub> stub( 572 scoped_ptr<GpuCommandBufferStub> stub(
576 new GpuCommandBufferStub(this, 573 new GpuCommandBufferStub(this,
577 share_group, 574 share_group,
578 window, 575 window,
579 mailbox_manager_.get(), 576 mailbox_manager_.get(),
580 image_manager_.get(),
581 gfx::Size(), 577 gfx::Size(),
582 disallowed_features_, 578 disallowed_features_,
583 init_params.attribs, 579 init_params.attribs,
584 init_params.gpu_preference, 580 init_params.gpu_preference,
585 use_virtualized_gl_context, 581 use_virtualized_gl_context,
586 route_id, 582 route_id,
587 surface_id, 583 surface_id,
588 watchdog_, 584 watchdog_,
589 software_, 585 software_,
590 init_params.active_url)); 586 init_params.active_url));
591 if (preempted_flag_.get()) 587 if (preempted_flag_.get())
592 stub->SetPreemptByFlag(preempted_flag_); 588 stub->SetPreemptByFlag(preempted_flag_);
593 if (!router_.AddRoute(route_id, stub.get())) { 589 if (!router_.AddRoute(route_id, stub.get())) {
594 DLOG(ERROR) << "GpuChannel::CreateViewCommandBuffer(): " 590 DLOG(ERROR) << "GpuChannel::CreateViewCommandBuffer(): "
595 "failed to add route"; 591 "failed to add route";
596 return CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST; 592 return CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST;
597 } 593 }
598 stubs_.AddWithID(stub.release(), route_id); 594 stubs_.AddWithID(stub.release(), route_id);
599 return CREATE_COMMAND_BUFFER_SUCCEEDED; 595 return CREATE_COMMAND_BUFFER_SUCCEEDED;
600 } 596 }
601 597
602 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) { 598 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) {
603 return stubs_.Lookup(route_id); 599 return stubs_.Lookup(route_id);
604 } 600 }
605 601
606 void GpuChannel::CreateImage(
607 gfx::PluginWindowHandle window,
608 int32 image_id,
609 gfx::Size* size) {
610 TRACE_EVENT1("gpu",
611 "GpuChannel::CreateImage",
612 "image_id",
613 image_id);
614
615 *size = gfx::Size();
616
617 if (image_manager_->LookupImage(image_id)) {
618 LOG(ERROR) << "CreateImage failed, image_id already in use.";
619 return;
620 }
621
622 scoped_refptr<gfx::GLImage> image = gfx::GLImage::CreateGLImage(window);
623 if (!image.get())
624 return;
625
626 image_manager_->AddImage(image.get(), image_id);
627 *size = image->GetSize();
628 }
629
630 void GpuChannel::DeleteImage(int32 image_id) {
631 TRACE_EVENT1("gpu",
632 "GpuChannel::DeleteImage",
633 "image_id",
634 image_id);
635
636 image_manager_->RemoveImage(image_id);
637 }
638
639 void GpuChannel::LoseAllContexts() { 602 void GpuChannel::LoseAllContexts() {
640 gpu_channel_manager_->LoseAllContexts(); 603 gpu_channel_manager_->LoseAllContexts();
641 } 604 }
642 605
643 void GpuChannel::MarkAllContextsLost() { 606 void GpuChannel::MarkAllContextsLost() {
644 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 607 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
645 !it.IsAtEnd(); it.Advance()) { 608 !it.IsAtEnd(); it.Advance()) {
646 it.GetCurrentValue()->MarkContextLost(); 609 it.GetCurrentValue()->MarkContextLost();
647 } 610 }
648 } 611 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 int32 route_id, 737 int32 route_id,
775 bool* succeeded) { 738 bool* succeeded) {
776 TRACE_EVENT0("gpu", "GpuChannel::OnCreateOffscreenCommandBuffer"); 739 TRACE_EVENT0("gpu", "GpuChannel::OnCreateOffscreenCommandBuffer");
777 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id); 740 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id);
778 741
779 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( 742 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub(
780 this, 743 this,
781 share_group, 744 share_group,
782 gfx::GLSurfaceHandle(), 745 gfx::GLSurfaceHandle(),
783 mailbox_manager_.get(), 746 mailbox_manager_.get(),
784 image_manager_.get(),
785 size, 747 size,
786 disallowed_features_, 748 disallowed_features_,
787 init_params.attribs, 749 init_params.attribs,
788 init_params.gpu_preference, 750 init_params.gpu_preference,
789 false, 751 false,
790 route_id, 752 route_id,
791 0, 753 0,
792 watchdog_, 754 watchdog_,
793 software_, 755 software_,
794 init_params.active_url)); 756 init_params.active_url));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 uint64 GpuChannel::GetMemoryUsage() { 823 uint64 GpuChannel::GetMemoryUsage() {
862 uint64 size = 0; 824 uint64 size = 0;
863 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 825 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
864 !it.IsAtEnd(); it.Advance()) { 826 !it.IsAtEnd(); it.Advance()) {
865 size += it.GetCurrentValue()->GetMemoryUsage(); 827 size += it.GetCurrentValue()->GetMemoryUsage();
866 } 828 }
867 return size; 829 return size;
868 } 830 }
869 831
870 } // namespace content 832 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_channel_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698