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);
diff --git a/tests/cppallocation/compute.cpp b/tests/cppallocation/compute.cpp
index 8439ffb..5407e06 100644
--- a/tests/cppallocation/compute.cpp
+++ b/tests/cppallocation/compute.cpp
@@ -40,11 +40,11 @@
buf[ct] = (uint32_t)ct;
}
- ain->copy1DRangeFrom(0, numElems, buf, numElems*sizeof(uint32_t));
+ ain->copy1DRangeFrom(0, numElems, buf);
sc->forEach_multiply(ain, aout);
- aout->copy1DRangeTo(0, numElems, buf, numElems*sizeof(uint32_t));
+ aout->copy1DRangeTo(0, numElems, buf);
for (uint32_t ct=0; ct < numElems; ct++) {
if (buf[ct] != ct * 2) {
diff --git a/tests/cppbasic/compute.cpp b/tests/cppbasic/compute.cpp
index 782410a..471b10a 100644
--- a/tests/cppbasic/compute.cpp
+++ b/tests/cppbasic/compute.cpp
@@ -39,7 +39,7 @@
for (uint32_t ct=0; ct < t->getCount(); ct++) {
buf[ct] = ct | (ct << 16);
}
- ain->copy1DRangeFrom(0, t->getCount(), buf, t->getCount()*4);
+ ain->copy1DRangeFrom(0, t->getCount(), buf);
sc->forEach_root(ain, aout);
printf("for each done\n");
diff --git a/tests/latency/latency.cpp b/tests/latency/latency.cpp
index b6a6c47..124fb20 100644
--- a/tests/latency/latency.cpp
+++ b/tests/latency/latency.cpp
@@ -64,8 +64,6 @@
sc->forEach_root(ain, aout);
}
- uint32_t temp;
-
rs->finish();
gettimeofday(&stop, NULL);