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

Side by Side Diff: content/browser/gpu/gpu_surface_tracker.h

Issue 1359163005: Remove surface_id from RenderWidget/RenderWidgetHost and friends (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@channel_creation_preempt
Patch Set: fix more tests Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ 5 #ifndef CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
6 #define CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ 6 #define CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 18 matching lines...) Expand all
29 // it is unamibiguously identified. 29 // it is unamibiguously identified.
30 class CONTENT_EXPORT GpuSurfaceTracker : public GpuSurfaceLookup { 30 class CONTENT_EXPORT GpuSurfaceTracker : public GpuSurfaceLookup {
31 public: 31 public:
32 // GpuSurfaceLookup implementation: 32 // GpuSurfaceLookup implementation:
33 // Returns the native widget associated with a given surface_id. 33 // Returns the native widget associated with a given surface_id.
34 gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override; 34 gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override;
35 35
36 // Gets the global instance of the surface tracker. 36 // Gets the global instance of the surface tracker.
37 static GpuSurfaceTracker* Get() { return GetInstance(); } 37 static GpuSurfaceTracker* Get() { return GetInstance(); }
38 38
39 // Adds a surface for a given RenderWidgetHost. |renderer_id| is the renderer
40 // process ID, |render_widget_id| is the RenderWidgetHost route id within that
41 // renderer. Returns the surface ID.
42 int AddSurfaceForRenderer(int renderer_id, int render_widget_id);
43
44 // Looks up a surface for a given RenderWidgetHost. Returns the surface
45 // ID, or 0 if not found.
46 // Note: This is an O(N) lookup.
47 int LookupSurfaceForRenderer(int renderer_id, int render_widget_id);
48
49 // Adds a surface for a native widget. Returns the surface ID. 39 // Adds a surface for a native widget. Returns the surface ID.
50 int AddSurfaceForNativeWidget(gfx::AcceleratedWidget widget); 40 int AddSurfaceForNativeWidget(gfx::AcceleratedWidget widget);
51 41
52 // Removes a given existing surface. 42 // Removes a given existing surface.
53 void RemoveSurface(int surface_id); 43 void RemoveSurface(int surface_id);
54 44
55 // Sets the native handle for the given surface. 45 // Sets the native handle for the given surface.
56 // Note: This is an O(log N) lookup. 46 // Note: This is an O(log N) lookup.
57 void SetSurfaceHandle(int surface_id, const gfx::GLSurfaceHandle& handle); 47 void SetSurfaceHandle(int surface_id, const gfx::GLSurfaceHandle& handle);
58 48
59 // Gets the native handle for the given surface. 49 // Gets the native handle for the given surface.
60 // Note: This is an O(log N) lookup. 50 // Note: This is an O(log N) lookup.
61 gfx::GLSurfaceHandle GetSurfaceHandle(int surface_id); 51 gfx::GLSurfaceHandle GetSurfaceHandle(int surface_id);
62 52
63 // Returns the number of surfaces currently registered with the tracker. 53 // Returns the number of surfaces currently registered with the tracker.
64 std::size_t GetSurfaceCount(); 54 std::size_t GetSurfaceCount();
65 55
66 // Gets the global instance of the surface tracker. Identical to Get(), but 56 // Gets the global instance of the surface tracker. Identical to Get(), but
67 // named that way for the implementation of Singleton. 57 // named that way for the implementation of Singleton.
68 static GpuSurfaceTracker* GetInstance(); 58 static GpuSurfaceTracker* GetInstance();
69 59
70 private: 60 private:
71 struct SurfaceInfo { 61 struct SurfaceInfo {
72 SurfaceInfo(); 62 SurfaceInfo();
73 SurfaceInfo(int renderer_id, 63 SurfaceInfo(const gfx::AcceleratedWidget& native_widget,
74 int render_widget_id,
75 const gfx::AcceleratedWidget& native_widget,
76 const gfx::GLSurfaceHandle& handle); 64 const gfx::GLSurfaceHandle& handle);
77 ~SurfaceInfo(); 65 ~SurfaceInfo();
78 int renderer_id;
79 int render_widget_id;
80 gfx::AcceleratedWidget native_widget; 66 gfx::AcceleratedWidget native_widget;
81 gfx::GLSurfaceHandle handle; 67 gfx::GLSurfaceHandle handle;
82 }; 68 };
83 typedef std::map<int, SurfaceInfo> SurfaceMap; 69 typedef std::map<int, SurfaceInfo> SurfaceMap;
84 70
85 friend struct base::DefaultSingletonTraits<GpuSurfaceTracker>; 71 friend struct base::DefaultSingletonTraits<GpuSurfaceTracker>;
86 72
87 GpuSurfaceTracker(); 73 GpuSurfaceTracker();
88 ~GpuSurfaceTracker() override; 74 ~GpuSurfaceTracker() override;
89 75
90 base::Lock lock_; 76 base::Lock lock_;
91 SurfaceMap surface_map_; 77 SurfaceMap surface_map_;
92 int next_surface_id_; 78 int next_surface_id_;
93 79
94 DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker); 80 DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker);
95 }; 81 };
96 82
97 } // namespace content 83 } // namespace content
98 84
99 #endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ 85 #endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_widget_host_view_guest_unittest.cc ('k') | content/browser/gpu/gpu_surface_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698