summaryrefslogtreecommitdiffstats
path: root/content/browser/gpu/gpu_surface_tracker.cc
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-18 22:29:56 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-18 22:29:56 +0000
commit9f4f3322e7c9a5feedd5ca2b986daf2f8d5b8d3d (patch)
treea67a3d0397a03e12ee51aa8720f612c62c20e936 /content/browser/gpu/gpu_surface_tracker.cc
parenta3102766e725636ad23ad99faa1e8a481a1129e7 (diff)
downloadchromium_src-9f4f3322e7c9a5feedd5ca2b986daf2f8d5b8d3d.zip
chromium_src-9f4f3322e7c9a5feedd5ca2b986daf2f8d5b8d3d.tar.gz
chromium_src-9f4f3322e7c9a5feedd5ca2b986daf2f8d5b8d3d.tar.bz2
gpu: reference target surfaces through a globally unique surface id.
This allows the gpu process to ignore all knowledge of renderers. It simplifies some of the gpu <-> browser and gpu <-> renderer IPC, but mostly paves the way for non-renderer clients. Surfaces are kept in a global GpuSurfaceTracker which is just a thread-safe map. BUG=99516 TEST=covered by existing tests. Run chrome, open poster circle (or other accelerated content page). Review URL: http://codereview.chromium.org/9194005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118172 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/gpu/gpu_surface_tracker.cc')
-rw-r--r--content/browser/gpu/gpu_surface_tracker.cc75
1 files changed, 75 insertions, 0 deletions
diff --git a/content/browser/gpu/gpu_surface_tracker.cc b/content/browser/gpu/gpu_surface_tracker.cc
new file mode 100644
index 0000000..280f48f
--- /dev/null
+++ b/content/browser/gpu/gpu_surface_tracker.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/gpu/gpu_surface_tracker.h"
+
+#include "base/logging.h"
+
+GpuSurfaceTracker::GpuSurfaceTracker()
+ : next_surface_id_(1) {
+}
+
+GpuSurfaceTracker::~GpuSurfaceTracker() {
+}
+
+GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() {
+ return Singleton<GpuSurfaceTracker>::get();
+}
+
+int GpuSurfaceTracker::AddSurfaceForRenderer(int renderer_id,
+ int render_widget_id) {
+ base::AutoLock lock(lock_);
+ SurfaceInfo info = { renderer_id, render_widget_id, gfx::kNullPluginWindow };
+ int surface_id = next_surface_id_++;
+ surface_map_[surface_id] = info;
+ return surface_id;
+}
+
+int GpuSurfaceTracker::LookupSurfaceForRenderer(int renderer_id,
+ int render_widget_id) {
+ base::AutoLock lock(lock_);
+ for (SurfaceMap::iterator it = surface_map_.begin(); it != surface_map_.end();
+ ++it) {
+ const SurfaceInfo& info = it->second;
+ if (info.renderer_id == renderer_id &&
+ info.render_widget_id == render_widget_id) {
+ return it->first;
+ }
+ }
+ return 0;
+}
+
+void GpuSurfaceTracker::RemoveSurface(int surface_id) {
+ base::AutoLock lock(lock_);
+ DCHECK(surface_map_.find(surface_id) != surface_map_.end());
+ surface_map_.erase(surface_id);
+}
+
+bool GpuSurfaceTracker::GetRenderWidgetIDForSurface(int surface_id,
+ int* renderer_id,
+ int* render_widget_id) {
+ base::AutoLock lock(lock_);
+ SurfaceMap::iterator it = surface_map_.find(surface_id);
+ if (it == surface_map_.end())
+ return false;
+ const SurfaceInfo& info = it->second;
+ *renderer_id = info.renderer_id;
+ *render_widget_id = info.render_widget_id;
+ return true;
+}
+
+void GpuSurfaceTracker::SetSurfaceHandle(int surface_id,
+ gfx::PluginWindowHandle handle) {
+ base::AutoLock lock(lock_);
+ DCHECK(surface_map_.find(surface_id) != surface_map_.end());
+ SurfaceInfo& info = surface_map_[surface_id];
+ info.handle = handle;
+}
+
+gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceHandle(int surface_id) {
+ base::AutoLock lock(lock_);
+ DCHECK(surface_map_.find(surface_id) != surface_map_.end());
+ return surface_map_[surface_id].handle;
+}
+