gfx/angle/src/libGLESv2/HandleAllocator.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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