diff options
| author | Tim Murray <timmurray@google.com> | 2012-11-15 14:56:54 -0800 |
|---|---|---|
| committer | Tim Murray <timmurray@google.com> | 2012-11-26 12:19:48 -0800 |
| commit | 0b93e30c8c64fb2f985218adfaceff777f62a42f (patch) | |
| tree | 7e2009d7a5e4ec5b3aeb08e07500ad9da39f4ff1 /cpp/Allocation.cpp | |
| parent | 5f3c0c28bd86a676a0fb7d2f32e82bf42e279f3b (diff) | |
Remove size parameter from copy* methods in C++ and add copy*(void* data).
Change-Id: I4905a4774748c9f0d0406f70ce3895ebd68e92ce
Diffstat (limited to 'cpp/Allocation.cpp')
| -rw-r--r-- | cpp/Allocation.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/cpp/Allocation.cpp b/cpp/Allocation.cpp index 121d88d1..15df82af 100644 --- a/cpp/Allocation.cpp +++ b/cpp/Allocation.cpp @@ -160,8 +160,7 @@ void Allocation::generateMipmaps() { rsAllocationGenerateMipmaps(mRS->getContext(), getID()); } -void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const void *data, - size_t dataLen) { +void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const void *data) { if(count < 1) { ALOGE("Count must be >= 1."); @@ -171,15 +170,12 @@ void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const void *data, ALOGE("Overflow, Available count %zu, got %zu at offset %zu.", mCurrentCount, count, off); return; } - if((count * mType->getElement()->getSizeBytes()) > dataLen) { - ALOGE("Array too small for allocation type."); - return; - } - rsAllocation1DData(mRS->getContext(), getIDSafe(), off, mSelectedLOD, count, data, dataLen); + rsAllocation1DData(mRS->getContext(), getIDSafe(), off, mSelectedLOD, count, data, + count * mType->getElement()->getSizeBytes()); } -void Allocation::copy1DRangeTo(uint32_t off, size_t count, void *data, size_t dataLen) { +void Allocation::copy1DRangeTo(uint32_t off, size_t count, void *data) { if(count < 1) { ALOGE("Count must be >= 1."); return; @@ -188,11 +184,9 @@ void Allocation::copy1DRangeTo(uint32_t off, size_t count, void *data, size_t da ALOGE("Overflow, Available count %zu, got %zu at offset %zu.", mCurrentCount, count, off); return; } - if((count * mType->getElement()->getSizeBytes()) > dataLen) { - ALOGE("Array too small for allocation type."); - return; - } - rsAllocation1DRead(mRS->getContext(), getIDSafe(), off, mSelectedLOD, count, data, dataLen); + + rsAllocation1DRead(mRS->getContext(), getIDSafe(), off, mSelectedLOD, count, data, + count * mType->getElement()->getSizeBytes()); } void Allocation::copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data, @@ -204,6 +198,15 @@ void Allocation::copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation data->mSelectedLOD, data->mSelectedFace); } +void Allocation::copy1DFrom(const void* data) { + copy1DRangeFrom(0, mCurrentCount, data); +} + +void Allocation::copy1DTo(void* data) { + copy1DRangeTo(0, mCurrentCount, data); +} + + void Allocation::validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h) { if (mAdaptedAllocation != NULL) { @@ -215,15 +218,14 @@ void Allocation::validate2DRange(uint32_t xoff, uint32_t yoff, uint32_t w, uint3 } void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, - const void *data, size_t dataLen) { + const void *data) { validate2DRange(xoff, yoff, w, h); rsAllocation2DData(mRS->getContext(), getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace, - w, h, data, dataLen); + w, h, data, w * h * mType->getElement()->getSizeBytes()); } void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, - sp<const Allocation> data, size_t dataLen, - uint32_t dataXoff, uint32_t dataYoff) { + sp<const Allocation> data, uint32_t dataXoff, uint32_t dataYoff) { validate2DRange(xoff, yoff, w, h); rsAllocationCopy2DRange(mRS->getContext(), getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace, |
