diff options
author | Alex Sakhartchouk <alexst@google.com> | 2011-08-19 09:43:18 -0700 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2011-08-19 09:43:18 -0700 |
commit | a8bb921c8b50dd4b9c000b9bb6a438a7faf9539a (patch) | |
tree | 82e0aa25a5bb09e568d5dbcc0be4ae359d62ffd9 | |
parent | 0197d825f15844e51b91a0006d411ecb06350641 (diff) | |
download | frameworks_base-a8bb921c8b50dd4b9c000b9bb6a438a7faf9539a.zip frameworks_base-a8bb921c8b50dd4b9c000b9bb6a438a7faf9539a.tar.gz frameworks_base-a8bb921c8b50dd4b9c000b9bb6a438a7faf9539a.tar.bz2 |
Fixing the lockless fifo destory bug.
Removing unused code from element. build.
Change-Id: I4bb324a666486d6d3fa45cc1995d0e96cb99f70a
-rw-r--r-- | libs/rs/rsElement.cpp | 38 | ||||
-rw-r--r-- | libs/rs/rsElement.h | 10 | ||||
-rw-r--r-- | libs/rs/rsLocklessFifo.cpp | 5 | ||||
-rw-r--r-- | libs/rs/rsLocklessFifo.h | 1 |
4 files changed, 14 insertions, 40 deletions
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<const Element>(e)); mBuilderElements.push(e); @@ -303,41 +312,12 @@ ObjectBaseRef<const Element> 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<const Element> 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<Element *> mElements; -private: - Vector<const Element *> mBuilderElements; - Vector<const char*> mBuilderNameStrings; - Vector<size_t> mBuilderNameLengths; - Vector<uint32_t> 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; |