Sat, 03 Jan 2015 20:18:00 +0100
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) 2002-2012 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 | // IndexBuffer.cpp: Defines the abstract IndexBuffer class and IndexBufferInterface |
michael@0 | 9 | // class with derivations, classes that perform graphics API agnostic index buffer operations. |
michael@0 | 10 | |
michael@0 | 11 | #include "libGLESv2/renderer/IndexBuffer.h" |
michael@0 | 12 | #include "libGLESv2/renderer/Renderer.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace rx |
michael@0 | 15 | { |
michael@0 | 16 | |
michael@0 | 17 | unsigned int IndexBuffer::mNextSerial = 1; |
michael@0 | 18 | |
michael@0 | 19 | IndexBuffer::IndexBuffer() |
michael@0 | 20 | { |
michael@0 | 21 | updateSerial(); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | IndexBuffer::~IndexBuffer() |
michael@0 | 25 | { |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | unsigned int IndexBuffer::getSerial() const |
michael@0 | 29 | { |
michael@0 | 30 | return mSerial; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | void IndexBuffer::updateSerial() |
michael@0 | 34 | { |
michael@0 | 35 | mSerial = mNextSerial++; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | |
michael@0 | 39 | IndexBufferInterface::IndexBufferInterface(Renderer *renderer, bool dynamic) : mRenderer(renderer) |
michael@0 | 40 | { |
michael@0 | 41 | mIndexBuffer = renderer->createIndexBuffer(); |
michael@0 | 42 | |
michael@0 | 43 | mDynamic = dynamic; |
michael@0 | 44 | mWritePosition = 0; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | IndexBufferInterface::~IndexBufferInterface() |
michael@0 | 48 | { |
michael@0 | 49 | if (mIndexBuffer) |
michael@0 | 50 | { |
michael@0 | 51 | delete mIndexBuffer; |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | GLenum IndexBufferInterface::getIndexType() const |
michael@0 | 56 | { |
michael@0 | 57 | return mIndexBuffer->getIndexType(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | unsigned int IndexBufferInterface::getBufferSize() const |
michael@0 | 61 | { |
michael@0 | 62 | return mIndexBuffer->getBufferSize(); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | unsigned int IndexBufferInterface::getSerial() const |
michael@0 | 66 | { |
michael@0 | 67 | return mIndexBuffer->getSerial(); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | bool IndexBufferInterface::mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset) |
michael@0 | 71 | { |
michael@0 | 72 | // Protect against integer overflow |
michael@0 | 73 | if (mWritePosition + size < mWritePosition) |
michael@0 | 74 | { |
michael@0 | 75 | return false; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | if (!mIndexBuffer->mapBuffer(mWritePosition, size, outMappedMemory)) |
michael@0 | 79 | { |
michael@0 | 80 | if (outMappedMemory) |
michael@0 | 81 | { |
michael@0 | 82 | *outMappedMemory = NULL; |
michael@0 | 83 | } |
michael@0 | 84 | return false; |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | if (streamOffset) |
michael@0 | 88 | { |
michael@0 | 89 | *streamOffset = mWritePosition; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | mWritePosition += size; |
michael@0 | 93 | return true; |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | bool IndexBufferInterface::unmapBuffer() |
michael@0 | 97 | { |
michael@0 | 98 | return mIndexBuffer->unmapBuffer(); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | IndexBuffer * IndexBufferInterface::getIndexBuffer() const |
michael@0 | 102 | { |
michael@0 | 103 | return mIndexBuffer; |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | unsigned int IndexBufferInterface::getWritePosition() const |
michael@0 | 107 | { |
michael@0 | 108 | return mWritePosition; |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | void IndexBufferInterface::setWritePosition(unsigned int writePosition) |
michael@0 | 112 | { |
michael@0 | 113 | mWritePosition = writePosition; |
michael@0 | 114 | } |
michael@0 | 115 | |
michael@0 | 116 | bool IndexBufferInterface::discard() |
michael@0 | 117 | { |
michael@0 | 118 | return mIndexBuffer->discard(); |
michael@0 | 119 | } |
michael@0 | 120 | |
michael@0 | 121 | bool IndexBufferInterface::setBufferSize(unsigned int bufferSize, GLenum indexType) |
michael@0 | 122 | { |
michael@0 | 123 | if (mIndexBuffer->getBufferSize() == 0) |
michael@0 | 124 | { |
michael@0 | 125 | return mIndexBuffer->initialize(bufferSize, indexType, mDynamic); |
michael@0 | 126 | } |
michael@0 | 127 | else |
michael@0 | 128 | { |
michael@0 | 129 | return mIndexBuffer->setSize(bufferSize, indexType); |
michael@0 | 130 | } |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | StreamingIndexBufferInterface::StreamingIndexBufferInterface(Renderer *renderer) : IndexBufferInterface(renderer, true) |
michael@0 | 134 | { |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | StreamingIndexBufferInterface::~StreamingIndexBufferInterface() |
michael@0 | 138 | { |
michael@0 | 139 | } |
michael@0 | 140 | |
michael@0 | 141 | bool StreamingIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType) |
michael@0 | 142 | { |
michael@0 | 143 | bool result = true; |
michael@0 | 144 | unsigned int curBufferSize = getBufferSize(); |
michael@0 | 145 | unsigned int writePos = getWritePosition(); |
michael@0 | 146 | if (size > curBufferSize) |
michael@0 | 147 | { |
michael@0 | 148 | result = setBufferSize(std::max(size, 2 * curBufferSize), indexType); |
michael@0 | 149 | setWritePosition(0); |
michael@0 | 150 | } |
michael@0 | 151 | else if (writePos + size > curBufferSize || writePos + size < writePos) |
michael@0 | 152 | { |
michael@0 | 153 | if (!discard()) |
michael@0 | 154 | { |
michael@0 | 155 | return false; |
michael@0 | 156 | } |
michael@0 | 157 | setWritePosition(0); |
michael@0 | 158 | } |
michael@0 | 159 | |
michael@0 | 160 | return result; |
michael@0 | 161 | } |
michael@0 | 162 | |
michael@0 | 163 | |
michael@0 | 164 | StaticIndexBufferInterface::StaticIndexBufferInterface(Renderer *renderer) : IndexBufferInterface(renderer, false) |
michael@0 | 165 | { |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | StaticIndexBufferInterface::~StaticIndexBufferInterface() |
michael@0 | 169 | { |
michael@0 | 170 | } |
michael@0 | 171 | |
michael@0 | 172 | bool StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType) |
michael@0 | 173 | { |
michael@0 | 174 | unsigned int curSize = getBufferSize(); |
michael@0 | 175 | if (curSize == 0) |
michael@0 | 176 | { |
michael@0 | 177 | return setBufferSize(size, indexType); |
michael@0 | 178 | } |
michael@0 | 179 | else if (curSize >= size && indexType == getIndexType()) |
michael@0 | 180 | { |
michael@0 | 181 | return true; |
michael@0 | 182 | } |
michael@0 | 183 | else |
michael@0 | 184 | { |
michael@0 | 185 | ERR("Static index buffers can't be resized"); |
michael@0 | 186 | UNREACHABLE(); |
michael@0 | 187 | return false; |
michael@0 | 188 | } |
michael@0 | 189 | } |
michael@0 | 190 | |
michael@0 | 191 | IndexRangeCache *StaticIndexBufferInterface::getIndexRangeCache() |
michael@0 | 192 | { |
michael@0 | 193 | return &mIndexRangeCache; |
michael@0 | 194 | } |
michael@0 | 195 | |
michael@0 | 196 | } |
michael@0 | 197 |