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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
6 #define CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/memory/singleton.h"
12 #include "base/synchronization/lock.h"
13 #include "ui/gfx/native_widget_types.h"
14
15 // This class is responsible for managing rendering surfaces exposed to the
16 // GPU process. Every surface gets registered to this class, and gets an ID.
17 // All calls to and from the GPU process, with the exception of
18 // CreateViewCommandBuffer, refer to the rendering surface by its ID.
19 // This class is thread safe.
20 //
21 // Note: The ID can exist before the actual native handle for the surface is
22 // created, for example to allow giving a reference to it to a renderer, so that
23 // it is unamibiguously identified.
24 class GpuSurfaceTracker {
25 public:
26 // Gets the global instance of the surface tracker.
27 static GpuSurfaceTracker* Get() { return GetInstance(); }
28
29 // Adds a surface for a given RenderWidgetHost. |renderer_id| is the renderer
30 // process ID, |render_widget_id| is the RenderWidgetHost route id within that
31 // renderer. Returns the surface ID.
32 int AddSurfaceForRenderer(int renderer_id, int render_widget_id);
33
34 // Looks up a surface for a given RenderWidgetHost. Returns the surface
35 // ID, or 0 if not found.
36 // Note: This is an O(N) lookup.
37 int LookupSurfaceForRenderer(int renderer_id, int render_widget_id);
38
39 // Removes a given existing surface.
40 void RemoveSurface(int surface_id);
41
42 // Gets the renderer process ID and RenderWidgetHost route id for a given
43 // surface, returning true if the surface is found (and corresponds to a
44 // RenderWidgetHost), or false if not.
45 bool GetRenderWidgetIDForSurface(int surface_id,
46 int* renderer_id,
47 int* render_widget_id);
48
49 // Sets the native handle for the given surface.
50 // Note: This is an O(log N) lookup.
51 void SetSurfaceHandle(int surface_id, gfx::PluginWindowHandle handle);
52
53 // Gets the native handle for the given surface.
54 // Note: This is an O(log N) lookup.
55 gfx::PluginWindowHandle GetSurfaceHandle(int surface_id);
56
57 // Gets the global instance of the surface tracker. Identical to Get(), but
58 // named that way for the implementation of Singleton.
59 static GpuSurfaceTracker* GetInstance();
60
61 private:
62 struct SurfaceInfo {
63 int renderer_id;
64 int render_widget_id;
65 gfx::PluginWindowHandle handle;
66 };
67 typedef std::map<int, SurfaceInfo> SurfaceMap;
68
69 friend struct DefaultSingletonTraits<GpuSurfaceTracker>;
70
71 GpuSurfaceTracker();
72 ~GpuSurfaceTracker();
73
74 base::Lock lock_;
75 SurfaceMap surface_map_;
76 int next_surface_id_;
77
78 DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker);
79 };
80
81 #endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
OLDNEW
« 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