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.

michael@0 1 #include "precompiled.h"
michael@0 2 //
michael@0 3 // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
michael@0 4 // Use of this source code is governed by a BSD-style license that can be
michael@0 5 // found in the LICENSE file.
michael@0 6 //
michael@0 7
michael@0 8 // IndexRangeCache.cpp: Defines the rx::IndexRangeCache class which stores information about
michael@0 9 // ranges of indices.
michael@0 10
michael@0 11 #include "libGLESv2/renderer/IndexRangeCache.h"
michael@0 12 #include "common/debug.h"
michael@0 13 #include "libGLESv2/utilities.h"
michael@0 14 #include <tuple>
michael@0 15
michael@0 16 namespace rx
michael@0 17 {
michael@0 18
michael@0 19 void IndexRangeCache::addRange(GLenum type, intptr_t offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx,
michael@0 20 unsigned int streamOffset)
michael@0 21 {
michael@0 22 mIndexRangeCache[IndexRange(type, offset, count)] = IndexBounds(minIdx, maxIdx, streamOffset);
michael@0 23 }
michael@0 24
michael@0 25 void IndexRangeCache::invalidateRange(unsigned int offset, unsigned int size)
michael@0 26 {
michael@0 27 unsigned int invalidateStart = offset;
michael@0 28 unsigned int invalidateEnd = offset + size;
michael@0 29
michael@0 30 IndexRangeMap::iterator i = mIndexRangeCache.begin();
michael@0 31 while (i != mIndexRangeCache.end())
michael@0 32 {
michael@0 33 unsigned int rangeStart = i->second.streamOffset;
michael@0 34 unsigned int rangeEnd = i->second.streamOffset + (gl::ComputeTypeSize(i->first.type) * i->first.count);
michael@0 35
michael@0 36 if (invalidateEnd < rangeStart || invalidateStart > rangeEnd)
michael@0 37 {
michael@0 38 ++i;
michael@0 39 }
michael@0 40 else
michael@0 41 {
michael@0 42 i = mIndexRangeCache.erase(i);
michael@0 43 }
michael@0 44 }
michael@0 45 }
michael@0 46
michael@0 47 bool IndexRangeCache::findRange(GLenum type, intptr_t offset, GLsizei count, unsigned int *outMinIndex,
michael@0 48 unsigned int *outMaxIndex, unsigned int *outStreamOffset) const
michael@0 49 {
michael@0 50 IndexRangeMap::const_iterator i = mIndexRangeCache.find(IndexRange(type, offset, count));
michael@0 51 if (i != mIndexRangeCache.end())
michael@0 52 {
michael@0 53 if (outMinIndex) *outMinIndex = i->second.minIndex;
michael@0 54 if (outMaxIndex) *outMaxIndex = i->second.maxIndex;
michael@0 55 if (outStreamOffset) *outStreamOffset = i->second.streamOffset;
michael@0 56 return true;
michael@0 57 }
michael@0 58 else
michael@0 59 {
michael@0 60 if (outMinIndex) *outMinIndex = 0;
michael@0 61 if (outMaxIndex) *outMaxIndex = 0;
michael@0 62 if (outStreamOffset) *outStreamOffset = 0;
michael@0 63 return false;
michael@0 64 }
michael@0 65 }
michael@0 66
michael@0 67 void IndexRangeCache::clear()
michael@0 68 {
michael@0 69 mIndexRangeCache.clear();
michael@0 70 }
michael@0 71
michael@0 72 IndexRangeCache::IndexRange::IndexRange()
michael@0 73 : type(GL_NONE), offset(0), count(0)
michael@0 74 {
michael@0 75 }
michael@0 76
michael@0 77 IndexRangeCache::IndexRange::IndexRange(GLenum typ, intptr_t off, GLsizei c)
michael@0 78 : type(typ), offset(off), count(c)
michael@0 79 {
michael@0 80 }
michael@0 81
michael@0 82 bool IndexRangeCache::IndexRange::operator<(const IndexRange& rhs) const
michael@0 83 {
michael@0 84 return std::make_tuple(type, offset, count) < std::make_tuple(rhs.type, rhs.offset, rhs.count);
michael@0 85 }
michael@0 86
michael@0 87 IndexRangeCache::IndexBounds::IndexBounds()
michael@0 88 : minIndex(0), maxIndex(0), streamOffset(0)
michael@0 89 {
michael@0 90 }
michael@0 91
michael@0 92 IndexRangeCache::IndexBounds::IndexBounds(unsigned int minIdx, unsigned int maxIdx, unsigned int offset)
michael@0 93 : minIndex(minIdx), maxIndex(maxIdx), streamOffset(offset)
michael@0 94 {
michael@0 95 }
michael@0 96
michael@0 97 }

mercurial