Fixing the lockless fifo destory bug.
Removing unused code from element. build.
Change-Id: I4bb324a666486d6d3fa45cc1995d0e96cb99f70a
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 @@
}
}
+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 @@
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 @@
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 @@
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 @@
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 @@
uint8_t * mEnd;
uint8_t mSize;
bool mInShutdown;
+ bool mInitialized;
Signal mSignalToWorker;
Signal mSignalToControl;