diff options
| author | 2010-12-10 16:03:15 -0800 | |
|---|---|---|
| committer | 2010-12-10 16:03:15 -0800 | |
| commit | 4ef6650bd05a39a09958ea1db92f120ea4949cb1 (patch) | |
| tree | 19e72e8c62fe8239d453826f4610feb7491dbcba /libs/rs/rsAllocation.cpp | |
| parent | 16bb80af66012cee1625dd4e926c1fbdf87b8670 (diff) | |
Remove CreateFromBitmapRef and add
CopyTo(bitmap) replacement.
Change-Id: Ib73fb9f4bfe5f468eaf0f8f1bf68a93759eef00d
Diffstat (limited to 'libs/rs/rsAllocation.cpp')
| -rw-r--r-- | libs/rs/rsAllocation.cpp | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index f42be0e871da..10a5caf56019 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -763,32 +763,44 @@ RsAllocation rsi_AllocationCreateBitmapRef(Context *rsc, RsType vtype, return alloc; } -void rsi_AllocationUpdateFromBitmap(Context *rsc, RsAllocation va, - RsElement _src, const void *data) { +void rsi_AllocationCopyFromBitmap(Context *rsc, RsAllocation va, const void *data, size_t dataLen) { Allocation *texAlloc = static_cast<Allocation *>(va); - const Element *src = static_cast<const Element *>(_src); - const Element *dst = texAlloc->getType()->getElement(); - uint32_t w = texAlloc->getType()->getDimX(); - uint32_t h = texAlloc->getType()->getDimY(); - bool genMips = texAlloc->getType()->getDimLOD(); - - ElementConverter_t cvt = pickConverter(dst, src); - if (cvt) { - cvt(texAlloc->getPtr(), data, w * h); - if (genMips) { - Adapter2D adapt(rsc, texAlloc); - Adapter2D adapt2(rsc, texAlloc); - for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { - adapt.setLOD(lod); - adapt2.setLOD(lod + 1); - mip(adapt2, adapt); - } + const Type * t = texAlloc->getType(); + + uint32_t w = t->getDimX(); + uint32_t h = t->getDimY(); + bool genMips = t->getDimLOD(); + size_t s = w * h * t->getElementSizeBytes(); + if (s != dataLen) { + rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size"); + return; + } + + memcpy(texAlloc->getPtr(), data, s); + if (genMips) { + Adapter2D adapt(rsc, texAlloc); + Adapter2D adapt2(rsc, texAlloc); + for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { + adapt.setLOD(lod); + adapt2.setLOD(lod + 1); + mip(adapt2, adapt); } - } else { - rsc->setError(RS_ERROR_BAD_VALUE, "Unsupported bitmap format"); } } +void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) { + Allocation *texAlloc = static_cast<Allocation *>(va); + const Type * t = texAlloc->getType(); + + size_t s = t->getDimX() * t->getDimY() * t->getElementSizeBytes(); + if (s != dataLen) { + rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size"); + return; + } + + memcpy(data, texAlloc->getPtr(), s); +} + void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); a->data(rsc, data, sizeBytes); |