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

Unified Diff: app/gfx/gl/gl_context_egl.h

Issue 6296004: EGL contexts reference count the EGL surfaces they share.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « no previous file | app/gfx/gl/gl_context_egl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/gl/gl_context_egl.h
===================================================================
--- app/gfx/gl/gl_context_egl.h (revision 71275)
+++ app/gfx/gl/gl_context_egl.h (working copy)
@@ -6,8 +6,9 @@
#define APP_GFX_GL_GL_CONTEXT_EGL_H_
#pragma once
+#include "app/gfx/gl/gl_context.h"
+#include "base/ref_counted.h"
#include "gfx/size.h"
-#include "app/gfx/gl/gl_context.h"
typedef void* EGLDisplay;
typedef void* EGLContext;
@@ -15,6 +16,20 @@
namespace gfx {
+// Takes ownership of an EGL surface and reference counts it so it can be shared
+// by multiple EGL contexts and destroyed with the last.
+class SharedEGLSurface : public base::RefCounted<SharedEGLSurface> {
+ public:
+ explicit SharedEGLSurface(EGLSurface surface);
+ ~SharedEGLSurface();
+
+ EGLSurface egl_surface() const;
+
+ private:
+ EGLSurface surface_;
+ DISALLOW_COPY_AND_ASSIGN(SharedEGLSurface);
+};
+
// Interface for EGL contexts. Adds an EGL specific accessor for retreiving
// the surface.
class BaseEGLContext : public GLContext {
@@ -27,7 +42,7 @@
static EGLDisplay GetDisplay();
// Get the associated EGL surface.
- virtual EGLSurface GetSurface() = 0;
+ virtual SharedEGLSurface* GetSurface() = 0;
// Implement GLContext.
virtual std::string GetExtensions();
@@ -56,20 +71,21 @@
virtual void SetSwapInterval(int interval);
// Implement BaseEGLContext.
- virtual EGLSurface GetSurface();
+ virtual SharedEGLSurface* GetSurface();
private:
void* window_;
- EGLSurface surface_;
+ scoped_refptr<SharedEGLSurface> surface_;
EGLContext context_;
DISALLOW_COPY_AND_ASSIGN(NativeViewEGLContext);
};
// Encapsulates an EGL OpenGL ES context intended for offscreen use. It is
-// actually associated with a native window and will render to it. The caller
-// must bind an FBO to prevent this. Not using pbuffers because ANGLE does not
-// support them.
+// actually associated with a native window or a pbuffer on supporting platforms
+// and will render to it. The caller must bind an FBO to prevent this.
+// TODO(apatrick): implement pbuffers in ANGLE and change this to
+// PbufferEGLContext and use it on all EGL platforms.
class SecondaryEGLContext : public BaseEGLContext {
public:
SecondaryEGLContext();
@@ -89,12 +105,10 @@
virtual void SetSwapInterval(int interval);
// Implement BaseEGLContext.
- virtual EGLSurface GetSurface();
+ virtual SharedEGLSurface* GetSurface();
private:
- // All offscreen
- EGLSurface surface_;
- bool own_surface_;
+ scoped_refptr<SharedEGLSurface> surface_;
EGLContext context_;
DISALLOW_COPY_AND_ASSIGN(SecondaryEGLContext);
« no previous file with comments | « no previous file | app/gfx/gl/gl_context_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698