Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa7d2884 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Removed unnecessary change based on comments.

Now using android utils lib.
collada_to_a3d seems to work with android util libs.
Integrating old changelist
Changing assert to rsAssrt in VertexArray
making context compile.
Change-Id: I33890defa777f09253bfab630d97782359ec49d7

Added serialization code to rsLib
Integrated old changelist
Change-Id: Ie4746113f6d1817fbb3264f97fdddde25b779311

Added serialization code to rsLib

Change-Id: Ie4746113f6d1817fbb3264f97fdddde25b779311
parent dd56b39e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ LOCAL_SRC_FILES:= \
    rsShaderCache.cpp \
	rsSignal.cpp \
	rsSimpleMesh.cpp \
    rsStream.cpp \
	rsThreadIO.cpp \
	rsType.cpp \
	rsVertexArray.cpp
+23 −0
Original line number Diff line number Diff line
@@ -15,7 +15,11 @@
 * limitations under the License.
 */

#ifndef ANDROID_RS_BUILD_FOR_HOST
#include "rsContext.h"
#else
#include "rsContextHostStub.h"
#endif

using namespace android;
using namespace android::renderscript;
@@ -70,6 +74,16 @@ void Adapter1D::data(const void *data)
           mAllocation.get()->getType()->getSizeBytes());
}

void Adapter1D::serialize(OStream *stream) const
{
    
}

Adapter1D *Adapter1D::createFromStream(Context *rsc, IStream *stream)
{
    return NULL;
}

namespace android {
namespace renderscript {

@@ -185,6 +199,15 @@ void Adapter2D::data(const void *data)
           mAllocation.get()->getType()->getSizeBytes());
}

void Adapter2D::serialize(OStream *stream) const
{
    
}

Adapter2D *Adapter2D::createFromStream(Context *rsc, IStream *stream)
{
    return NULL;
}


namespace android {
+8 −0
Original line number Diff line number Diff line
@@ -50,6 +50,10 @@ public:
    void subData(uint32_t xoff, uint32_t count, const void *data);
    void data(const void *data);
    
    virtual void serialize(OStream *stream) const;
    virtual A3DClassID getClassId() const { return A3D_CLASS_ID_ADAPTER_1D; }
    static Adapter1D *createFromStream(Context *rsc, IStream *stream);

protected:
    ObjectBaseRef<Allocation> mAllocation;
    uint32_t mY;
@@ -82,6 +86,10 @@ public:
    void data(const void *data);
    void subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data);
    
    virtual void serialize(OStream *stream) const;
    virtual A3DClassID getClassId() const { return A3D_CLASS_ID_ADAPTER_2D; }
    static Adapter2D *createFromStream(Context *rsc, IStream *stream);

protected:
    ObjectBaseRef<Allocation> mAllocation;
    uint32_t mZ;
+67 −2
Original line number Diff line number Diff line
@@ -13,12 +13,18 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_RS_BUILD_FOR_HOST
#include "rsContext.h"

#include <GLES/gl.h>
#include <GLES2/gl2.h>
#include <GLES/glext.h>
#else
#include "rsContextHostStub.h"

#include <OpenGL/gl.h>
#include <OpenGl/glext.h>
#endif

using namespace android;
using namespace android::renderscript;
@@ -167,7 +173,9 @@ void Allocation::uploadToTexture(const Context *rsc)
                     0, format, type, ptr);
    }
    if (mTextureGenMipmap) {
#ifndef ANDROID_RS_BUILD_FOR_HOST
        glGenerateMipmap(GL_TEXTURE_2D);
#endif //ANDROID_RS_BUILD_FOR_HOST
    }

    rsc->checkError("Allocation::uploadToTexture");
@@ -286,7 +294,7 @@ void Allocation::subData(uint32_t xoff, uint32_t yoff, uint32_t zoff,

void Allocation::addProgramToDirty(const Program *p)
{
    mToDirtyList.add(p);
    mToDirtyList.push(p);
}

void Allocation::removeProgramToDirty(const Program *p)
@@ -318,6 +326,60 @@ void Allocation::dumpLOGV(const char *prefix) const

}

void Allocation::serialize(OStream *stream) const
{
    // Need to identify ourselves
    stream->addU32((uint32_t)getClassId());

    String8 name(getName());
    stream->addString(&name);

    // First thing we need to serialize is the type object since it will be needed
    // to initialize the class
    mType->serialize(stream);

    uint32_t dataSize = mType->getSizeBytes();
    // Write how much data we are storing
    stream->addU32(dataSize);
    // Now write the data
    stream->addByteArray(mPtr, dataSize);
}

Allocation *Allocation::createFromStream(Context *rsc, IStream *stream)
{
    // First make sure we are reading the correct object
    A3DClassID classID = (A3DClassID)stream->loadU32();
    if(classID != A3D_CLASS_ID_ALLOCATION) {
        LOGE("allocation loading skipped due to invalid class id\n");
        return NULL;
    }

    String8 name;
    stream->loadString(&name);

    Type *type = Type::createFromStream(rsc, stream);
    if(!type) {
        return NULL;
    }
    type->compute();

    // Number of bytes we wrote out for this allocation
    uint32_t dataSize = stream->loadU32();
    if(dataSize != type->getSizeBytes()) {
        LOGE("failed to read allocation because numbytes written is not the same loaded type wants\n");
        delete type;
        return NULL;
    }

    Allocation *alloc = new Allocation(rsc, type);
    alloc->setName(name.string(), name.size());

    // Read in all of our allocation data
    stream->loadByteArray(alloc->getPtr(), dataSize);

    return alloc;
}

void Allocation::sendDirty() const
{
    for (size_t ct=0; ct < mToDirtyList.size(); ct++) {
@@ -514,6 +576,8 @@ static ElementConverter_t pickConverter(const Element *dst, const Element *src)
    return 0;
}

#ifndef ANDROID_RS_BUILD_FOR_HOST

RsAllocation rsi_AllocationCreateBitmapRef(Context *rsc, RsType vtype,
                                           void *bmp, void *callbackData, RsBitmapCallback_t callback)
{
@@ -615,6 +679,7 @@ void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data)
    a->read(data);
}

#endif //ANDROID_RS_BUILD_FOR_HOST

}
}
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ public:
    void removeProgramToDirty(const Program *);

    virtual void dumpLOGV(const char *prefix) const;
    virtual void serialize(OStream *stream) const;
    virtual A3DClassID getClassId() const { return A3D_CLASS_ID_ALLOCATION; }
    static Allocation *createFromStream(Context *rsc, IStream *stream);

    virtual void uploadCheck(const Context *rsc);

Loading