Chromium Code Reviews| Index: gpu/ipc/common/gpu_surface_tracker.h |
| diff --git a/gpu/ipc/common/gpu_surface_tracker.h b/gpu/ipc/common/gpu_surface_tracker.h |
| index 6d372712521397e6e77bd9d9160d1e7888dbfdcd..5aa32fd138030c8758006d0c06532eac877b96de 100644 |
| --- a/gpu/ipc/common/gpu_surface_tracker.h |
| +++ b/gpu/ipc/common/gpu_surface_tracker.h |
| @@ -26,12 +26,32 @@ namespace gpu { |
| // GpuMemoryBufferManager::CreateGpuMemoryBuffer. |
| // On Android, the handle is used in the GPU process to get a reference to the |
| // ANativeWindow, using GpuSurfaceLookup (implemented by |
| -// ChildProcessSurfaceManager). |
| +// ChildProcessSurfaceManager). We require that an Android Surface is provided |
| +// with the ANativeWindow, so one must provide an explicit GpuSurfaceTracker:: |
| +// Record when adding it. |
| // On Mac, the handle just passes through the GPU process, and is sent back via |
| // GpuCommandBufferMsg_SwapBuffersCompleted to reference the surface. |
| // This class is thread safe. |
| class GPU_EXPORT GpuSurfaceTracker : public gpu::GpuSurfaceLookup { |
| public: |
| + struct Record { |
| + // Do not mark 'explicit', since most platforms can just provide a widget |
| + // and we'll automatically construct a Record for it. |
| + Record(gfx::AcceleratedWidget widget |
| +#if defined(OS_ANDROID) |
| + , |
| + jobject j_surface |
|
boliu
2017/04/10 22:50:46
maybe just write two versions of the constructor,
|
| +#endif |
| + ); |
| + Record(Record&&); |
| + Record(const Record&) = delete; |
| + |
| + gfx::AcceleratedWidget widget; |
| +#if defined(OS_ANDROID) |
| + gl::ScopedJavaSurface surface; |
| +#endif |
| + }; |
| + |
| // GpuSurfaceLookup implementation: |
| // Returns the native widget associated with a given surface_handle. |
| // On Android, this adds a reference on the ANativeWindow. |
| @@ -39,16 +59,15 @@ class GPU_EXPORT GpuSurfaceTracker : public gpu::GpuSurfaceLookup { |
| gpu::SurfaceHandle surface_handle) override; |
| #if defined(OS_ANDROID) |
| - void RegisterViewSurface(int surface_id, jobject j_surface); |
| - void UnregisterViewSurface(int surface_id); |
| - gl::ScopedJavaSurface AcquireJavaSurface(int surface_id) override; |
| + gl::ScopedJavaSurface AcquireJavaSurface( |
| + gpu::SurfaceHandle surface_handle) override; |
| #endif |
| // Gets the global instance of the surface tracker. |
| static GpuSurfaceTracker* Get() { return GetInstance(); } |
| // Adds a surface for a native widget. Returns the surface ID. |
| - int AddSurfaceForNativeWidget(gfx::AcceleratedWidget widget); |
| + int AddSurfaceForNativeWidget(Record record); |
| // Return true if the surface handle is registered with the tracker. |
| bool IsValidSurfaceHandle(gpu::SurfaceHandle surface_handle) const; |
| @@ -64,7 +83,7 @@ class GPU_EXPORT GpuSurfaceTracker : public gpu::GpuSurfaceLookup { |
| static GpuSurfaceTracker* GetInstance(); |
| private: |
| - typedef std::map<gpu::SurfaceHandle, gfx::AcceleratedWidget> SurfaceMap; |
| + typedef std::map<gpu::SurfaceHandle, Record> SurfaceMap; |
| friend struct base::DefaultSingletonTraits<GpuSurfaceTracker>; |
| @@ -75,12 +94,6 @@ class GPU_EXPORT GpuSurfaceTracker : public gpu::GpuSurfaceLookup { |
| SurfaceMap surface_map_; |
| int next_surface_handle_; |
| -#if defined(OS_ANDROID) |
| - base::Lock surface_view_map_lock_; |
| - typedef std::map<gpu::SurfaceHandle, gl::ScopedJavaSurface> SurfaceViewMap; |
| - SurfaceViewMap surface_view_map_; |
| -#endif |
| - |
| DISALLOW_COPY_AND_ASSIGN(GpuSurfaceTracker); |
| }; |