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

Commit 4344b724 authored by Jason Sams's avatar Jason Sams Committed by Android (Google) Code Review
Browse files

Merge "More RS cpp binding work. All classes for compute should be partially...

Merge "More RS cpp binding work.  All classes for compute should be partially implemented at this time."
parents c97a2b6e 170dc848
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */

#ifndef __ANDROID_ALLOCATION_H__
#define __ANDROID_ALLOCATION_H__

#include <pthread.h>
#include <rs.h>
@@ -22,7 +24,7 @@
#include "Type.h"
#include "Element.h"

class Allocation : BaseObj {
class Allocation : public BaseObj {
protected:
    const Type *mType;
    uint32_t mUsage;
@@ -121,4 +123,4 @@ public:

};

#endif
+3 −1
Original line number Diff line number Diff line
@@ -132,7 +132,9 @@ LOCAL_SRC_FILES:= \
	BaseObj.cpp \
	Element.cpp \
	Type.cpp \
	Allocation.cpp
	Allocation.cpp \
	Script.cpp \
	ScriptC.cpp

LOCAL_SHARED_LIBRARIES += libz libcutils libutils libEGL libGLESv1_CM libGLESv2 libui libbcc libbcinfo libgui

+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@ void * BaseObj::getID() const {
    return mID;
}

void * BaseObj::getObjID(const BaseObj *o) {
    return o == NULL ? NULL : o->getID();
}


BaseObj::BaseObj(void *id, RenderScript *rs) {
    mRS = rs;
    mID = id;
+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ class BaseObj {
protected:
    friend class Element;
    friend class Type;
    friend class Allocation;
    friend class Script;
    friend class ScriptC;

    void *mID;
    RenderScript *mRS;
@@ -37,6 +40,8 @@ protected:
    BaseObj(void *id, RenderScript *rs);
    void checkValid();

    static void * getObjID(const BaseObj *o);

public:

    virtual ~BaseObj();
+15 −25
Original line number Diff line number Diff line
@@ -24,41 +24,40 @@

const Element * Element::getSubElement(uint32_t index) {
    if (!mVisibleElementMap.size()) {
        ALOGE("Element contains no sub-elements");
        return NULL;
        mRS->throwError("Element contains no sub-elements");
    }
    if (index >= mVisibleElementMap.size()) {
        ALOGE("Illegal sub-element index");
        mRS->throwError("Illegal sub-element index");
    }
    return mElements[mVisibleElementMap[index]];
}

const char * Element::getSubElementName(uint32_t index) {
    if (!mVisibleElementMap.size()) {
        ALOGE("Element contains no sub-elements");
        mRS->throwError("Element contains no sub-elements");
    }
    if (index >= mVisibleElementMap.size()) {
        ALOGE("Illegal sub-element index");
        mRS->throwError("Illegal sub-element index");
    }
    return mElementNames[mVisibleElementMap[index]];
}

size_t Element::getSubElementArraySize(uint32_t index) {
    if (!mVisibleElementMap.size()) {
        ALOGE("Element contains no sub-elements");
        mRS->throwError("Element contains no sub-elements");
    }
    if (index >= mVisibleElementMap.size()) {
        ALOGE("Illegal sub-element index");
        mRS->throwError("Illegal sub-element index");
    }
    return mArraySizes[mVisibleElementMap[index]];
}

uint32_t Element::getSubElementOffsetBytes(uint32_t index) {
    if (mVisibleElementMap.size()) {
        ALOGE("Element contains no sub-elements");
        mRS->throwError("Element contains no sub-elements");
    }
    if (index >= mVisibleElementMap.size()) {
        ALOGE("Illegal sub-element index");
        mRS->throwError("Illegal sub-element index");
    }
    return mOffsetInBytes[mVisibleElementMap[index]];
}
@@ -293,54 +292,45 @@ void Element::updateFromNative() {
}

const Element * Element::createUser(RenderScript *rs, RsDataType dt) {
    ALOGE("createUser %p %i", rs, dt);
    void * id = rsElementCreate(rs->mContext, dt, RS_KIND_USER, false, 1);
    return new Element(id, rs, dt, RS_KIND_USER, false, 1);
}

const Element * Element::createVector(RenderScript *rs, RsDataType dt, uint32_t size) {
    if (size < 2 || size > 4) {
        ALOGE("Vector size out of range 2-4.");
        return NULL;
        rs->throwError("Vector size out of range 2-4.");
    }
    void *id = rsElementCreate(rs->mContext, dt, RS_KIND_USER, false, size);
    return new Element(id, rs, dt, RS_KIND_USER, false, size);
}

const Element * Element::createPixel(RenderScript *rs, RsDataType dt, RsDataKind dk) {
    ALOGE("createPixel %p %i %i", rs, dt, dk);
    if (!(dk == RS_KIND_PIXEL_L ||
          dk == RS_KIND_PIXEL_A ||
          dk == RS_KIND_PIXEL_LA ||
          dk == RS_KIND_PIXEL_RGB ||
          dk == RS_KIND_PIXEL_RGBA ||
          dk == RS_KIND_PIXEL_DEPTH)) {
        ALOGE("Unsupported DataKind");
        return NULL;
        rs->throwError("Unsupported DataKind");
    }
    if (!(dt == RS_TYPE_UNSIGNED_8 ||
          dt == RS_TYPE_UNSIGNED_16 ||
          dt == RS_TYPE_UNSIGNED_5_6_5 ||
          dt == RS_TYPE_UNSIGNED_4_4_4_4 ||
          dt == RS_TYPE_UNSIGNED_5_5_5_1)) {
        ALOGE("Unsupported DataType");
        return NULL;
        rs->throwError("Unsupported DataType");
    }
    if (dt == RS_TYPE_UNSIGNED_5_6_5 && dk != RS_KIND_PIXEL_RGB) {
        ALOGE("Bad kind and type combo");
        return NULL;
        rs->throwError("Bad kind and type combo");
    }
    if (dt == RS_TYPE_UNSIGNED_5_5_5_1 && dk != RS_KIND_PIXEL_RGBA) {
        ALOGE("Bad kind and type combo");
        return NULL;
        rs->throwError("Bad kind and type combo");
    }
    if (dt == RS_TYPE_UNSIGNED_4_4_4_4 && dk != RS_KIND_PIXEL_RGBA) {
        ALOGE("Bad kind and type combo");
        return NULL;
        rs->throwError("Bad kind and type combo");
    }
    if (dt == RS_TYPE_UNSIGNED_16 && dk != RS_KIND_PIXEL_DEPTH) {
        ALOGE("Bad kind and type combo");
        return NULL;
        rs->throwError("Bad kind and type combo");
    }

    int size = 1;
Loading