OLD | NEW |
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" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 | 15 |
| 16 #if defined(OS_ANDROID) |
| 17 gfx::AcceleratedWidget GetNativeWidgetAndroid(int surface_id); |
| 18 #endif |
| 19 |
16 // This class is responsible for managing rendering surfaces exposed to the | 20 // This class is responsible for managing rendering surfaces exposed to the |
17 // GPU process. Every surface gets registered to this class, and gets an ID. | 21 // GPU process. Every surface gets registered to this class, and gets an ID. |
18 // All calls to and from the GPU process, with the exception of | 22 // All calls to and from the GPU process, with the exception of |
19 // CreateViewCommandBuffer, refer to the rendering surface by its ID. | 23 // CreateViewCommandBuffer, refer to the rendering surface by its ID. |
20 // This class is thread safe. | 24 // This class is thread safe. |
21 // | 25 // |
22 // Note: The ID can exist before the actual native handle for the surface is | 26 // Note: The ID can exist before the actual native handle for the surface is |
23 // created, for example to allow giving a reference to it to a renderer, so that | 27 // created, for example to allow giving a reference to it to a renderer, so that |
24 // it is unamibiguously identified. | 28 // it is unamibiguously identified. |
25 class GpuSurfaceTracker { | 29 class GpuSurfaceTracker { |
26 public: | 30 public: |
27 // Gets the global instance of the surface tracker. | 31 // Gets the global instance of the surface tracker. |
28 static GpuSurfaceTracker* Get() { return GetInstance(); } | 32 static GpuSurfaceTracker* Get() { return GetInstance(); } |
29 | 33 |
30 // Adds a surface for a given RenderWidgetHost. |renderer_id| is the renderer | 34 // Adds a surface for a given RenderWidgetHost. |renderer_id| is the renderer |
31 // process ID, |render_widget_id| is the RenderWidgetHost route id within that | 35 // process ID, |render_widget_id| is the RenderWidgetHost route id within that |
32 // renderer. Returns the surface ID. | 36 // renderer. Returns the surface ID. |
33 int AddSurfaceForRenderer(int renderer_id, int render_widget_id); | 37 int AddSurfaceForRenderer(int renderer_id, int render_widget_id); |
34 | 38 |
35 // Looks up a surface for a given RenderWidgetHost. Returns the surface | 39 // Looks up a surface for a given RenderWidgetHost. Returns the surface |
36 // ID, or 0 if not found. | 40 // ID, or 0 if not found. |
37 // Note: This is an O(N) lookup. | 41 // Note: This is an O(N) lookup. |
38 int LookupSurfaceForRenderer(int renderer_id, int render_widget_id); | 42 int LookupSurfaceForRenderer(int renderer_id, int render_widget_id); |
39 | 43 |
40 // Adds a surface for a native widget. Returns the surface ID. | 44 // Adds a surface for a native widget. Returns the surface ID. |
41 int AddSurfaceForNativeWidget(gfx::AcceleratedWidget widget); | 45 int AddSurfaceForNativeWidget(gfx::AcceleratedWidget widget); |
42 | 46 |
| 47 // Returns the native widget associated with a given surface_id. |
| 48 gfx::AcceleratedWidget GetNativeWidget(int surface_id); |
| 49 |
43 // Removes a given existing surface. | 50 // Removes a given existing surface. |
44 void RemoveSurface(int surface_id); | 51 void RemoveSurface(int surface_id); |
45 | 52 |
46 // Gets the renderer process ID and RenderWidgetHost route id for a given | 53 // Gets the renderer process ID and RenderWidgetHost route id for a given |
47 // surface, returning true if the surface is found (and corresponds to a | 54 // surface, returning true if the surface is found (and corresponds to a |
48 // RenderWidgetHost), or false if not. | 55 // RenderWidgetHost), or false if not. |
49 bool GetRenderWidgetIDForSurface(int surface_id, | 56 bool GetRenderWidgetIDForSurface(int surface_id, |
50 int* renderer_id, | 57 int* renderer_id, |
51 int* render_widget_id); | 58 int* render_widget_id); |
52 | 59 |
(...skipping 28 matching lines...) Expand all Loading... |
81 ~GpuSurfaceTracker(); | 88 ~GpuSurfaceTracker(); |
82 | 89 |
83 base::Lock lock_; | 90 base::Lock lock_; |
84 SurfaceMap surface_map_; | 91 SurfaceMap surface_map_; |
85 int next_surface_id_; | 92 int next_surface_id_; |
86 | 93 |
87 DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker); | 94 DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker); |
88 }; | 95 }; |
89 | 96 |
90 #endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ | 97 #endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ |
OLD | NEW |