Merge "Fixing the lockless fifo destory bug. Removing unused code from element. build."
This commit is contained in:
committed by
Android (Google) Code Review
commit
0806d51832
@@ -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) {
|
void Element::Builder::add(const Element *e, const char *nameStr, uint32_t arraySize) {
|
||||||
mBuilderElementRefs.push(ObjectBaseRef<const Element>(e));
|
mBuilderElementRefs.push(ObjectBaseRef<const Element>(e));
|
||||||
mBuilderElements.push(e);
|
mBuilderElements.push(e);
|
||||||
@@ -303,41 +312,12 @@ ObjectBaseRef<const Element> Element::Builder::create(Context *rsc) {
|
|||||||
|
|
||||||
|
|
||||||
ElementState::ElementState() {
|
ElementState::ElementState() {
|
||||||
const uint32_t initialCapacity = 32;
|
|
||||||
mBuilderElements.setCapacity(initialCapacity);
|
|
||||||
mBuilderNameStrings.setCapacity(initialCapacity);
|
|
||||||
mBuilderNameLengths.setCapacity(initialCapacity);
|
|
||||||
mBuilderArrays.setCapacity(initialCapacity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementState::~ElementState() {
|
ElementState::~ElementState() {
|
||||||
rsAssert(!mElements.size());
|
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class Element : public ObjectBase {
|
|||||||
public:
|
public:
|
||||||
class Builder {
|
class Builder {
|
||||||
public:
|
public:
|
||||||
|
Builder();
|
||||||
void add(const Element *e, const char *nameStr, uint32_t arraySize);
|
void add(const Element *e, const char *nameStr, uint32_t arraySize);
|
||||||
ObjectBaseRef<const Element> create(Context *rsc);
|
ObjectBaseRef<const Element> create(Context *rsc);
|
||||||
private:
|
private:
|
||||||
@@ -135,17 +136,8 @@ public:
|
|||||||
ElementState();
|
ElementState();
|
||||||
~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.
|
// Cache of all existing elements.
|
||||||
Vector<Element *> mElements;
|
Vector<Element *> mElements;
|
||||||
private:
|
|
||||||
Vector<const Element *> mBuilderElements;
|
|
||||||
Vector<const char*> mBuilderNameStrings;
|
|
||||||
Vector<size_t> mBuilderNameLengths;
|
|
||||||
Vector<uint32_t> mBuilderArrays;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@
|
|||||||
using namespace android;
|
using namespace android;
|
||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
LocklessCommandFifo::LocklessCommandFifo() : mBuffer(0) {
|
LocklessCommandFifo::LocklessCommandFifo() : mBuffer(0), mInitialized(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LocklessCommandFifo::~LocklessCommandFifo() {
|
LocklessCommandFifo::~LocklessCommandFifo() {
|
||||||
if (!mInShutdown) {
|
if (!mInShutdown && mInitialized) {
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
if (mBuffer) {
|
if (mBuffer) {
|
||||||
@@ -58,6 +58,7 @@ bool LocklessCommandFifo::init(uint32_t sizeInBytes) {
|
|||||||
mGet = mBuffer;
|
mGet = mBuffer;
|
||||||
mEnd = mBuffer + (sizeInBytes) - 1;
|
mEnd = mBuffer + (sizeInBytes) - 1;
|
||||||
//dumpState("init");
|
//dumpState("init");
|
||||||
|
mInitialized = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ protected:
|
|||||||
uint8_t * mEnd;
|
uint8_t * mEnd;
|
||||||
uint8_t mSize;
|
uint8_t mSize;
|
||||||
bool mInShutdown;
|
bool mInShutdown;
|
||||||
|
bool mInitialized;
|
||||||
|
|
||||||
Signal mSignalToWorker;
|
Signal mSignalToWorker;
|
||||||
Signal mSignalToControl;
|
Signal mSignalToControl;
|
||||||
|
|||||||
Reference in New Issue
Block a user