gfx/angle/src/libGLESv2/HandleAllocator.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 #include "precompiled.h"
     2 //
     3 // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
     4 // Use of this source code is governed by a BSD-style license that can be
     5 // found in the LICENSE file.
     6 //
     8 // HandleAllocator.cpp: Implements the gl::HandleAllocator class, which is used
     9 // to allocate GL handles.
    11 #include "libGLESv2/HandleAllocator.h"
    13 #include "libGLESv2/main.h"
    15 namespace gl
    16 {
    18 HandleAllocator::HandleAllocator() : mBaseValue(1), mNextValue(1)
    19 {
    20 }
    22 HandleAllocator::~HandleAllocator()
    23 {
    24 }
    26 void HandleAllocator::setBaseHandle(GLuint value)
    27 {
    28     ASSERT(mBaseValue == mNextValue);
    29     mBaseValue = value;
    30     mNextValue = value;
    31 }
    33 GLuint HandleAllocator::allocate()
    34 {
    35     if (mFreeValues.size())
    36     {
    37         GLuint handle = mFreeValues.back();
    38         mFreeValues.pop_back();
    39         return handle;
    40     }
    41     return mNextValue++;
    42 }
    44 void HandleAllocator::release(GLuint handle)
    45 {
    46     if (handle == mNextValue - 1)
    47     {
    48         // Don't drop below base value
    49         if(mNextValue > mBaseValue)
    50         {
    51             mNextValue--;
    52         }
    53     }
    54     else
    55     {
    56         // Only free handles that we own - don't drop below the base value
    57         if (handle >= mBaseValue)
    58         {
    59             mFreeValues.push_back(handle);
    60         }
    61     }
    62 }
    64 }

mercurial