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

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: . 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 static GpuSurfaceTracker* GetInstance();
27 static GpuSurfaceTracker* Get() { return GetInstance(); }
jonathan.backer 2012/01/16 19:47:26 Why both Get() and GetInstance()?
piman 2012/01/17 19:40:54 I added a comment, it's just syntactic sugar. Sing
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);
jonathan.backer 2012/01/16 19:47:26 Not sure it matters (this isn't performance critic
piman 2012/01/17 19:40:54 Yeah, I figured it's not worth the extra space, pl
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 private:
58 struct SurfaceInfo {
59 int renderer_id;
60 int render_widget_id;
61 gfx::PluginWindowHandle handle;
62 };
63 typedef std::map<int, SurfaceInfo> SurfaceMap;
64
65 friend class DefaultSingletonTraits<GpuSurfaceTracker>;
66
67 GpuSurfaceTracker();
68 ~GpuSurfaceTracker();
69
70 base::Lock lock_;
71 SurfaceMap surface_map_;
72 int next_surface_id_;
73
74 DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker);
75 };
76
77 #endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698