diff options
author | Jason Sams <rjsams@android.com> | 2010-08-31 19:19:05 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-08-31 19:19:05 -0700 |
commit | 3927dbb52a99382802f8df8d03fef496a8e0a1ea (patch) | |
tree | 53759393b771fd7f08ae8e5884121ba15d21bc45 /libs | |
parent | 2394c164a76f6d3f8ad9f1c1517f58f72adab9d7 (diff) | |
parent | 49bdaf0293408159df18a1d8540360f9623c40f7 (diff) | |
download | frameworks_base-3927dbb52a99382802f8df8d03fef496a8e0a1ea.zip frameworks_base-3927dbb52a99382802f8df8d03fef496a8e0a1ea.tar.gz frameworks_base-3927dbb52a99382802f8df8d03fef496a8e0a1ea.tar.bz2 |
Merge "SubElementData data upload functions."
Diffstat (limited to 'libs')
-rw-r--r-- | libs/rs/rs.spec | 19 | ||||
-rw-r--r-- | libs/rs/rsAllocation.cpp | 131 | ||||
-rw-r--r-- | libs/rs/rsAllocation.h | 13 | ||||
-rw-r--r-- | libs/rs/rsHandcode.h | 23 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 4 |
5 files changed, 167 insertions, 23 deletions
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 781dbea..ad162bb 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -184,6 +184,16 @@ Allocation1DSubData { togglePlay } +Allocation1DSubElementData { + param RsAllocation va + param uint32_t x + param const void *data + param uint32_t comp_offset + param uint32_t bytes + handcodeApi + togglePlay + } + Allocation2DSubData { param RsAllocation va param uint32_t xoff @@ -194,6 +204,15 @@ Allocation2DSubData { param uint32_t bytes } +Allocation2DSubElementData { + param RsAllocation va + param uint32_t x + param uint32_t y + param const void *data + param uint32_t element_offset + param uint32_t bytes + } + AllocationRead { param RsAllocation va param void * data diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 7e44fea..60998c3 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -230,7 +230,7 @@ void Allocation::uploadCheck(const Context *rsc) } -void Allocation::data(const void *data, uint32_t sizeBytes) +void Allocation::data(Context *rsc, const void *data, uint32_t sizeBytes) { uint32_t size = mType->getSizeBytes(); if (size != sizeBytes) { @@ -253,7 +253,7 @@ void Allocation::read(void *data) memcpy(data, mPtr, mType->getSizeBytes()); } -void Allocation::subData(uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes) +void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes) { uint32_t eSize = mType->getElementSizeBytes(); uint8_t * ptr = static_cast<uint8_t *>(mPtr); @@ -276,7 +276,7 @@ void Allocation::subData(uint32_t xoff, uint32_t count, const void *data, uint32 mUploadDefered = true; } -void Allocation::subData(uint32_t xoff, uint32_t yoff, +void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) { uint32_t eSize = mType->getElementSizeBytes(); @@ -306,11 +306,93 @@ void Allocation::subData(uint32_t xoff, uint32_t yoff, mUploadDefered = true; } -void Allocation::subData(uint32_t xoff, uint32_t yoff, uint32_t zoff, +void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes) { } +void Allocation::subElementData(Context *rsc, uint32_t x, const void *data, + uint32_t cIdx, uint32_t sizeBytes) +{ + uint32_t eSize = mType->getElementSizeBytes(); + uint8_t * ptr = static_cast<uint8_t *>(mPtr); + ptr += eSize * x; + + if (cIdx >= mType->getElement()->getFieldCount()) { + LOGE("Error Allocation::subElementData component %i out of range.", cIdx); + rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range."); + return; + } + + if (x >= mType->getDimX()) { + LOGE("Error Allocation::subElementData X offset %i out of range.", x); + rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range."); + return; + } + + const Element * e = mType->getElement()->getField(cIdx); + ptr += mType->getElement()->getFieldOffsetBytes(cIdx); + + if (sizeBytes != e->getSizeBytes()) { + LOGE("Error Allocation::subElementData data size %i does not match field size %i.", sizeBytes, e->getSizeBytes()); + rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size."); + return; + } + + if (e->getHasReferences()) { + e->incRefs(data); + e->decRefs(ptr); + } + + memcpy(ptr, data, sizeBytes); + sendDirty(); + mUploadDefered = true; +} + +void Allocation::subElementData(Context *rsc, uint32_t x, uint32_t y, + const void *data, uint32_t cIdx, uint32_t sizeBytes) +{ + uint32_t eSize = mType->getElementSizeBytes(); + uint8_t * ptr = static_cast<uint8_t *>(mPtr); + ptr += eSize * (x + y * mType->getDimX()); + + if (x >= mType->getDimX()) { + LOGE("Error Allocation::subElementData X offset %i out of range.", x); + rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range."); + return; + } + + if (y >= mType->getDimY()) { + LOGE("Error Allocation::subElementData X offset %i out of range.", x); + rsc->setError(RS_ERROR_BAD_VALUE, "subElementData X offset out of range."); + return; + } + + if (cIdx >= mType->getElement()->getFieldCount()) { + LOGE("Error Allocation::subElementData component %i out of range.", cIdx); + rsc->setError(RS_ERROR_BAD_VALUE, "subElementData component out of range."); + return; + } + + const Element * e = mType->getElement()->getField(cIdx); + ptr += mType->getElement()->getFieldOffsetBytes(cIdx); + + if (sizeBytes != e->getSizeBytes()) { + LOGE("Error Allocation::subElementData data size %i does not match field size %i.", sizeBytes, e->getSizeBytes()); + rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size."); + return; + } + + if (e->getHasReferences()) { + e->incRefs(data); + e->decRefs(ptr); + } + + memcpy(ptr, data, sizeBytes); + sendDirty(); + mUploadDefered = true; +} + void Allocation::addProgramToDirty(const Program *p) { mToDirtyList.push(p); @@ -394,7 +476,7 @@ Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) alloc->setName(name.string(), name.size()); // Read in all of our allocation data - alloc->data(stream->getPtr() + stream->getPos(), dataSize); + alloc->data(rsc, stream->getPtr() + stream->getPos(), dataSize); stream->reset(stream->getPos() + dataSize); return alloc; @@ -662,16 +744,19 @@ RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h } ElementConverter_t cvt = pickConverter(dst, src); - 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); + 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); + } } + } else { + rsc->setError(RS_ERROR_BAD_VALUE, "Unsupported bitmap format"); } return texAlloc; @@ -708,19 +793,31 @@ RsAllocation rsi_AllocationCreateFromBitmapBoxed(Context *rsc, uint32_t w, uint3 void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); - a->data(data, sizeBytes); + a->data(rsc, data, sizeBytes); } void rsi_Allocation1DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); - a->subData(xoff, count, data, sizeBytes); + a->subData(rsc, xoff, count, data, sizeBytes); +} + +void rsi_Allocation2DSubElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, const void *data, uint32_t eoff, uint32_t sizeBytes) +{ + Allocation *a = static_cast<Allocation *>(va); + a->subElementData(rsc, x, y, data, eoff, sizeBytes); +} + +void rsi_Allocation1DSubElementData(Context *rsc, RsAllocation va, uint32_t x, const void *data, uint32_t eoff, uint32_t sizeBytes) +{ + Allocation *a = static_cast<Allocation *>(va); + a->subElementData(rsc, x, data, eoff, sizeBytes); } void rsi_Allocation2DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); - a->subData(xoff, yoff, w, h, data, sizeBytes); + a->subData(rsc, xoff, yoff, w, h, data, sizeBytes); } void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data) diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h index 177d5a4..967f220 100644 --- a/libs/rs/rsAllocation.h +++ b/libs/rs/rsAllocation.h @@ -56,13 +56,18 @@ public: uint32_t getBufferObjectID() const {return mBufferID;} - void data(const void *data, uint32_t sizeBytes); - void subData(uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes); - void subData(uint32_t xoff, uint32_t yoff, + void data(Context *rsc, const void *data, uint32_t sizeBytes); + void subData(Context *rsc, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes); + void subData(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes); - void subData(uint32_t xoff, uint32_t yoff, uint32_t zoff, + void subData(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); + void subElementData(Context *rsc, uint32_t x, + const void *data, uint32_t elementOff, uint32_t sizeBytes); + void subElementData(Context *rsc, uint32_t x, uint32_t y, + const void *data, uint32_t elementOff, uint32_t sizeBytes); + void read(void *data); void enableGLVertexBuffers() const; diff --git a/libs/rs/rsHandcode.h b/libs/rs/rsHandcode.h index 353b73a..c02fd42 100644 --- a/libs/rs/rsHandcode.h +++ b/libs/rs/rsHandcode.h @@ -96,3 +96,26 @@ static inline void rsHCAPI_Allocation1DSubData (RsContext rsc, RsAllocation va, } +static inline void rsHCAPI_Allocation1DSubElementData (RsContext rsc, RsAllocation va, uint32_t x, const void * data, uint32_t comp_offset, uint32_t sizeBytes) +{ + ThreadIO *io = &((Context *)rsc)->mIO; + uint32_t size = sizeof(RS_CMD_Allocation1DSubElementData); + if (sizeBytes < DATA_SYNC_SIZE) { + size += (sizeBytes + 3) & ~3; + } + RS_CMD_Allocation1DSubElementData *cmd = static_cast<RS_CMD_Allocation1DSubElementData *>(io->mToCore.reserve(size)); + cmd->va = va; + cmd->x = x; + cmd->data = data; + cmd->comp_offset = comp_offset; + cmd->bytes = sizeBytes; + if (sizeBytes < DATA_SYNC_SIZE) { + cmd->data = (void *)(cmd+1); + memcpy(cmd+1, data, sizeBytes); + io->mToCore.commit(RS_CMD_ID_Allocation1DSubElementData, size); + } else { + io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubElementData, size); + } + +} + diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index 41d8247..e1628f4 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -331,10 +331,10 @@ void ProgramVertexState::updateSize(Context *rsc) { Matrix m; m.loadOrtho(0,rsc->getWidth(), rsc->getHeight(),0, -1,1); - mDefaultAlloc->subData(RS_PROGRAM_VERTEX_PROJECTION_OFFSET, 16, &m.m[0], 16*4); + mDefaultAlloc->subData(rsc, RS_PROGRAM_VERTEX_PROJECTION_OFFSET, 16, &m.m[0], 16*4); m.loadIdentity(); - mDefaultAlloc->subData(RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, 16, &m.m[0], 16*4); + mDefaultAlloc->subData(rsc, RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, 16, &m.m[0], 16*4); } void ProgramVertexState::deinit(Context *rsc) |