summaryrefslogtreecommitdiffstats
path: root/content/browser/gpu/gpu_surface_tracker.h
diff options
context:
space:
mode:
authorbenm@chromium.org <benm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-12 12:29:59 +0000
committerbenm@chromium.org <benm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-12 12:29:59 +0000
commitfa893ac0228308da04ea8452cf3af5a650221f0d (patch)
tree5deadb06b82a598d657581f5f89155cfb6a6fb29 /content/browser/gpu/gpu_surface_tracker.h
parent00aa8e1c91bdcf9ce00676fdc4b658abdabb243e (diff)
downloadchromium_src-fa893ac0228308da04ea8452cf3af5a650221f0d.zip
chromium_src-fa893ac0228308da04ea8452cf3af5a650221f0d.tar.gz
chromium_src-fa893ac0228308da04ea8452cf3af5a650221f0d.tar.bz2
Patch refactors the GpuProcessHost::SurfaceRef class that was previously only used on GTK to ensure that browser process drawing surface wasn't torn down until the GPU process was done with it so that it can be used on Android too.
[Android notes...] Ensure that we don't release the Java side resources used by SurfaceTextureBridge until the gpu process is completely finished with the GL surface. Otherwise we end up with a race between the RenderView shutting down and releasing the Java Surface, yet the GPU process continuing to use it. Bug: b/7697692 Bug: 119006 Review URL: https://chromiumcodereview.appspot.com/12989029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193907 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/gpu/gpu_surface_tracker.h')
-rw-r--r--content/browser/gpu/gpu_surface_tracker.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/content/browser/gpu/gpu_surface_tracker.h b/content/browser/gpu/gpu_surface_tracker.h
index ddf0a66..de9d666 100644
--- a/content/browser/gpu/gpu_surface_tracker.h
+++ b/content/browser/gpu/gpu_surface_tracker.h
@@ -8,6 +8,7 @@
#include <map>
#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
#include "content/common/gpu/gpu_surface_lookup.h"
@@ -27,6 +28,27 @@ namespace content {
// it is unamibiguously identified.
class GpuSurfaceTracker : public GpuSurfaceLookup {
public:
+ // Base class for reference counting surfaces. We store a
+ // reference to an instance of this class in the surface_map_
+ // and GpuProcessHost (if the GPU process is drawing to
+ // the surface with a Command Buffer). The reference count ensures that
+ // we don't destroy the object until it's released from both places.
+ //
+ // This is especially important on Android and GTK where the surface must
+ // not be destroyed when the WebContents is closed if the GPU is still
+ // drawing to it. Those platforms extend this class with the functionality
+ // they need to implement on tear down (see SurfaceRefPluginWindow for GTK and
+ // SurfaceRefAndroid for Android).
+ class SurfaceRef : public base::RefCountedThreadSafe<SurfaceRef> {
+ protected:
+ SurfaceRef() { }
+ virtual ~SurfaceRef() { }
+
+ private:
+ friend class base::RefCountedThreadSafe<SurfaceRef>;
+ DISALLOW_COPY_AND_ASSIGN(SurfaceRef);
+ };
+
// GpuSurfaceLookup implementation:
// Returns the native widget associated with a given surface_id.
virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) OVERRIDE;
@@ -62,7 +84,10 @@ class GpuSurfaceTracker : public GpuSurfaceLookup {
void SetSurfaceHandle(int surface_id, const gfx::GLSurfaceHandle& handle);
// Sets the native widget associated with the surface_id.
- void SetNativeWidget(int surface_id, gfx::AcceleratedWidget widget);
+ void SetNativeWidget(
+ int surface_id,
+ gfx::AcceleratedWidget widget,
+ SurfaceRef* surface_ref);
// Gets the native handle for the given surface.
// Note: This is an O(log N) lookup.
@@ -75,12 +100,24 @@ class GpuSurfaceTracker : public GpuSurfaceLookup {
// named that way for the implementation of Singleton.
static GpuSurfaceTracker* GetInstance();
+ scoped_refptr<SurfaceRef> GetSurfaceRefForSurface(int surface_id) {
+ return surface_map_[surface_id].surface_ref;
+ }
+
private:
struct SurfaceInfo {
+ SurfaceInfo();
+ SurfaceInfo(int renderer_id,
+ int render_widget_id,
+ const gfx::AcceleratedWidget& native_widget,
+ const gfx::GLSurfaceHandle& handle,
+ const scoped_refptr<SurfaceRef>& surface_ref);
+ ~SurfaceInfo();
int renderer_id;
int render_widget_id;
gfx::AcceleratedWidget native_widget;
gfx::GLSurfaceHandle handle;
+ scoped_refptr<SurfaceRef> surface_ref;
};
typedef std::map<int, SurfaceInfo> SurfaceMap;