michael@0: #include "precompiled.h" michael@0: // michael@0: // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // BufferStorage9.cpp Defines the BufferStorage9 class. michael@0: michael@0: #include "libGLESv2/renderer/BufferStorage9.h" michael@0: #include "common/debug.h" michael@0: michael@0: namespace rx michael@0: { michael@0: michael@0: BufferStorage9::BufferStorage9() michael@0: { michael@0: mMemory = NULL; michael@0: mAllocatedSize = 0; michael@0: mSize = 0; michael@0: } michael@0: michael@0: BufferStorage9::~BufferStorage9() michael@0: { michael@0: delete[] mMemory; michael@0: } michael@0: michael@0: BufferStorage9 *BufferStorage9::makeBufferStorage9(BufferStorage *bufferStorage) michael@0: { michael@0: ASSERT(HAS_DYNAMIC_TYPE(BufferStorage9*, bufferStorage)); michael@0: return static_cast(bufferStorage); michael@0: } michael@0: michael@0: void *BufferStorage9::getData() michael@0: { michael@0: return mMemory; michael@0: } michael@0: michael@0: void BufferStorage9::setData(const void* data, unsigned int size, unsigned int offset) michael@0: { michael@0: if (!mMemory || offset + size > mAllocatedSize) michael@0: { michael@0: unsigned int newAllocatedSize = offset + size; michael@0: void *newMemory = new char[newAllocatedSize]; michael@0: michael@0: if (offset > 0 && mMemory && mAllocatedSize > 0) michael@0: { michael@0: memcpy(newMemory, mMemory, std::min(offset, mAllocatedSize)); michael@0: } michael@0: michael@0: delete[] mMemory; michael@0: mMemory = newMemory; michael@0: mAllocatedSize = newAllocatedSize; michael@0: } michael@0: michael@0: mSize = std::max(mSize, offset + size); michael@0: if (data) michael@0: { michael@0: memcpy(reinterpret_cast(mMemory) + offset, data, size); michael@0: } michael@0: } michael@0: michael@0: void BufferStorage9::clear() michael@0: { michael@0: mSize = 0; michael@0: } michael@0: michael@0: unsigned int BufferStorage9::getSize() const michael@0: { michael@0: return mSize; michael@0: } michael@0: michael@0: bool BufferStorage9::supportsDirectBinding() const michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: }