From 117abdbc67123654d0754b686c5bbdee6b44bcdd Mon Sep 17 00:00:00 2001 From: Alex Sakhartchouk Date: Tue, 16 Aug 2011 13:09:46 -0700 Subject: Fixing asynchronous performance issues. Change-Id: I10f02cd37a33a6c655814d24e0a4291dc044fba3 --- libs/rs/rsElement.h | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) (limited to 'libs/rs/rsElement.h') diff --git a/libs/rs/rsElement.h b/libs/rs/rsElement.h index 26e2760..c3ef250 100644 --- a/libs/rs/rsElement.h +++ b/libs/rs/rsElement.h @@ -28,8 +28,17 @@ namespace renderscript { // An element is a group of Components that occupies one cell in a structure. class Element : public ObjectBase { public: - ~Element(); - + class Builder { + public: + void add(const Element *e, const char *nameStr, uint32_t arraySize); + ObjectBaseRef create(Context *rsc); + private: + Vector > mBuilderElementRefs; + Vector mBuilderElements; + Vector mBuilderNameStrings; + Vector mBuilderNameLengths; + Vector mBuilderArrays; + }; uint32_t getGLType() const; uint32_t getGLFormat() const; @@ -55,24 +64,45 @@ public: RsDataKind getKind() const {return mComponent.getKind();} uint32_t getBits() const {return mBits;} - String8 getGLSLType(uint32_t indent=0) const; - void dumpLOGV(const char *prefix) const; virtual void serialize(OStream *stream) const; virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_ELEMENT; } static Element *createFromStream(Context *rsc, IStream *stream); - static const Element * create(Context *rsc, RsDataType dt, RsDataKind dk, - bool isNorm, uint32_t vecSize); - static const Element * create(Context *rsc, size_t count, const Element **, - const char **, const size_t * lengths, const uint32_t *asin); + static ObjectBaseRef createRef(Context *rsc, + RsDataType dt, + RsDataKind dk, + bool isNorm, + uint32_t vecSize); + static ObjectBaseRef createRef(Context *rsc, size_t count, + const Element **, + const char **, + const size_t * lengths, + const uint32_t *asin); + + static const Element* create(Context *rsc, + RsDataType dt, + RsDataKind dk, + bool isNorm, + uint32_t vecSize) { + ObjectBaseRef elem = createRef(rsc, dt, dk, isNorm, vecSize); + elem->incUserRef(); + return elem.get(); + } + static const Element* create(Context *rsc, size_t count, + const Element **ein, + const char **nin, + const size_t * lengths, + const uint32_t *asin) { + ObjectBaseRef elem = createRef(rsc, count, ein, nin, lengths, asin); + elem->incUserRef(); + return elem.get(); + } void incRefs(const void *) const; void decRefs(const void *) const; bool getHasReferences() const {return mHasReference;} - bool isEqual(const Element *other) const; - protected: // deallocate any components that are part of this element. void clear(); @@ -88,12 +118,15 @@ protected: bool mHasReference; + virtual ~Element(); Element(Context *); Component mComponent; uint32_t mBits; void compute(); + + virtual void preDestroy() const; }; -- cgit v1.1