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

Side by Side Diff: content/common/gpu/gpu_channel_manager.cc

Issue 1210703002: content: Make sure all CreateGpuMemoryBuffer messages are handled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: avoid use of g_thread_safe_sender 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/common/gpu/gpu_channel_manager.h" 5 #include "content/common/gpu/gpu_channel_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 13 matching lines...) Expand all
24 #include "ipc/message_filter.h" 24 #include "ipc/message_filter.h"
25 #include "ui/gl/gl_bindings.h" 25 #include "ui/gl/gl_bindings.h"
26 #include "ui/gl/gl_share_group.h" 26 #include "ui/gl/gl_share_group.h"
27 #if defined(USE_OZONE) 27 #if defined(USE_OZONE)
28 #include "ui/ozone/public/gpu_platform_support.h" 28 #include "ui/ozone/public/gpu_platform_support.h"
29 #include "ui/ozone/public/ozone_platform.h" 29 #include "ui/ozone/public/ozone_platform.h"
30 #endif 30 #endif
31 31
32 namespace content { 32 namespace content {
33 33
34 namespace {
35
36 class GpuChannelManagerMessageFilter : public IPC::MessageFilter {
37 public:
38 GpuChannelManagerMessageFilter(
39 GpuMemoryBufferFactory* gpu_memory_buffer_factory)
40 : sender_(NULL), gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {}
41
42 void OnFilterAdded(IPC::Sender* sender) override {
43 DCHECK(!sender_);
44 sender_ = sender;
45 }
46
47 void OnFilterRemoved() override {
48 DCHECK(sender_);
49 sender_ = NULL;
50 }
51
52 bool OnMessageReceived(const IPC::Message& message) override {
53 DCHECK(sender_);
54 bool handled = true;
55 IPC_BEGIN_MESSAGE_MAP(GpuChannelManagerMessageFilter, message)
56 IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer)
57 IPC_MESSAGE_UNHANDLED(handled = false)
58 IPC_END_MESSAGE_MAP()
59 return handled;
60 }
61
62 protected:
63 ~GpuChannelManagerMessageFilter() override {}
64
65 // GPU IO thread bounces off GpuMsg_CreateGpuMemoryBuffer message, because
66 // the UI thread in the browser process must remain fast at all times.
67 void OnCreateGpuMemoryBuffer(
68 const GpuMsg_CreateGpuMemoryBuffer_Params& params) {
69 TRACE_EVENT2("gpu",
70 "GpuChannelManagerMessageFilter::OnCreateGpuMemoryBuffer",
71 "id", params.id, "client_id", params.client_id);
72 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated(
73 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(
74 params.id, params.size, params.format, params.usage,
75 params.client_id, params.surface_handle)));
76 }
77
78 IPC::Sender* sender_;
79 GpuMemoryBufferFactory* gpu_memory_buffer_factory_;
80 };
81
82 gfx::GpuMemoryBufferType GetGpuMemoryBufferFactoryType() {
83 std::vector<gfx::GpuMemoryBufferType> supported_types;
84 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types);
85 DCHECK(!supported_types.empty());
86 return supported_types[0];
87 }
88
89 } // namespace
90
91 GpuChannelManager::GpuChannelManager( 34 GpuChannelManager::GpuChannelManager(
92 MessageRouter* router, 35 MessageRouter* router,
93 GpuWatchdog* watchdog, 36 GpuWatchdog* watchdog,
94 base::SingleThreadTaskRunner* io_task_runner, 37 base::SingleThreadTaskRunner* io_task_runner,
95 base::WaitableEvent* shutdown_event, 38 base::WaitableEvent* shutdown_event,
96 IPC::SyncChannel* channel, 39 IPC::SyncChannel* channel,
97 IPC::AttachmentBroker* broker) 40 IPC::AttachmentBroker* broker,
41 GpuMemoryBufferFactory* gpu_memory_buffer_factory)
98 : io_task_runner_(io_task_runner), 42 : io_task_runner_(io_task_runner),
99 shutdown_event_(shutdown_event), 43 shutdown_event_(shutdown_event),
100 router_(router), 44 router_(router),
101 gpu_memory_manager_( 45 gpu_memory_manager_(
102 this, 46 this,
103 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), 47 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit),
104 watchdog_(watchdog), 48 watchdog_(watchdog),
105 sync_point_manager_(gpu::SyncPointManager::Create(false)), 49 sync_point_manager_(gpu::SyncPointManager::Create(false)),
106 gpu_memory_buffer_factory_( 50 gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
107 GpuMemoryBufferFactory::Create(GetGpuMemoryBufferFactoryType())),
108 channel_(channel), 51 channel_(channel),
109 filter_(
110 new GpuChannelManagerMessageFilter(gpu_memory_buffer_factory_.get())),
111 relinquish_resources_pending_(false), 52 relinquish_resources_pending_(false),
112 attachment_broker_(broker), 53 attachment_broker_(broker),
113 weak_factory_(this) { 54 weak_factory_(this) {
114 DCHECK(router_); 55 DCHECK(router_);
115 DCHECK(io_task_runner); 56 DCHECK(io_task_runner);
116 DCHECK(shutdown_event); 57 DCHECK(shutdown_event);
117 channel_->AddFilter(filter_.get());
118 } 58 }
119 59
120 GpuChannelManager::~GpuChannelManager() { 60 GpuChannelManager::~GpuChannelManager() {
121 gpu_channels_.clear(); 61 gpu_channels_.clear();
122 if (default_offscreen_surface_.get()) { 62 if (default_offscreen_surface_.get()) {
123 default_offscreen_surface_->Destroy(); 63 default_offscreen_surface_->Destroy();
124 default_offscreen_surface_ = NULL; 64 default_offscreen_surface_ = NULL;
125 } 65 }
126 } 66 }
127 67
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 OnResourcesRelinquished(); 307 OnResourcesRelinquished();
368 #endif 308 #endif
369 } 309 }
370 } 310 }
371 311
372 void GpuChannelManager::OnResourcesRelinquished() { 312 void GpuChannelManager::OnResourcesRelinquished() {
373 Send(new GpuHostMsg_ResourcesRelinquished()); 313 Send(new GpuHostMsg_ResourcesRelinquished());
374 } 314 }
375 315
376 } // namespace content 316 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_channel_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698