Bug 1356540 - Remove unused TextureGarbageBin. - r=daoshengmu
authorJeff Gilbert <jgilbert@mozilla.com>
Wed, 05 Apr 2017 15:51:49 -0700
changeset 353998 7492d1c0aad42af792d55fed897be329489f7219
parent 353997 c1d7ee18b7d0bd59990d666473d47b8b31f4710b
child 353999 ccfe5420876a232a834afe88597228d832afb089
push id31684
push usercbook@mozilla.com
push dateThu, 20 Apr 2017 09:13:26 +0000
treeherdermozilla-central@27311156637f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaoshengmu
bugs1356540
milestone55.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 1356540 - Remove unused TextureGarbageBin. - r=daoshengmu MozReview-Commit-ID: 3EON2kNdEBh
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/SharedSurfaceEGL.cpp
gfx/gl/SharedSurfaceEGL.h
gfx/gl/TextureGarbageBin.cpp
gfx/gl/TextureGarbageBin.h
gfx/gl/moz.build
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -28,17 +28,16 @@
 #include "GLTextureImage.h"
 #include "nsPrintfCString.h"
 #include "nsThreadUtils.h"
 #include "prenv.h"
 #include "prlink.h"
 #include "ScopedGLHelpers.h"
 #include "SharedSurfaceGL.h"
 #include "GfxTexturesReporter.h"
-#include "TextureGarbageBin.h"
 #include "gfx2DGlue.h"
 #include "gfxPrefs.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/gfx/Logging.h"
 
 #include "OGLShaderProgram.h" // for ShaderProgramType
 
 #include "mozilla/DebugOnly.h"
@@ -942,18 +941,16 @@ GLContext::InitWithPrefixImpl(const char
 
     // TODO: Remove SurfaceCaps::any.
     if (mCaps.any) {
         mCaps.any = false;
         mCaps.color = true;
         mCaps.alpha = false;
     }
 
-    mTexGarbageBin = new TextureGarbageBin(this);
-
     MOZ_ASSERT(IsCurrent());
 
     if (ShouldSpew() && IsExtensionSupported(KHR_debug)) {
         fEnable(LOCAL_GL_DEBUG_OUTPUT);
         fDisable(LOCAL_GL_DEBUG_OUTPUT_SYNCHRONOUS);
         fDebugMessageCallback(&StaticDebugCallback, (void*)this);
         fDebugMessageControl(LOCAL_GL_DONT_CARE,
                              LOCAL_GL_DONT_CARE,
@@ -2101,19 +2098,17 @@ GLContext::MarkDestroyed()
         return;
 
     // Null these before they're naturally nulled after dtor, as we want GLContext to
     // still be alive in *their* dtors.
     mScreen = nullptr;
     mBlitHelper = nullptr;
     mReadTexImageHelper = nullptr;
 
-    if (MakeCurrent()) {
-        mTexGarbageBin->GLContextTeardown();
-    } else {
+    if (!MakeCurrent()) {
         NS_WARNING("MakeCurrent() failed during MarkDestroyed! Skipping GL object teardown.");
     }
 
     mSymbols.Zero();
 }
 
 #ifdef MOZ_GL_DEBUG
 /* static */ void
@@ -2383,22 +2378,16 @@ GLContext::CleanDirtyScreen()
 {
     ScopedBindFramebuffer autoFB(0);
 
     BeforeGLReadCall();
     // no-op; we just want to make sure the Read FBO is updated if it needs to be
     AfterGLReadCall();
 }
 
-void
-GLContext::EmptyTexGarbageBin()
-{
-    TexGarbageBin()->EmptyGarbage();
-}
-
 bool
 GLContext::IsOffscreenSizeAllowed(const IntSize& aSize) const
 {
     int32_t biggerDimension = std::max(aSize.width, aSize.height);
     int32_t maxAllowed = std::min(mMaxRenderbufferSize, mMaxTextureSize);
     return biggerDimension <= maxAllowed;
 }
 
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -58,17 +58,16 @@ namespace mozilla {
     namespace gl {
         class GLBlitHelper;
         class GLBlitTextureImageHelper;
         class GLContext;
         class GLLibraryEGL;
         class GLReadTexImageHelper;
         class GLScreenBuffer;
         class SharedSurface;
-        class TextureGarbageBin;
         struct SurfaceCaps;
     } // namespace gl
 
     namespace layers {
         class ColorTextureLayerProgram;
     } // namespace layers
 
     namespace widget {
@@ -3452,27 +3451,16 @@ public:
      * Useful for resizing offscreen buffers.
      */
     void ClearSafely();
 
     bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; }
 
     bool IsDrawingToDefaultFramebuffer();
 
-protected:
-    RefPtr<TextureGarbageBin> mTexGarbageBin;
-
-public:
-    TextureGarbageBin* TexGarbageBin() {
-        MOZ_ASSERT(mTexGarbageBin);
-        return mTexGarbageBin;
-    }
-
-    void EmptyTexGarbageBin();
-
     bool IsOffscreenSizeAllowed(const gfx::IntSize& aSize) const;
 
 protected:
     bool InitWithPrefix(const char* prefix, bool trygl);
 
 private:
     bool InitWithPrefixImpl(const char* prefix, bool trygl);
     void LoadMoreSymbols(const char* prefix, bool trygl);
--- a/gfx/gl/SharedSurfaceEGL.cpp
+++ b/gfx/gl/SharedSurfaceEGL.cpp
@@ -6,17 +6,16 @@
 #include "SharedSurfaceEGL.h"
 
 #include "GLBlitHelper.h"
 #include "GLContextEGL.h"
 #include "GLLibraryEGL.h"
 #include "GLReadTexImageHelper.h"
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 #include "SharedSurface.h"
-#include "TextureGarbageBin.h"
 
 namespace mozilla {
 namespace gl {
 
 /*static*/ UniquePtr<SharedSurface_EGLImage>
 SharedSurface_EGLImage::Create(GLContext* prodGL,
                                const GLFormats& formats,
                                const gfx::IntSize& size,
--- a/gfx/gl/SharedSurfaceEGL.h
+++ b/gfx/gl/SharedSurfaceEGL.h
@@ -10,17 +10,16 @@
 #include "mozilla/Mutex.h"
 #include "SharedSurface.h"
 
 namespace mozilla {
 namespace gl {
 
 class GLContext;
 class GLLibraryEGL;
-class TextureGarbageBin;
 
 class SharedSurface_EGLImage
     : public SharedSurface
 {
 public:
     static UniquePtr<SharedSurface_EGLImage> Create(GLContext* prodGL,
                                                     const GLFormats& formats,
                                                     const gfx::IntSize& size,
deleted file mode 100644
--- a/gfx/gl/TextureGarbageBin.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=8 sts=4 et sw=4 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "TextureGarbageBin.h"
-#include "GLContext.h"
-
-using namespace mozilla;
-using namespace mozilla::gl;
-
-void
-TextureGarbageBin::GLContextTeardown()
-{
-    EmptyGarbage();
-
-    MutexAutoLock lock(mMutex);
-    mGL = nullptr;
-}
-
-void
-TextureGarbageBin::Trash(GLuint tex)
-{
-    MutexAutoLock lock(mMutex);
-    if (!mGL)
-        return;
-
-    mGarbageTextures.push(tex);
-}
-
-void
-TextureGarbageBin::EmptyGarbage()
-{
-    MutexAutoLock lock(mMutex);
-    if (!mGL)
-        return;
-
-    MOZ_RELEASE_ASSERT(mGL->IsCurrent(), "GFX: GL context not current.");
-    while (!mGarbageTextures.empty()) {
-        GLuint tex = mGarbageTextures.top();
-        mGarbageTextures.pop();
-        mGL->fDeleteTextures(1, &tex);
-    }
-}
deleted file mode 100644
--- a/gfx/gl/TextureGarbageBin.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=8 sts=4 et sw=4 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef TEXTUREGARBAGEBIN_H_
-#define TEXTUREGARBAGEBIN_H_
-
-#include <stack>
-
-#include "mozilla/Mutex.h"
-#include "nsISupportsImpl.h"
-
-#include "GLContextTypes.h"
-
-namespace mozilla {
-namespace gl {
-
-class TextureGarbageBin final {
-    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TextureGarbageBin)
-
-private:
-    // Private destructor, to discourage deletion outside of Release():
-    ~TextureGarbageBin()
-    {
-    }
-
-    GLContext* mGL;
-    Mutex mMutex;
-    std::stack<GLuint> mGarbageTextures;
-
-public:
-    explicit TextureGarbageBin(GLContext* gl)
-        : mGL(gl)
-        , mMutex("TextureGarbageBin mutex")
-    {}
-
-    void GLContextTeardown();
-    void Trash(GLuint tex);
-    void EmptyGarbage();
-};
-
-} // namespace gl
-} // namespace mozilla
-
-#endif // TEXTUREGARBAGEBIN_H_
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -46,17 +46,16 @@ EXPORTS += [
     'GLTypes.h',
     'GLUploadHelpers.h',
     'HeapCopyOfStackArray.h',
     'ScopedGLHelpers.h',
     'SharedSurface.h',
     'SharedSurfaceEGL.h',
     'SharedSurfaceGL.h',
     'SurfaceTypes.h',
-    'TextureGarbageBin.h',
 ]
 
 if CONFIG['MOZ_X11']:
     EXPORTS += [
         'GLContextGLX.h',
         'GLXLibrary.h',
     ]
 
@@ -135,17 +134,16 @@ UNIFIED_SOURCES += [
     'GLScreenBuffer.cpp',
     'GLTextureImage.cpp',
     'GLUploadHelpers.cpp',
     'ScopedGLHelpers.cpp',
     'SharedSurface.cpp',
     'SharedSurfaceEGL.cpp',
     'SharedSurfaceGL.cpp',
     'SurfaceTypes.cpp',
-    'TextureGarbageBin.cpp',
     'TextureImageEGL.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_D3DCOMPILER_VISTA_DLL']: