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

Side by Side Diff: content/common/gpu/gpu_channel_manager.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: have GpuChannelManager implement X11PixmapTracker Created 6 years, 6 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/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/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_memory_manager.h" 10 #include "content/common/gpu/gpu_memory_manager.h"
(...skipping 28 matching lines...) Expand all
39 shutdown_event_(shutdown_event), 39 shutdown_event_(shutdown_event),
40 router_(router), 40 router_(router),
41 gpu_memory_manager_( 41 gpu_memory_manager_(
42 this, 42 this,
43 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), 43 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit),
44 watchdog_(watchdog), 44 watchdog_(watchdog),
45 sync_point_manager_(new SyncPointManager) { 45 sync_point_manager_(new SyncPointManager) {
46 DCHECK(router_); 46 DCHECK(router_);
47 DCHECK(io_message_loop); 47 DCHECK(io_message_loop);
48 DCHECK(shutdown_event); 48 DCHECK(shutdown_event);
49 #if defined(USE_X11)
50 gfx::X11PixmapTracker::InitInstance(this);
51 #endif
49 } 52 }
50 53
51 GpuChannelManager::~GpuChannelManager() { 54 GpuChannelManager::~GpuChannelManager() {
52 gpu_channels_.clear(); 55 gpu_channels_.clear();
53 if (default_offscreen_surface_.get()) { 56 if (default_offscreen_surface_.get()) {
54 default_offscreen_surface_->Destroy(); 57 default_offscreen_surface_->Destroy();
55 default_offscreen_surface_ = NULL; 58 default_offscreen_surface_ = NULL;
56 } 59 }
57 DCHECK(image_operations_.empty()); 60 DCHECK(image_operations_.empty());
58 } 61 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 gpu_channels_.set(client_id, channel.Pass()); 154 gpu_channels_.set(client_id, channel.Pass());
152 155
153 Send(new GpuHostMsg_ChannelEstablished(channel_handle)); 156 Send(new GpuHostMsg_ChannelEstablished(channel_handle));
154 } 157 }
155 158
156 void GpuChannelManager::OnCloseChannel( 159 void GpuChannelManager::OnCloseChannel(
157 const IPC::ChannelHandle& channel_handle) { 160 const IPC::ChannelHandle& channel_handle) {
158 for (GpuChannelMap::iterator iter = gpu_channels_.begin(); 161 for (GpuChannelMap::iterator iter = gpu_channels_.begin();
159 iter != gpu_channels_.end(); ++iter) { 162 iter != gpu_channels_.end(); ++iter) {
160 if (iter->second->GetChannelName() == channel_handle.name) { 163 if (iter->second->GetChannelName() == channel_handle.name) {
164 #if defined(USE_X11)
165 RemoveAllPixmaps(iter->first);
166 #endif
161 gpu_channels_.erase(iter); 167 gpu_channels_.erase(iter);
162 return; 168 return;
163 } 169 }
164 } 170 }
165 } 171 }
166 172
167 void GpuChannelManager::OnCreateViewCommandBuffer( 173 void GpuChannelManager::OnCreateViewCommandBuffer(
168 const gfx::GLSurfaceHandle& window, 174 const gfx::GLSurfaceHandle& window,
169 int32 surface_id, 175 int32 surface_id,
170 int32 client_id, 176 int32 client_id,
171 const GPUCreateCommandBufferConfig& init_params, 177 const GPUCreateCommandBufferConfig& init_params,
172 int32 route_id) { 178 int32 route_id) {
173 DCHECK(surface_id); 179 DCHECK(surface_id);
174 bool succeeded = false; 180 bool succeeded = false;
175 181
176 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); 182 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
177 if (iter != gpu_channels_.end()) { 183 if (iter != gpu_channels_.end()) {
178 succeeded = iter->second->CreateViewCommandBuffer( 184 succeeded = iter->second->CreateViewCommandBuffer(
179 window, surface_id, init_params, route_id); 185 window, surface_id, init_params, route_id);
180 } 186 }
181 187
182 Send(new GpuHostMsg_CommandBufferCreated(succeeded)); 188 Send(new GpuHostMsg_CommandBufferCreated(succeeded));
183 } 189 }
184 190
185 void GpuChannelManager::CreateImage( 191 void GpuChannelManager::CreateImage(
186 gfx::PluginWindowHandle window, int32 client_id, int32 image_id) { 192 const gfx::GpuMemoryBufferHandle& handle,
187 gfx::Size size; 193 const gfx::Size& size,
194 unsigned internalformat,
195 int32 client_id,
196 int32 image_id) {
197 switch (handle.type) {
198 #if defined(USE_X11)
199 case gfx::X11_PIXMAP_BUFFER:
200 AddPixmap(handle.pixmap,
201 handle.global_id.primary_id,
202 handle.global_id.secondary_id);
203 break;
204 #endif
205 default:
206 NOTIMPLEMENTED();
207 break;
208 }
188 209
189 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); 210 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
190 if (iter != gpu_channels_.end()) { 211 Send(new GpuHostMsg_ImageCreated(
191 iter->second->CreateImage(window, image_id, &size); 212 iter != gpu_channels_.end()
192 } 213 ? iter->second->CreateImage(handle, size, internalformat, image_id)
193 214 : false));
194 Send(new GpuHostMsg_ImageCreated(size));
195 } 215 }
196 216
197 void GpuChannelManager::OnCreateImage( 217 void GpuChannelManager::OnCreateImage(
198 gfx::PluginWindowHandle window, int32 client_id, int32 image_id) { 218 const gfx::GpuMemoryBufferHandle& handle,
219 const gfx::Size& size,
220 unsigned internalformat,
221 int32 client_id,
222 int32 image_id) {
199 DCHECK(image_id); 223 DCHECK(image_id);
200 224
201 if (image_operations_.empty()) { 225 if (image_operations_.empty()) {
202 CreateImage(window, client_id, image_id); 226 CreateImage(handle, size, internalformat, client_id, image_id);
203 } else { 227 } else {
204 image_operations_.push_back( 228 image_operations_.push_back(
205 new ImageOperation(0, base::Bind(&GpuChannelManager::CreateImage, 229 new ImageOperation(0, base::Bind(&GpuChannelManager::CreateImage,
206 base::Unretained(this), 230 base::Unretained(this),
207 window, 231 handle,
232 size,
233 internalformat,
208 client_id, 234 client_id,
209 image_id))); 235 image_id)));
210 } 236 }
211 } 237 }
212 238
213 void GpuChannelManager::DeleteImage(int32 client_id, int32 image_id) { 239 void GpuChannelManager::DeleteImage(int32 client_id, int32 image_id) {
214 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); 240 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
215 if (iter != gpu_channels_.end()) { 241 if (iter != gpu_channels_.end()) {
216 iter->second->DeleteImage(image_id); 242 iter->second->DeleteImage(image_id);
217 } 243 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 iter->second->MarkAllContextsLost(); 326 iter->second->MarkAllContextsLost();
301 } 327 }
302 base::MessageLoop::current()->PostTask( 328 base::MessageLoop::current()->PostTask(
303 FROM_HERE, 329 FROM_HERE,
304 base::Bind(&GpuChannelManager::OnLoseAllContexts, 330 base::Bind(&GpuChannelManager::OnLoseAllContexts,
305 weak_factory_.GetWeakPtr())); 331 weak_factory_.GetWeakPtr()));
306 } 332 }
307 333
308 void GpuChannelManager::OnLoseAllContexts() { 334 void GpuChannelManager::OnLoseAllContexts() {
309 gpu_channels_.clear(); 335 gpu_channels_.clear();
336 #if defined(USE_X11)
337 pixmaps_.clear();
338 #endif
310 } 339 }
311 340
312 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 341 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
313 if (!default_offscreen_surface_.get()) { 342 if (!default_offscreen_surface_.get()) {
314 default_offscreen_surface_ = 343 default_offscreen_surface_ =
315 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); 344 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size());
316 } 345 }
317 return default_offscreen_surface_.get(); 346 return default_offscreen_surface_.get();
318 } 347 }
319 348
349 #if defined(USE_X11)
350 XID GpuChannelManager::AcquirePixmap(int primary_id, int secondary_id) {
351 DCHECK(thread_checker_.CalledOnValidThread());
352 X11PixmapMapKey key(primary_id, secondary_id);
353 X11PixmapMap::iterator it = pixmaps_.find(key);
354 if (it == pixmaps_.end())
355 return 0;
356 XID pixmap = it->second;
357 pixmaps_.erase(it);
358 return pixmap;
359 }
360
361 void GpuChannelManager::AddPixmap(XID pixmap, int pixmap_id, int client_id) {
362 X11PixmapMapKey key(pixmap_id, client_id);
363 DCHECK(pixmaps_.find(key) == pixmaps_.end());
364 pixmaps_[key] = pixmap;
365 }
366
367 void GpuChannelManager::RemoveAllPixmaps(int client_id) {
368 X11PixmapMap::iterator it = pixmaps_.begin();
369 while (it != pixmaps_.end()) {
370 if (it->first.second == client_id)
371 pixmaps_.erase(it++);
372 else
373 ++it;
374 }
375 }
376 #endif
377
320 } // namespace content 378 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698