Bug 937196 - Remove mPlatformContext from GLContextProviderEGL - r=jgilbert
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 15 Nov 2013 11:28:36 -0500
changeset 154879 81ca3fc9e506
parent 154878 60a117ce0fab
child 154880 6a83dc3f7886
push id25656
push userryanvm@gmail.com
push dateSat, 16 Nov 2013 02:44:05 +0000
treeherdermozilla-central@a475f94bb1b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs937196
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 937196 - Remove mPlatformContext from GLContextProviderEGL - r=jgilbert
gfx/gl/GLContextProviderEGL.cpp
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -229,17 +229,16 @@ public:
                  EGLConfig config,
                  EGLSurface surface,
                  EGLContext context)
         : GLContext(caps, shareContext, isOffscreen)
         , mConfig(config)
         , mSurface(surface)
         , mCurSurface(surface)
         , mContext(context)
-        , mPlatformContext(nullptr)
         , mThebesSurface(nullptr)
         , mBound(false)
         , mIsPBuffer(false)
         , mIsDoubleBuffered(false)
         , mCanBindToTexture(false)
         , mShareWithEGLImage(false)
         , mTemporaryEGLImageTexture(0)
     {
@@ -268,28 +267,22 @@ public:
             if (mTemporaryEGLImageTexture != 0) {
                 fDeleteTextures(1, &mTemporaryEGLImageTexture);
                 mTemporaryEGLImageTexture = 0;
             }
         }
 
         MarkDestroyed();
 
-        // If mGLWidget is non-null, then we've been given it by the GL context provider,
-        // and it's managed by the widget implementation. In this case, We can't destroy
-        // our contexts.
-        if (mPlatformContext)
-            return;
-
 #ifdef DEBUG
         printf_stderr("Destroying context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
 #endif
 
         sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext);
-        if (mSurface && !mPlatformContext) {
+        if (mSurface) {
             sEGLLibrary.fDestroySurface(EGL_DISPLAY(), mSurface);
         }
     }
 
     GLContextType GetContextType() {
         return ContextTypeEGL;
     }
 
@@ -484,17 +477,17 @@ public:
         }
         return sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
                                         mSurface, mSurface,
                                         mContext);
     }
 
     virtual void
     ReleaseSurface() {
-        if (mSurface && !mPlatformContext) {
+        if (mSurface) {
             sEGLLibrary.fMakeCurrent(EGL_DISPLAY(), EGL_NO_SURFACE, EGL_NO_SURFACE,
                                      EGL_NO_CONTEXT);
             sEGLLibrary.fDestroySurface(EGL_DISPLAY(), mSurface);
             mSurface = nullptr;
         }
     }
 
     bool SetupLookupFunction()
@@ -511,17 +504,17 @@ public:
 
         default:
             return nullptr;
         }
     }
 
     bool SwapBuffers()
     {
-        if (mSurface && !mPlatformContext) {
+        if (mSurface) {
 #ifdef MOZ_WIDGET_GONK
             if (!mIsOffscreen) {
                 if (mHwc) {
                     return mHwc->Render(EGL_DISPLAY(), mSurface);
                 } else {
                     return GetGonkDisplay()->SwapBuffers(EGL_DISPLAY(), mSurface);
                 }
             } else
@@ -546,20 +539,16 @@ public:
                 TextureImage::Flags aFlags = TextureImage::NoFlags,
                 TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown) MOZ_OVERRIDE;
     // hold a reference to the given surface
     // for the lifetime of this context.
     void HoldSurface(gfxASurface *aSurf) {
         mThebesSurface = aSurf;
     }
 
-    void SetPlatformContext(void *context) {
-        mPlatformContext = context;
-    }
-
     EGLContext Context() {
         return mContext;
     }
 
     bool BindTex2DOffscreen(GLContext *aOffscreen);
     void UnbindTex2DOffscreen(GLContext *aOffscreen);
     bool ResizeOffscreen(const gfxIntSize& aNewSize);
     void BindOffscreenFramebuffer();
@@ -585,17 +574,16 @@ public:
 
 protected:
     friend class GLContextProviderEGL;
 
     EGLConfig  mConfig;
     EGLSurface mSurface;
     EGLSurface mCurSurface;
     EGLContext mContext;
-    void *mPlatformContext;
     nsRefPtr<gfxASurface> mThebesSurface;
     bool mBound;
 
     bool mIsPBuffer;
     bool mIsDoubleBuffered;
     bool mCanBindToTexture;
     bool mShareWithEGLImage;
 #ifdef MOZ_WIDGET_GONK
@@ -1150,38 +1138,16 @@ already_AddRefed<GLContext>
 GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
 {
     if (!sEGLLibrary.EnsureInitialized()) {
         return nullptr;
     }
 
     bool doubleBuffered = true;
 
-    bool hasNativeContext = aWidget->HasGLContext();
-    EGLContext eglContext = sEGLLibrary.fGetCurrentContext();
-    if (hasNativeContext && eglContext) {
-        void* platformContext = eglContext;
-        SurfaceCaps caps = SurfaceCaps::Any();
-        EGLConfig config = EGL_NO_CONFIG;
-        EGLSurface surface = sEGLLibrary.fGetCurrentSurface(LOCAL_EGL_DRAW);
-        nsRefPtr<GLContextEGL> glContext =
-            new GLContextEGL(caps,
-                             nullptr, false,
-                             config, surface, eglContext);
-
-        if (!glContext->Init())
-            return nullptr;
-
-        glContext->MakeCurrent();
-        glContext->SetIsDoubleBuffered(doubleBuffered);
-        glContext->SetPlatformContext(platformContext);
-
-        return glContext.forget();
-    }
-
     EGLConfig config;
     if (!CreateConfig(&config)) {
         printf_stderr("Failed to create EGL config!\n");
         return nullptr;
     }
 
 #ifdef MOZ_ANDROID_OMTC
     mozilla::AndroidBridge::Bridge()->RegisterCompositor();