Add copy1DRangeToUnchecked.
Change-Id: Iac550920b8e274819e43aca867dedc66eff47dcf
diff --git a/cpp/Allocation.cpp b/cpp/Allocation.cpp
index 396018b..7275261 100644
--- a/cpp/Allocation.cpp
+++ b/cpp/Allocation.cpp
@@ -178,6 +178,22 @@
rsAllocation1DData(mRS->getContext(), getIDSafe(), off, mSelectedLOD, count, data, dataLen);
}
+void Allocation::copy1DRangeToUnchecked(uint32_t off, size_t count, void *data, size_t dataLen) {
+ if(count < 1) {
+ ALOGE("Count must be >= 1.");
+ return;
+ }
+ if((off + count) > mCurrentCount) {
+ 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);
+}
+
void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const int32_t *d, size_t dataLen) {
validateIsInt32();
copy1DRangeFromUnchecked(off, count, d, dataLen);
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index 0b7e613..a936d47 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -218,7 +218,10 @@
void ioGetInput();
void generateMipmaps();
+
void copy1DRangeFromUnchecked(uint32_t off, size_t count, const void *data, size_t dataLen);
+ void copy1DRangeToUnchecked(uint32_t off, size_t count, void *data, size_t dataLen);
+
void copy1DRangeFrom(uint32_t off, size_t count, const int32_t* d, size_t dataLen);
void copy1DRangeFrom(uint32_t off, size_t count, const int16_t* d, size_t dataLen);
void copy1DRangeFrom(uint32_t off, size_t count, const int8_t* d, size_t dataLen);