| 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 "content/common/gpu/gpu_surface_lookup.h" |
| 13 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 14 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
| 15 | 16 |
| 16 // This class is responsible for managing rendering surfaces exposed to the | 17 // 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. | 18 // 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 | 19 // All calls to and from the GPU process, with the exception of |
| 19 // CreateViewCommandBuffer, refer to the rendering surface by its ID. | 20 // CreateViewCommandBuffer, refer to the rendering surface by its ID. |
| 20 // This class is thread safe. | 21 // This class is thread safe. |
| 21 // | 22 // |
| 22 // Note: The ID can exist before the actual native handle for the surface is | 23 // 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 | 24 // created, for example to allow giving a reference to it to a renderer, so that |
| 24 // it is unamibiguously identified. | 25 // it is unamibiguously identified. |
| 25 class GpuSurfaceTracker { | 26 class GpuSurfaceTracker : public GpuSurfaceLookup { |
| 26 public: | 27 public: |
| 28 // GpuSurfaceLookup implementation: |
| 29 // Returns the native widget associated with a given surface_id. |
| 30 virtual gfx::AcceleratedWidget GetNativeWidget(int surface_id) OVERRIDE; |
| 31 |
| 27 // Gets the global instance of the surface tracker. | 32 // Gets the global instance of the surface tracker. |
| 28 static GpuSurfaceTracker* Get() { return GetInstance(); } | 33 static GpuSurfaceTracker* Get() { return GetInstance(); } |
| 29 | 34 |
| 30 // Adds a surface for a given RenderWidgetHost. |renderer_id| is the renderer | 35 // 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 | 36 // process ID, |render_widget_id| is the RenderWidgetHost route id within that |
| 32 // renderer. Returns the surface ID. | 37 // renderer. Returns the surface ID. |
| 33 int AddSurfaceForRenderer(int renderer_id, int render_widget_id); | 38 int AddSurfaceForRenderer(int renderer_id, int render_widget_id); |
| 34 | 39 |
| 35 // Looks up a surface for a given RenderWidgetHost. Returns the surface | 40 // Looks up a surface for a given RenderWidgetHost. Returns the surface |
| 36 // ID, or 0 if not found. | 41 // ID, or 0 if not found. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 int renderer_id; | 76 int renderer_id; |
| 72 int render_widget_id; | 77 int render_widget_id; |
| 73 gfx::AcceleratedWidget native_widget; | 78 gfx::AcceleratedWidget native_widget; |
| 74 gfx::GLSurfaceHandle handle; | 79 gfx::GLSurfaceHandle handle; |
| 75 }; | 80 }; |
| 76 typedef std::map<int, SurfaceInfo> SurfaceMap; | 81 typedef std::map<int, SurfaceInfo> SurfaceMap; |
| 77 | 82 |
| 78 friend struct DefaultSingletonTraits<GpuSurfaceTracker>; | 83 friend struct DefaultSingletonTraits<GpuSurfaceTracker>; |
| 79 | 84 |
| 80 GpuSurfaceTracker(); | 85 GpuSurfaceTracker(); |
| 81 ~GpuSurfaceTracker(); | 86 virtual ~GpuSurfaceTracker(); |
| 82 | 87 |
| 83 base::Lock lock_; | 88 base::Lock lock_; |
| 84 SurfaceMap surface_map_; | 89 SurfaceMap surface_map_; |
| 85 int next_surface_id_; | 90 int next_surface_id_; |
| 86 | 91 |
| 87 DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker); | 92 DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker); |
| 88 }; | 93 }; |
| 89 | 94 |
| 90 #endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ | 95 #endif // CONTENT_BROWSER_GPU_GPU_SURFACE_TRACKER_H_ |
| OLD | NEW |