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

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

Issue 10543125: gpu: Add support for GLX_EXT_texture_from_pixmap extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add kGLImplementationMockGL case to gl_image_android.cc. Created 8 years, 2 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_manager.h ('k') | content/common/gpu/gpu_command_buffer_stub.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 #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 "content/common/child_thread.h" 9 #include "content/common/child_thread.h"
10 #include "content/common/gpu/gpu_channel.h" 10 #include "content/common/gpu/gpu_channel.h"
11 #include "content/common/gpu/gpu_memory_manager.h" 11 #include "content/common/gpu/gpu_memory_manager.h"
12 #include "content/common/gpu/gpu_messages.h" 12 #include "content/common/gpu/gpu_messages.h"
13 #include "content/common/gpu/sync_point_manager.h" 13 #include "content/common/gpu/sync_point_manager.h"
14 #include "gpu/command_buffer/service/feature_info.h" 14 #include "gpu/command_buffer/service/feature_info.h"
15 #include "gpu/command_buffer/service/gpu_switches.h" 15 #include "gpu/command_buffer/service/gpu_switches.h"
16 #include "gpu/command_buffer/service/mailbox_manager.h" 16 #include "gpu/command_buffer/service/mailbox_manager.h"
17 #include "gpu/command_buffer/service/memory_program_cache.h" 17 #include "gpu/command_buffer/service/memory_program_cache.h"
18 #include "ui/gl/gl_bindings.h" 18 #include "ui/gl/gl_bindings.h"
19 #include "ui/gl/gl_share_group.h" 19 #include "ui/gl/gl_share_group.h"
20 20
21 GpuChannelManager::ImageOperation::ImageOperation(
22 int32 sync_point, base::Closure callback)
23 : sync_point(sync_point),
24 callback(callback) {
25 }
26
27 GpuChannelManager::ImageOperation::~ImageOperation() {
28 }
29
21 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, 30 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread,
22 GpuWatchdog* watchdog, 31 GpuWatchdog* watchdog,
23 base::MessageLoopProxy* io_message_loop, 32 base::MessageLoopProxy* io_message_loop,
24 base::WaitableEvent* shutdown_event) 33 base::WaitableEvent* shutdown_event)
25 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 34 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
26 io_message_loop_(io_message_loop), 35 io_message_loop_(io_message_loop),
27 shutdown_event_(shutdown_event), 36 shutdown_event_(shutdown_event),
28 gpu_child_thread_(gpu_child_thread), 37 gpu_child_thread_(gpu_child_thread),
29 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, 38 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this,
30 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)), 39 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)),
31 watchdog_(watchdog), 40 watchdog_(watchdog),
32 sync_point_manager_(new SyncPointManager), 41 sync_point_manager_(new SyncPointManager),
33 program_cache_(NULL) { 42 program_cache_(NULL) {
34 DCHECK(gpu_child_thread); 43 DCHECK(gpu_child_thread);
35 DCHECK(io_message_loop); 44 DCHECK(io_message_loop);
36 DCHECK(shutdown_event); 45 DCHECK(shutdown_event);
37 } 46 }
38 47
39 GpuChannelManager::~GpuChannelManager() { 48 GpuChannelManager::~GpuChannelManager() {
40 gpu_channels_.clear(); 49 gpu_channels_.clear();
41 if (default_offscreen_surface_.get()) { 50 if (default_offscreen_surface_.get()) {
42 default_offscreen_surface_->Destroy(); 51 default_offscreen_surface_->Destroy();
43 default_offscreen_surface_ = NULL; 52 default_offscreen_surface_ = NULL;
44 } 53 }
54 DCHECK(image_operations_.empty());
45 } 55 }
46 56
47 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { 57 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() {
48 if (!program_cache_.get() && 58 if (!program_cache_.get() &&
49 (gfx::g_ARB_get_program_binary || gfx::g_OES_get_program_binary) && 59 (gfx::g_ARB_get_program_binary || gfx::g_OES_get_program_binary) &&
50 !CommandLine::ForCurrentProcess()->HasSwitch( 60 !CommandLine::ForCurrentProcess()->HasSwitch(
51 switches::kDisableGpuProgramCache)) { 61 switches::kDisableGpuProgramCache)) {
52 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); 62 program_cache_.reset(new gpu::gles2::MemoryProgramCache());
53 } 63 }
54 return program_cache_.get(); 64 return program_cache_.get();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 98 }
89 99
90 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { 100 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
91 bool msg_is_ok = true; 101 bool msg_is_ok = true;
92 bool handled = true; 102 bool handled = true;
93 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) 103 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok)
94 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) 104 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
95 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) 105 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
96 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, 106 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
97 OnCreateViewCommandBuffer) 107 OnCreateViewCommandBuffer)
108 IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage)
109 IPC_MESSAGE_HANDLER(GpuMsg_DeleteImage, OnDeleteImage)
98 IPC_MESSAGE_UNHANDLED(handled = false) 110 IPC_MESSAGE_UNHANDLED(handled = false)
99 IPC_END_MESSAGE_MAP_EX() 111 IPC_END_MESSAGE_MAP_EX()
100 return handled; 112 return handled;
101 } 113 }
102 114
103 bool GpuChannelManager::Send(IPC::Message* msg) { 115 bool GpuChannelManager::Send(IPC::Message* msg) {
104 return gpu_child_thread_->Send(msg); 116 return gpu_child_thread_->Send(msg);
105 } 117 }
106 118
107 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) { 119 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 174
163 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); 175 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
164 if (iter != gpu_channels_.end()) { 176 if (iter != gpu_channels_.end()) {
165 iter->second->CreateViewCommandBuffer( 177 iter->second->CreateViewCommandBuffer(
166 window, surface_id, init_params, &route_id); 178 window, surface_id, init_params, &route_id);
167 } 179 }
168 180
169 Send(new GpuHostMsg_CommandBufferCreated(route_id)); 181 Send(new GpuHostMsg_CommandBufferCreated(route_id));
170 } 182 }
171 183
184 void GpuChannelManager::CreateImage(
185 gfx::PluginWindowHandle window, int32 client_id, int32 image_id) {
186 gfx::Size size;
187
188 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
189 if (iter != gpu_channels_.end()) {
190 iter->second->CreateImage(window, image_id, &size);
191 }
192
193 Send(new GpuHostMsg_ImageCreated(size));
194 }
195
196 void GpuChannelManager::OnCreateImage(
197 gfx::PluginWindowHandle window, int32 client_id, int32 image_id) {
198 DCHECK(image_id);
199
200 if (image_operations_.empty()) {
201 CreateImage(window, client_id, image_id);
202 } else {
203 image_operations_.push_back(
204 new ImageOperation(0, base::Bind(&GpuChannelManager::CreateImage,
205 base::Unretained(this),
206 window,
207 client_id,
208 image_id)));
209 }
210 }
211
212 void GpuChannelManager::DeleteImage(int32 client_id, int32 image_id) {
213 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
214 if (iter != gpu_channels_.end()) {
215 iter->second->DeleteImage(image_id);
216 }
217 }
218
219 void GpuChannelManager::OnDeleteImage(
220 int32 client_id, int32 image_id, int32 sync_point) {
221 DCHECK(image_id);
222
223 if (!sync_point && image_operations_.empty()) {
224 DeleteImage(client_id, image_id);
225 } else {
226 image_operations_.push_back(
227 new ImageOperation(sync_point,
228 base::Bind(&GpuChannelManager::DeleteImage,
229 base::Unretained(this),
230 client_id,
231 image_id)));
232 if (sync_point) {
233 sync_point_manager()->AddSyncPointCallback(
234 sync_point,
235 base::Bind(&GpuChannelManager::OnDeleteImageSyncPointRetired,
236 base::Unretained(this),
237 image_operations_.back()));
238 }
239 }
240 }
241
242 void GpuChannelManager::OnDeleteImageSyncPointRetired(
243 ImageOperation* image_operation) {
244 // Mark operation as no longer having a pending sync point.
245 image_operation->sync_point = 0;
246
247 // De-queue operations until we reach a pending sync point.
248 while (!image_operations_.empty()) {
249 // Check if operation has a pending sync point.
250 if (image_operations_.front()->sync_point)
251 return;
252
253 image_operations_.front()->callback.Run();
254 delete image_operations_.front();
255 image_operations_.pop_front();
256 }
257 }
258
172 void GpuChannelManager::LoseAllContexts() { 259 void GpuChannelManager::LoseAllContexts() {
173 MessageLoop::current()->PostTask( 260 MessageLoop::current()->PostTask(
174 FROM_HERE, 261 FROM_HERE,
175 base::Bind(&GpuChannelManager::OnLoseAllContexts, 262 base::Bind(&GpuChannelManager::OnLoseAllContexts,
176 weak_factory_.GetWeakPtr())); 263 weak_factory_.GetWeakPtr()));
177 } 264 }
178 265
179 void GpuChannelManager::OnLoseAllContexts() { 266 void GpuChannelManager::OnLoseAllContexts() {
180 gpu_channels_.clear(); 267 gpu_channels_.clear();
181 } 268 }
182 269
183 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 270 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
184 if (!default_offscreen_surface_.get()) { 271 if (!default_offscreen_surface_.get()) {
185 default_offscreen_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( 272 default_offscreen_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(
186 false, gfx::Size(1, 1)); 273 false, gfx::Size(1, 1));
187 } 274 }
188 return default_offscreen_surface_.get(); 275 return default_offscreen_surface_.get();
189 } 276 }
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698