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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/gpu_channel_manager.cc
diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc
index 899da86e45f047842ab902387c699c612cdb8844..acfcbc15c173056987219bb58cee7ca8388c7057 100644
--- a/content/common/gpu/gpu_channel_manager.cc
+++ b/content/common/gpu/gpu_channel_manager.cc
@@ -46,6 +46,9 @@ GpuChannelManager::GpuChannelManager(MessageRouter* router,
DCHECK(router_);
DCHECK(io_message_loop);
DCHECK(shutdown_event);
+#if defined(USE_X11)
+ gfx::X11PixmapTracker::InitInstance(this);
+#endif
}
GpuChannelManager::~GpuChannelManager() {
@@ -158,6 +161,9 @@ void GpuChannelManager::OnCloseChannel(
for (GpuChannelMap::iterator iter = gpu_channels_.begin();
iter != gpu_channels_.end(); ++iter) {
if (iter->second->GetChannelName() == channel_handle.name) {
+#if defined(USE_X11)
+ RemoveAllPixmaps(iter->first);
+#endif
gpu_channels_.erase(iter);
return;
}
@@ -183,28 +189,48 @@ void GpuChannelManager::OnCreateViewCommandBuffer(
}
void GpuChannelManager::CreateImage(
- gfx::PluginWindowHandle window, int32 client_id, int32 image_id) {
- gfx::Size size;
-
- GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
- if (iter != gpu_channels_.end()) {
- iter->second->CreateImage(window, image_id, &size);
+ const gfx::GpuMemoryBufferHandle& handle,
+ const gfx::Size& size,
+ unsigned internalformat,
+ int32 client_id,
+ int32 image_id) {
+ switch (handle.type) {
+#if defined(USE_X11)
+ case gfx::X11_PIXMAP_BUFFER:
+ AddPixmap(handle.pixmap,
+ handle.global_id.primary_id,
+ handle.global_id.secondary_id);
+ break;
+#endif
+ default:
+ NOTIMPLEMENTED();
+ break;
}
- Send(new GpuHostMsg_ImageCreated(size));
+ GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
+ Send(new GpuHostMsg_ImageCreated(
+ iter != gpu_channels_.end()
+ ? iter->second->CreateImage(handle, size, internalformat, image_id)
+ : false));
}
void GpuChannelManager::OnCreateImage(
- gfx::PluginWindowHandle window, int32 client_id, int32 image_id) {
+ const gfx::GpuMemoryBufferHandle& handle,
+ const gfx::Size& size,
+ unsigned internalformat,
+ int32 client_id,
+ int32 image_id) {
DCHECK(image_id);
if (image_operations_.empty()) {
- CreateImage(window, client_id, image_id);
+ CreateImage(handle, size, internalformat, client_id, image_id);
} else {
image_operations_.push_back(
new ImageOperation(0, base::Bind(&GpuChannelManager::CreateImage,
base::Unretained(this),
- window,
+ handle,
+ size,
+ internalformat,
client_id,
image_id)));
}
@@ -307,6 +333,9 @@ void GpuChannelManager::LoseAllContexts() {
void GpuChannelManager::OnLoseAllContexts() {
gpu_channels_.clear();
+#if defined(USE_X11)
+ pixmaps_.clear();
+#endif
}
gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
@@ -317,4 +346,33 @@ gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
return default_offscreen_surface_.get();
}
+#if defined(USE_X11)
+XID GpuChannelManager::AcquirePixmap(int primary_id, int secondary_id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ X11PixmapMapKey key(primary_id, secondary_id);
+ X11PixmapMap::iterator it = pixmaps_.find(key);
+ if (it == pixmaps_.end())
+ return 0;
+ XID pixmap = it->second;
+ pixmaps_.erase(it);
+ return pixmap;
+}
+
+void GpuChannelManager::AddPixmap(XID pixmap, int pixmap_id, int client_id) {
+ X11PixmapMapKey key(pixmap_id, client_id);
+ DCHECK(pixmaps_.find(key) == pixmaps_.end());
+ pixmaps_[key] = pixmap;
+}
+
+void GpuChannelManager::RemoveAllPixmaps(int client_id) {
+ X11PixmapMap::iterator it = pixmaps_.begin();
+ while (it != pixmaps_.end()) {
+ if (it->first.second == client_id)
+ pixmaps_.erase(it++);
+ else
+ ++it;
+ }
+}
+#endif
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698