michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim: set ts=8 sts=4 et sw=4 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "TextureGarbageBin.h" michael@0: #include "GLContext.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::gl; michael@0: michael@0: void michael@0: TextureGarbageBin::GLContextTeardown() michael@0: { michael@0: EmptyGarbage(); michael@0: michael@0: MutexAutoLock lock(mMutex); michael@0: mGL = nullptr; michael@0: } michael@0: michael@0: void michael@0: TextureGarbageBin::Trash(GLuint tex) michael@0: { michael@0: MutexAutoLock lock(mMutex); michael@0: if (!mGL) michael@0: return; michael@0: michael@0: mGarbageTextures.push(tex); michael@0: } michael@0: michael@0: void michael@0: TextureGarbageBin::EmptyGarbage() michael@0: { michael@0: MutexAutoLock lock(mMutex); michael@0: if (!mGL) michael@0: return; michael@0: michael@0: while (!mGarbageTextures.empty()) { michael@0: GLuint tex = mGarbageTextures.top(); michael@0: mGarbageTextures.pop(); michael@0: mGL->fDeleteTextures(1, &tex); michael@0: } michael@0: }