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

Unified Diff: content/browser/gpu/gpu_surface_tracker.h

Issue 9194005: gpu: reference target surfaces through a globally unique surface id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix more tests Created 8 years, 11 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
« no previous file with comments | « content/browser/gpu/gpu_process_host_ui_shim.cc ('k') | content/browser/gpu/gpu_surface_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/gpu_surface_tracker.h
diff --git a/content/browser/gpu/gpu_surface_tracker.h b/content/browser/gpu/gpu_surface_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..17fa13ab94faba864614e39ad16042529e719580
--- /dev/null
+++ b/content/browser/gpu/gpu_surface_tracker.h
@@ -0,0 +1,81 @@
+// 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.
+
+#ifndef CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
+#define CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "base/memory/singleton.h"
+#include "base/synchronization/lock.h"
+#include "ui/gfx/native_widget_types.h"
+
+// This class is responsible for managing rendering surfaces exposed to the
+// GPU process. Every surface gets registered to this class, and gets an ID.
+// All calls to and from the GPU process, with the exception of
+// CreateViewCommandBuffer, refer to the rendering surface by its ID.
+// This class is thread safe.
+//
+// Note: The ID can exist before the actual native handle for the surface is
+// created, for example to allow giving a reference to it to a renderer, so that
+// it is unamibiguously identified.
+class GpuSurfaceTracker {
+ public:
+ // Gets the global instance of the surface tracker.
+ static GpuSurfaceTracker* Get() { return GetInstance(); }
+
+ // Adds a surface for a given RenderWidgetHost. |renderer_id| is the renderer
+ // process ID, |render_widget_id| is the RenderWidgetHost route id within that
+ // renderer. Returns the surface ID.
+ int AddSurfaceForRenderer(int renderer_id, int render_widget_id);
+
+ // Looks up a surface for a given RenderWidgetHost. Returns the surface
+ // ID, or 0 if not found.
+ // Note: This is an O(N) lookup.
+ int LookupSurfaceForRenderer(int renderer_id, int render_widget_id);
+
+ // Removes a given existing surface.
+ void RemoveSurface(int surface_id);
+
+ // Gets the renderer process ID and RenderWidgetHost route id for a given
+ // surface, returning true if the surface is found (and corresponds to a
+ // RenderWidgetHost), or false if not.
+ bool GetRenderWidgetIDForSurface(int surface_id,
+ int* renderer_id,
+ int* render_widget_id);
+
+ // Sets the native handle for the given surface.
+ // Note: This is an O(log N) lookup.
+ void SetSurfaceHandle(int surface_id, gfx::PluginWindowHandle handle);
+
+ // Gets the native handle for the given surface.
+ // Note: This is an O(log N) lookup.
+ gfx::PluginWindowHandle GetSurfaceHandle(int surface_id);
+
+ // Gets the global instance of the surface tracker. Identical to Get(), but
+ // named that way for the implementation of Singleton.
+ static GpuSurfaceTracker* GetInstance();
+
+ private:
+ struct SurfaceInfo {
+ int renderer_id;
+ int render_widget_id;
+ gfx::PluginWindowHandle handle;
+ };
+ typedef std::map<int, SurfaceInfo> SurfaceMap;
+
+ friend struct DefaultSingletonTraits<GpuSurfaceTracker>;
+
+ GpuSurfaceTracker();
+ ~GpuSurfaceTracker();
+
+ base::Lock lock_;
+ SurfaceMap surface_map_;
+ int next_surface_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker);
+};
+
+#endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
« no previous file with comments | « content/browser/gpu/gpu_process_host_ui_shim.cc ('k') | content/browser/gpu/gpu_surface_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698