2
0

BsPixelBuffer.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "BsPixelBuffer.h"
  2. #include "BsException.h"
  3. namespace BansheeEngine
  4. {
  5. PixelBuffer::PixelBuffer(UINT32 width, UINT32 height, UINT32 depth,
  6. PixelFormat format,
  7. GpuBufferUsage usage, bool useSystemMemory):
  8. HardwareBuffer(usage, useSystemMemory),
  9. mWidth(width), mHeight(height), mDepth(depth),
  10. mFormat(format)
  11. {
  12. mRowPitch = mWidth;
  13. mSlicePitch = mHeight*mWidth;
  14. mSizeInBytes = mHeight*mWidth*PixelUtil::getNumElemBytes(mFormat);
  15. }
  16. PixelBuffer::~PixelBuffer()
  17. {
  18. }
  19. void* PixelBuffer::lock(UINT32 offset, UINT32 length, GpuLockOptions options)
  20. {
  21. assert(!isLocked() && "Cannot lock this buffer, it is already locked!");
  22. assert(offset == 0 && length == mSizeInBytes && "Cannot lock memory region, most lock box or entire buffer");
  23. PixelVolume myBox(0, 0, 0, mWidth, mHeight, mDepth);
  24. const PixelData &rv = lock(myBox, options);
  25. return rv.getData();
  26. }
  27. const PixelData& PixelBuffer::lock(const PixelVolume& lockBox, GpuLockOptions options)
  28. {
  29. // Lock the real buffer if there is no shadow buffer
  30. mCurrentLock = lockImpl(lockBox, options);
  31. mIsLocked = true;
  32. return mCurrentLock;
  33. }
  34. void* PixelBuffer::lockImpl(UINT32 offset, UINT32 length, GpuLockOptions options)
  35. {
  36. BS_EXCEPT(InternalErrorException, "lockImpl(offset,length) is not valid for PixelBuffers and should never be called");
  37. }
  38. void PixelBuffer::readData(UINT32 offset, UINT32 length, void* pDest)
  39. {
  40. // TODO
  41. BS_EXCEPT(NotImplementedException, "Reading a byte range is not implemented. Use blitToMemory.");
  42. }
  43. void PixelBuffer::writeData(UINT32 offset, UINT32 length, const void* pSource, BufferWriteType writeFlags)
  44. {
  45. // TODO
  46. BS_EXCEPT(NotImplementedException, "Writing a byte range is not implemented. Use blitFromMemory.");
  47. }
  48. }