Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | // BufferStorage9.cpp Defines the BufferStorage9 class. |
michael@0 | 9 | |
michael@0 | 10 | #include "libGLESv2/renderer/BufferStorage9.h" |
michael@0 | 11 | #include "common/debug.h" |
michael@0 | 12 | |
michael@0 | 13 | namespace rx |
michael@0 | 14 | { |
michael@0 | 15 | |
michael@0 | 16 | BufferStorage9::BufferStorage9() |
michael@0 | 17 | { |
michael@0 | 18 | mMemory = NULL; |
michael@0 | 19 | mAllocatedSize = 0; |
michael@0 | 20 | mSize = 0; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | BufferStorage9::~BufferStorage9() |
michael@0 | 24 | { |
michael@0 | 25 | delete[] mMemory; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | BufferStorage9 *BufferStorage9::makeBufferStorage9(BufferStorage *bufferStorage) |
michael@0 | 29 | { |
michael@0 | 30 | ASSERT(HAS_DYNAMIC_TYPE(BufferStorage9*, bufferStorage)); |
michael@0 | 31 | return static_cast<BufferStorage9*>(bufferStorage); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | void *BufferStorage9::getData() |
michael@0 | 35 | { |
michael@0 | 36 | return mMemory; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | void BufferStorage9::setData(const void* data, unsigned int size, unsigned int offset) |
michael@0 | 40 | { |
michael@0 | 41 | if (!mMemory || offset + size > mAllocatedSize) |
michael@0 | 42 | { |
michael@0 | 43 | unsigned int newAllocatedSize = offset + size; |
michael@0 | 44 | void *newMemory = new char[newAllocatedSize]; |
michael@0 | 45 | |
michael@0 | 46 | if (offset > 0 && mMemory && mAllocatedSize > 0) |
michael@0 | 47 | { |
michael@0 | 48 | memcpy(newMemory, mMemory, std::min(offset, mAllocatedSize)); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | delete[] mMemory; |
michael@0 | 52 | mMemory = newMemory; |
michael@0 | 53 | mAllocatedSize = newAllocatedSize; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | mSize = std::max(mSize, offset + size); |
michael@0 | 57 | if (data) |
michael@0 | 58 | { |
michael@0 | 59 | memcpy(reinterpret_cast<char*>(mMemory) + offset, data, size); |
michael@0 | 60 | } |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | void BufferStorage9::clear() |
michael@0 | 64 | { |
michael@0 | 65 | mSize = 0; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | unsigned int BufferStorage9::getSize() const |
michael@0 | 69 | { |
michael@0 | 70 | return mSize; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | bool BufferStorage9::supportsDirectBinding() const |
michael@0 | 74 | { |
michael@0 | 75 | return false; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | } |