From a8bb921c8b50dd4b9c000b9bb6a438a7faf9539a Mon Sep 17 00:00:00 2001 From: Alex Sakhartchouk Date: Fri, 19 Aug 2011 09:43:18 -0700 Subject: Fixing the lockless fifo destory bug. Removing unused code from element. build. Change-Id: I4bb324a666486d6d3fa45cc1995d0e96cb99f70a --- libs/rs/rsElement.cpp | 38 +++++++++----------------------------- libs/rs/rsElement.h | 10 +--------- libs/rs/rsLocklessFifo.cpp | 5 +++-- libs/rs/rsLocklessFifo.h | 1 + 4 files changed, 14 insertions(+), 40 deletions(-) (limited to 'libs') diff --git a/libs/rs/rsElement.cpp b/libs/rs/rsElement.cpp index 36bbdf0..d6ab0da 100644 --- a/libs/rs/rsElement.cpp +++ b/libs/rs/rsElement.cpp @@ -284,6 +284,15 @@ void Element::decRefs(const void *ptr) const { } } +Element::Builder::Builder() { + const uint32_t initialCapacity = 32; + mBuilderElementRefs.setCapacity(initialCapacity); + mBuilderElements.setCapacity(initialCapacity); + mBuilderNameStrings.setCapacity(initialCapacity); + mBuilderNameLengths.setCapacity(initialCapacity); + mBuilderArrays.setCapacity(initialCapacity); +} + void Element::Builder::add(const Element *e, const char *nameStr, uint32_t arraySize) { mBuilderElementRefs.push(ObjectBaseRef(e)); mBuilderElements.push(e); @@ -303,41 +312,12 @@ ObjectBaseRef Element::Builder::create(Context *rsc) { ElementState::ElementState() { - const uint32_t initialCapacity = 32; - mBuilderElements.setCapacity(initialCapacity); - mBuilderNameStrings.setCapacity(initialCapacity); - mBuilderNameLengths.setCapacity(initialCapacity); - mBuilderArrays.setCapacity(initialCapacity); } ElementState::~ElementState() { rsAssert(!mElements.size()); } -void ElementState::elementBuilderBegin() { - mBuilderElements.clear(); - mBuilderNameStrings.clear(); - mBuilderNameLengths.clear(); - mBuilderArrays.clear(); -} - -void ElementState::elementBuilderAdd(const Element *e, const char *nameStr, uint32_t arraySize) { - mBuilderElements.push(e); - mBuilderNameStrings.push(nameStr); - mBuilderNameLengths.push(strlen(nameStr)); - mBuilderArrays.push(arraySize); - -} - -const Element *ElementState::elementBuilderCreate(Context *rsc) { - return Element::create(rsc, mBuilderElements.size(), - &(mBuilderElements.editArray()[0]), - &(mBuilderNameStrings.editArray()[0]), - mBuilderNameLengths.editArray(), - mBuilderArrays.editArray()); -} - - ///////////////////////////////////////// // diff --git a/libs/rs/rsElement.h b/libs/rs/rsElement.h index c3ef250..bfdec53 100644 --- a/libs/rs/rsElement.h +++ b/libs/rs/rsElement.h @@ -30,6 +30,7 @@ class Element : public ObjectBase { public: class Builder { public: + Builder(); void add(const Element *e, const char *nameStr, uint32_t arraySize); ObjectBaseRef create(Context *rsc); private: @@ -135,17 +136,8 @@ public: ElementState(); ~ElementState(); - void elementBuilderBegin(); - void elementBuilderAdd(const Element *e, const char *nameStr, uint32_t arraySize); - const Element *elementBuilderCreate(Context *rsc); - // Cache of all existing elements. Vector mElements; -private: - Vector mBuilderElements; - Vector mBuilderNameStrings; - Vector mBuilderNameLengths; - Vector mBuilderArrays; }; diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp index 02a76ab..4d02269 100644 --- a/libs/rs/rsLocklessFifo.cpp +++ b/libs/rs/rsLocklessFifo.cpp @@ -21,11 +21,11 @@ using namespace android; using namespace android::renderscript; -LocklessCommandFifo::LocklessCommandFifo() : mBuffer(0) { +LocklessCommandFifo::LocklessCommandFifo() : mBuffer(0), mInitialized(false) { } LocklessCommandFifo::~LocklessCommandFifo() { - if (!mInShutdown) { + if (!mInShutdown && mInitialized) { shutdown(); } if (mBuffer) { @@ -58,6 +58,7 @@ bool LocklessCommandFifo::init(uint32_t sizeInBytes) { mGet = mBuffer; mEnd = mBuffer + (sizeInBytes) - 1; //dumpState("init"); + mInitialized = true; return true; } diff --git a/libs/rs/rsLocklessFifo.h b/libs/rs/rsLocklessFifo.h index 4962ef6..fa53d40 100644 --- a/libs/rs/rsLocklessFifo.h +++ b/libs/rs/rsLocklessFifo.h @@ -47,6 +47,7 @@ protected: uint8_t * mEnd; uint8_t mSize; bool mInShutdown; + bool mInitialized; Signal mSignalToWorker; Signal mSignalToControl; -- cgit v1.1