gfx/gl/TextureGarbageBin.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/TextureGarbageBin.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim: set ts=8 sts=4 et sw=4 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "TextureGarbageBin.h"
    1.11 +#include "GLContext.h"
    1.12 +
    1.13 +using namespace mozilla;
    1.14 +using namespace mozilla::gl;
    1.15 +
    1.16 +void
    1.17 +TextureGarbageBin::GLContextTeardown()
    1.18 +{
    1.19 +    EmptyGarbage();
    1.20 +
    1.21 +    MutexAutoLock lock(mMutex);
    1.22 +    mGL = nullptr;
    1.23 +}
    1.24 +
    1.25 +void
    1.26 +TextureGarbageBin::Trash(GLuint tex)
    1.27 +{
    1.28 +    MutexAutoLock lock(mMutex);
    1.29 +    if (!mGL)
    1.30 +        return;
    1.31 +
    1.32 +    mGarbageTextures.push(tex);
    1.33 +}
    1.34 +
    1.35 +void
    1.36 +TextureGarbageBin::EmptyGarbage()
    1.37 +{
    1.38 +    MutexAutoLock lock(mMutex);
    1.39 +    if (!mGL)
    1.40 +        return;
    1.41 +
    1.42 +    while (!mGarbageTextures.empty()) {
    1.43 +        GLuint tex = mGarbageTextures.top();
    1.44 +        mGarbageTextures.pop();
    1.45 +        mGL->fDeleteTextures(1, &tex);
    1.46 +    }
    1.47 +}

mercurial