1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/libGLESv2/renderer/BufferStorage9.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +#include "precompiled.h" 1.5 +// 1.6 +// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. 1.7 +// Use of this source code is governed by a BSD-style license that can be 1.8 +// found in the LICENSE file. 1.9 +// 1.10 + 1.11 +// BufferStorage9.cpp Defines the BufferStorage9 class. 1.12 + 1.13 +#include "libGLESv2/renderer/BufferStorage9.h" 1.14 +#include "common/debug.h" 1.15 + 1.16 +namespace rx 1.17 +{ 1.18 + 1.19 +BufferStorage9::BufferStorage9() 1.20 +{ 1.21 + mMemory = NULL; 1.22 + mAllocatedSize = 0; 1.23 + mSize = 0; 1.24 +} 1.25 + 1.26 +BufferStorage9::~BufferStorage9() 1.27 +{ 1.28 + delete[] mMemory; 1.29 +} 1.30 + 1.31 +BufferStorage9 *BufferStorage9::makeBufferStorage9(BufferStorage *bufferStorage) 1.32 +{ 1.33 + ASSERT(HAS_DYNAMIC_TYPE(BufferStorage9*, bufferStorage)); 1.34 + return static_cast<BufferStorage9*>(bufferStorage); 1.35 +} 1.36 + 1.37 +void *BufferStorage9::getData() 1.38 +{ 1.39 + return mMemory; 1.40 +} 1.41 + 1.42 +void BufferStorage9::setData(const void* data, unsigned int size, unsigned int offset) 1.43 +{ 1.44 + if (!mMemory || offset + size > mAllocatedSize) 1.45 + { 1.46 + unsigned int newAllocatedSize = offset + size; 1.47 + void *newMemory = new char[newAllocatedSize]; 1.48 + 1.49 + if (offset > 0 && mMemory && mAllocatedSize > 0) 1.50 + { 1.51 + memcpy(newMemory, mMemory, std::min(offset, mAllocatedSize)); 1.52 + } 1.53 + 1.54 + delete[] mMemory; 1.55 + mMemory = newMemory; 1.56 + mAllocatedSize = newAllocatedSize; 1.57 + } 1.58 + 1.59 + mSize = std::max(mSize, offset + size); 1.60 + if (data) 1.61 + { 1.62 + memcpy(reinterpret_cast<char*>(mMemory) + offset, data, size); 1.63 + } 1.64 +} 1.65 + 1.66 +void BufferStorage9::clear() 1.67 +{ 1.68 + mSize = 0; 1.69 +} 1.70 + 1.71 +unsigned int BufferStorage9::getSize() const 1.72 +{ 1.73 + return mSize; 1.74 +} 1.75 + 1.76 +bool BufferStorage9::supportsDirectBinding() const 1.77 +{ 1.78 + return false; 1.79 +} 1.80 + 1.81 +}