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

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: wip 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 #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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 GpuWatchdog* watchdog, 376 GpuWatchdog* watchdog,
379 gfx::GLShareGroup* share_group, 377 gfx::GLShareGroup* share_group,
380 gpu::gles2::MailboxManager* mailbox, 378 gpu::gles2::MailboxManager* mailbox,
381 int client_id, 379 int client_id,
382 bool software) 380 bool software)
383 : gpu_channel_manager_(gpu_channel_manager), 381 : gpu_channel_manager_(gpu_channel_manager),
384 messages_processed_(0), 382 messages_processed_(0),
385 client_id_(client_id), 383 client_id_(client_id),
386 share_group_(share_group ? share_group : new gfx::GLShareGroup), 384 share_group_(share_group ? share_group : new gfx::GLShareGroup),
387 mailbox_manager_(mailbox ? mailbox : new gpu::gles2::MailboxManager), 385 mailbox_manager_(mailbox ? mailbox : new gpu::gles2::MailboxManager),
388 image_manager_(new gpu::gles2::ImageManager),
389 watchdog_(watchdog), 386 watchdog_(watchdog),
390 software_(software), 387 software_(software),
391 handle_messages_scheduled_(false), 388 handle_messages_scheduled_(false),
392 currently_processing_message_(NULL), 389 currently_processing_message_(NULL),
393 weak_factory_(this), 390 weak_factory_(this),
394 num_stubs_descheduled_(0) { 391 num_stubs_descheduled_(0) {
395 DCHECK(gpu_channel_manager); 392 DCHECK(gpu_channel_manager);
396 DCHECK(client_id); 393 DCHECK(client_id);
397 394
398 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu"); 395 channel_id_ = IPC::Channel::GenerateVerifiedChannelID("gpu");
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 bool use_virtualized_gl_context = false; 542 bool use_virtualized_gl_context = false;
546 #if defined(OS_MACOSX) 543 #if defined(OS_MACOSX)
547 use_virtualized_gl_context = true; 544 use_virtualized_gl_context = true;
548 #endif 545 #endif
549 546
550 scoped_ptr<GpuCommandBufferStub> stub( 547 scoped_ptr<GpuCommandBufferStub> stub(
551 new GpuCommandBufferStub(this, 548 new GpuCommandBufferStub(this,
552 share_group, 549 share_group,
553 window, 550 window,
554 mailbox_manager_.get(), 551 mailbox_manager_.get(),
555 image_manager_.get(),
556 gfx::Size(), 552 gfx::Size(),
557 disallowed_features_, 553 disallowed_features_,
558 init_params.attribs, 554 init_params.attribs,
559 init_params.gpu_preference, 555 init_params.gpu_preference,
560 use_virtualized_gl_context, 556 use_virtualized_gl_context,
561 route_id, 557 route_id,
562 surface_id, 558 surface_id,
563 watchdog_, 559 watchdog_,
564 software_, 560 software_,
565 init_params.active_url)); 561 init_params.active_url));
566 if (preempted_flag_.get()) 562 if (preempted_flag_.get())
567 stub->SetPreemptByFlag(preempted_flag_); 563 stub->SetPreemptByFlag(preempted_flag_);
568 if (!router_.AddRoute(route_id, stub.get())) { 564 if (!router_.AddRoute(route_id, stub.get())) {
569 DLOG(ERROR) << "GpuChannel::CreateViewCommandBuffer(): " 565 DLOG(ERROR) << "GpuChannel::CreateViewCommandBuffer(): "
570 "failed to add route"; 566 "failed to add route";
571 return false; 567 return false;
572 } 568 }
573 stubs_.AddWithID(stub.release(), route_id); 569 stubs_.AddWithID(stub.release(), route_id);
574 return true; 570 return true;
575 } 571 }
576 572
577 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) { 573 GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) {
578 return stubs_.Lookup(route_id); 574 return stubs_.Lookup(route_id);
579 } 575 }
580 576
581 void GpuChannel::CreateImage(
582 gfx::PluginWindowHandle window,
583 int32 image_id,
584 gfx::Size* size) {
585 TRACE_EVENT1("gpu",
586 "GpuChannel::CreateImage",
587 "image_id",
588 image_id);
589
590 *size = gfx::Size();
591
592 if (image_manager_->LookupImage(image_id)) {
593 LOG(ERROR) << "CreateImage failed, image_id already in use.";
594 return;
595 }
596
597 scoped_refptr<gfx::GLImage> image = gfx::GLImage::CreateGLImage(window);
598 if (!image.get())
599 return;
600
601 image_manager_->AddImage(image.get(), image_id);
602 *size = image->GetSize();
603 }
604
605 void GpuChannel::DeleteImage(int32 image_id) {
606 TRACE_EVENT1("gpu",
607 "GpuChannel::DeleteImage",
608 "image_id",
609 image_id);
610
611 image_manager_->RemoveImage(image_id);
612 }
613
614 void GpuChannel::LoseAllContexts() { 577 void GpuChannel::LoseAllContexts() {
615 gpu_channel_manager_->LoseAllContexts(); 578 gpu_channel_manager_->LoseAllContexts();
616 } 579 }
617 580
618 void GpuChannel::MarkAllContextsLost() { 581 void GpuChannel::MarkAllContextsLost() {
619 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 582 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
620 !it.IsAtEnd(); it.Advance()) { 583 !it.IsAtEnd(); it.Advance()) {
621 it.GetCurrentValue()->MarkContextLost(); 584 it.GetCurrentValue()->MarkContextLost();
622 } 585 }
623 } 586 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 int32 route_id, 712 int32 route_id,
750 bool* succeeded) { 713 bool* succeeded) {
751 TRACE_EVENT0("gpu", "GpuChannel::OnCreateOffscreenCommandBuffer"); 714 TRACE_EVENT0("gpu", "GpuChannel::OnCreateOffscreenCommandBuffer");
752 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id); 715 GpuCommandBufferStub* share_group = stubs_.Lookup(init_params.share_group_id);
753 716
754 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( 717 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub(
755 this, 718 this,
756 share_group, 719 share_group,
757 gfx::GLSurfaceHandle(), 720 gfx::GLSurfaceHandle(),
758 mailbox_manager_.get(), 721 mailbox_manager_.get(),
759 image_manager_.get(),
760 size, 722 size,
761 disallowed_features_, 723 disallowed_features_,
762 init_params.attribs, 724 init_params.attribs,
763 init_params.gpu_preference, 725 init_params.gpu_preference,
764 false, 726 false,
765 route_id, 727 route_id,
766 0, 728 0,
767 watchdog_, 729 watchdog_,
768 software_, 730 software_,
769 init_params.active_url)); 731 init_params.active_url));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 uint64 GpuChannel::GetMemoryUsage() { 798 uint64 GpuChannel::GetMemoryUsage() {
837 uint64 size = 0; 799 uint64 size = 0;
838 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 800 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
839 !it.IsAtEnd(); it.Advance()) { 801 !it.IsAtEnd(); it.Advance()) {
840 size += it.GetCurrentValue()->GetMemoryUsage(); 802 size += it.GetCurrentValue()->GetMemoryUsage();
841 } 803 }
842 return size; 804 return size;
843 } 805 }
844 806
845 } // namespace content 807 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698