/*
Copyright (C) 2010, Heikki Salo
All rights reserved.
Distributed under the BSD license:
http://www.opensource.org/licenses/bsd-license.php
*/
#ifndef DP_BUFFER_HPP
#define DP_BUFFER_HPP
#include "stdafx.h"
#include "DPUtils.hpp"
#include "DPBase.hpp"
class DPBuffer : DPBase {
public:
~DPBuffer();
DPBuffer(python::object&, python::object&, UINT, UINT, UINT, UINT);
void release();
void map(UINT);
void unmap();
void copy(DPBuffer&);
void copyRegion(UINT, UINT, UINT, DPBuffer&);
void resize(UINT);
void reformat(python::object&);
python::object description();
python::str itemFormat();
void updateRaw(python::object&, UINT);
void update(python::object&, UINT, UINT);
void append(python::object&);
void extend(python::object&);
python::object pop();
void clear() { size = 0; }
python::object getitem_i(Py_ssize_t);
python::object getitem_s(python::slice&);
void setitem_i(Py_ssize_t, python::object&);
void setitem_s(python::slice&, python::object&);
ID3D11Buffer* getBuffer() { return buffer; }
UINT getElementSize() { return elementByteSize; }
bool isMapped() { return mapData.pData != 0; }
void* getMapData() { return mapData.pData; }
D3D11_MAP getMapType() { return mapType; }
const InputElementVector& getLayout() { return inputElements; }
UINT capacity() { return maxSize; }
UINT len() { return size; }
private:
ID3D11Buffer* buffer;
InputElementVector inputElements;
UINT elementByteSize;
UINT size;
UINT maxSize;
D3D11_MAPPED_SUBRESOURCE mapData;
D3D11_MAP mapType;
void* getMemoryPointer(UINT, bool checkIndex=true);
void checkAccessRW(bool read, bool write);
};
#ifdef DP_BUFFER_SUPPORT
extern "C" int DPBufferGetBuffer(PyObject*, Py_buffer*, int);
extern "C" void DPBufferReleaseBuffer(PyObject*, Py_buffer*);
#endif
#endif