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

Unified Diff: gpu/ipc/common/gpu_surface_tracker.h

Issue 2791723003: Update GpuSurfaceTracker to include Android surfaces. (Closed)
Patch Set: made one-arg constructor implicit Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
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..ab225ff18744c20713a63cb234fbdf8b4f1d24d2 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 {
+#if defined(OS_ANDROID)
+ explicit Record(gfx::AcceleratedWidget widget, jobject j_surface);
dcheng 2017/04/14 00:55:24 This doesn't need explicit
liberato (no reviews please) 2017/04/18 20:47:38 Done.
+#else // !defined(OS_ANDROID)
+ // Not explicit, since one can just provide the AcceleratedWidget and let it
+ // auto-convert to Record.
+ Record(gfx::AcceleratedWidget widget);
dcheng 2017/04/14 00:55:24 FWIW, this is specifically against the style guide
liberato (no reviews please) 2017/04/18 20:47:38 good point. i've made the callers explicitly cons
+#endif // !defined(OS_ANDROID)
dcheng 2017/04/14 00:55:24 Nit: usually no ! here (since this usually describ
liberato (no reviews please) 2017/04/18 20:47:38 Done, and elsewhere.
+
+ 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;
dcheng 2017/04/14 00:55:24 Nit using SurfaceMap = ...; since this is changin
liberato (no reviews please) 2017/04/18 20:47:38 Done.
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);
};

Powered by Google App Engine
This is Rietveld 408576698