Move to void* pointers for copying within C++ API.
Change-Id: If2eb0d649249a45a79810e8fddab96dc44b9fa68
diff --git a/cpp/Allocation.cpp b/cpp/Allocation.cpp
index 3551baa..5dd6af6 100644
--- a/cpp/Allocation.cpp
+++ b/cpp/Allocation.cpp
@@ -160,7 +160,7 @@
rsAllocationGenerateMipmaps(mRS->getContext(), getID());
}
-void Allocation::copy1DRangeFromUnchecked(uint32_t off, size_t count, const void *data,
+void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const void *data,
size_t dataLen) {
if(count < 1) {
@@ -179,7 +179,7 @@
rsAllocation1DData(mRS->getContext(), getIDSafe(), off, mSelectedLOD, count, data, dataLen);
}
-void Allocation::copy1DRangeToUnchecked(uint32_t off, size_t count, void *data, size_t dataLen) {
+void Allocation::copy1DRangeTo(uint32_t off, size_t count, void *data, size_t dataLen) {
if(count < 1) {
ALOGE("Count must be >= 1.");
return;
@@ -195,28 +195,8 @@
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);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const int16_t *d, size_t dataLen) {
- validateIsInt16();
- copy1DRangeFromUnchecked(off, count, d, dataLen);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const int8_t *d, size_t dataLen) {
- validateIsInt8();
- copy1DRangeFromUnchecked(off, count, d, dataLen);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const float *d, size_t dataLen) {
- validateIsFloat32();
- copy1DRangeFromUnchecked(off, count, d, dataLen);
-}
-
-void Allocation::copy1DRangeFrom(uint32_t off, size_t count, const Allocation *data,
- uint32_t dataOff) {
+void Allocation::copy1DRangeFrom(uint32_t off, size_t count, sp<const Allocation> data,
+ uint32_t dataOff) {
rsAllocationCopy2DRange(mRS->getContext(), getIDSafe(), off, 0,
mSelectedLOD, mSelectedFace,
@@ -235,35 +215,14 @@
}
void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int8_t *data, size_t dataLen) {
+ const void *data, size_t dataLen) {
validate2DRange(xoff, yoff, w, h);
rsAllocation2DData(mRS->getContext(), getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace,
w, h, data, dataLen);
}
void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int16_t *data, size_t dataLen) {
- validate2DRange(xoff, yoff, w, h);
- rsAllocation2DData(mRS->getContext(), getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace,
- w, h, data, dataLen);
-}
-
-void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int32_t *data, size_t dataLen) {
- validate2DRange(xoff, yoff, w, h);
- rsAllocation2DData(mRS->getContext(), getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace,
- w, h, data, dataLen);
-}
-
-void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const float *data, size_t dataLen) {
- validate2DRange(xoff, yoff, w, h);
- rsAllocation2DData(mRS->getContext(), getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace,
- w, h, data, dataLen);
-}
-
-void Allocation::copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const Allocation *data, size_t dataLen,
+ sp<const Allocation> data, size_t dataLen,
uint32_t dataXoff, uint32_t dataYoff) {
validate2DRange(xoff, yoff, w, h);
rsAllocationCopy2DRange(mRS->getContext(), getIDSafe(), xoff, yoff,
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index 888837f..ee3ebb1 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -221,25 +221,17 @@
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 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 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);
- void copy1DRangeFrom(uint32_t off, size_t count, const float* d, size_t dataLen);
- void copy1DRangeFrom(uint32_t off, size_t count, const Allocation *data, uint32_t dataOff);
+ 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 int32_t *data, size_t dataLen);
+ const void *data, size_t dataLen);
+ //TODO: add copy2DRangeTo
+
void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int16_t *data, size_t dataLen);
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const int8_t *data, size_t dataLen);
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const float *data, size_t dataLen);
- void copy2DRangeFrom(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h,
- const Allocation *data, size_t dataLen,
+ sp<const Allocation> data, size_t dataLen,
uint32_t dataXoff, uint32_t dataYoff);
void resize(int dimX);
diff --git a/tests/cppallocation/compute.cpp b/tests/cppallocation/compute.cpp
index e770ab2..214ffe9 100644
--- a/tests/cppallocation/compute.cpp
+++ b/tests/cppallocation/compute.cpp
@@ -40,11 +40,11 @@
buf[ct] = (uint32_t)ct;
}
- ain->copy1DRangeFromUnchecked(0, numElems, buf, numElems*sizeof(uint32_t));
+ ain->copy1DRangeFrom(0, numElems, buf, numElems*sizeof(uint32_t));
sc->forEach_multiply(ain, aout);
- aout->copy1DRangeToUnchecked(0, numElems, buf, numElems*sizeof(uint32_t));
+ aout->copy1DRangeTo(0, numElems, buf, numElems*sizeof(uint32_t));
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 fef116f..e015165 100644
--- a/tests/cppbasic/compute.cpp
+++ b/tests/cppbasic/compute.cpp
@@ -39,8 +39,7 @@
for (uint32_t ct=0; ct < t->getCount(); ct++) {
buf[ct] = ct | (ct << 16);
}
- //ain->copy1DRangeFrom(0, 128*128, (int32_t *)buf, 128*128*4);
- ain->copy1DRangeFromUnchecked(0, t->getCount(), buf, t->getCount()*4);
+ ain->copy1DRangeFrom(0, t->getCount(), buf, t->getCount()*4);
sc->forEach_root(ain, aout);
printf("for each done\n");
diff --git a/tests/latency/latency.cpp b/tests/latency/latency.cpp
index e6aaac9..b6e45e1 100644
--- a/tests/latency/latency.cpp
+++ b/tests/latency/latency.cpp
@@ -66,7 +66,7 @@
uint32_t temp;
- aout->copy1DRangeFromUnchecked(0, 1, &temp, sizeof(temp));
+ rs->finish();
gettimeofday(&stop, NULL);