gfx/angle/src/libGLESv2/renderer/IndexRangeCache.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) 2013 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 // IndexRangeCache.cpp: Defines the rx::IndexRangeCache class which stores information about
     9 // ranges of indices.
    11 #include "libGLESv2/renderer/IndexRangeCache.h"
    12 #include "common/debug.h"
    13 #include "libGLESv2/utilities.h"
    14 #include <tuple>
    16 namespace rx
    17 {
    19 void IndexRangeCache::addRange(GLenum type, intptr_t offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx, 
    20                                unsigned int streamOffset)
    21 {
    22     mIndexRangeCache[IndexRange(type, offset, count)] = IndexBounds(minIdx, maxIdx, streamOffset);
    23 }
    25 void IndexRangeCache::invalidateRange(unsigned int offset, unsigned int size)
    26 {
    27     unsigned int invalidateStart = offset;
    28     unsigned int invalidateEnd = offset + size;
    30     IndexRangeMap::iterator i = mIndexRangeCache.begin();
    31     while (i != mIndexRangeCache.end())
    32     {
    33         unsigned int rangeStart = i->second.streamOffset;
    34         unsigned int rangeEnd = i->second.streamOffset + (gl::ComputeTypeSize(i->first.type) * i->first.count);
    36         if (invalidateEnd < rangeStart || invalidateStart > rangeEnd)
    37         {
    38             ++i;
    39         }
    40         else
    41         {
    42             i = mIndexRangeCache.erase(i);
    43         }
    44     }
    45 }
    47 bool IndexRangeCache::findRange(GLenum type, intptr_t offset, GLsizei count, unsigned int *outMinIndex,
    48                                 unsigned int *outMaxIndex, unsigned int *outStreamOffset) const
    49 {
    50     IndexRangeMap::const_iterator i = mIndexRangeCache.find(IndexRange(type, offset, count));
    51     if (i != mIndexRangeCache.end())
    52     {
    53         if (outMinIndex)     *outMinIndex = i->second.minIndex;
    54         if (outMaxIndex)     *outMaxIndex = i->second.maxIndex;
    55         if (outStreamOffset) *outStreamOffset = i->second.streamOffset;
    56         return true;
    57     }
    58     else
    59     {
    60         if (outMinIndex)     *outMinIndex = 0;
    61         if (outMaxIndex)     *outMaxIndex = 0;
    62         if (outStreamOffset) *outStreamOffset = 0;
    63         return false;
    64     }
    65 }
    67 void IndexRangeCache::clear()
    68 {
    69     mIndexRangeCache.clear();
    70 }
    72 IndexRangeCache::IndexRange::IndexRange()
    73     : type(GL_NONE), offset(0), count(0)
    74 {
    75 }
    77 IndexRangeCache::IndexRange::IndexRange(GLenum typ, intptr_t off, GLsizei c)
    78     : type(typ), offset(off), count(c)
    79 {
    80 }
    82 bool IndexRangeCache::IndexRange::operator<(const IndexRange& rhs) const
    83 {
    84     return std::make_tuple(type, offset, count) < std::make_tuple(rhs.type, rhs.offset, rhs.count);
    85 }
    87 IndexRangeCache::IndexBounds::IndexBounds()
    88     : minIndex(0), maxIndex(0), streamOffset(0)
    89 {
    90 }
    92 IndexRangeCache::IndexBounds::IndexBounds(unsigned int minIdx, unsigned int maxIdx, unsigned int offset)
    93     : minIndex(minIdx), maxIndex(maxIdx), streamOffset(offset)
    94 {
    95 }
    97 }

mercurial