Remove size parameter from copy* methods in C++ and add copy*(void* data).
Change-Id: I4905a4774748c9f0d0406f70ce3895ebd68e92ce
diff --git a/cpp/Allocation.cpp b/cpp/Allocation.cpp
index 121d88d..15df82a 100644
--- a/cpp/Allocation.cpp
+++ b/cpp/Allocation.cpp
@@ -160,8 +160,7 @@
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 @@
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 @@
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 @@
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::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,
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index 3598367..80118f6 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -221,18 +221,18 @@
void generateMipmaps();
- void copy1DRangeFrom(uint32_t off, size_t count, const void *data, size_t dataLen);
- void copy1DRangeTo(uint32_t off, size_t count, void *data, size_t dataLen);
-
+ void copy1DRangeFrom(uint32_t off, size_t count, const void *data);
void copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data, uint32_t dataOff);
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const void *data, size_t dataLen);
- //TODO: add copy2DRangeTo
+ void copy1DRangeTo(uint32_t off, size_t count, void *data);
+
+ void copy1DFrom(const void* data);
+ void copy1DTo(void* data);
void 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);
+ const void *data);
+ void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
+ sp<const Allocation> data, uint32_t dataXoff, uint32_t dataYoff);
void resize(int dimX);
void resize(int dimX, int dimY);