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

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

Merge "Pipe rsa function though the RS api table."

parents 7da9ff5b c5765371
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -381,7 +381,7 @@ nTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid,
    LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i)",
            con, eid, dimx, dimy, dimz, mips, faces);

    jint id = (jint)rsaTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces);
    jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces);
    return (jint)id;
}

@@ -409,7 +409,7 @@ static jint
nAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mips, jint usage)
{
    LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i)", con, (RsElement)type, mips, usage);
    return (jint) rsaAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage);
    return (jint) rsAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage);
}

static void
@@ -435,7 +435,7 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint typ

    bitmap.lockPixels();
    const void* ptr = bitmap.getPixels();
    jint id = (jint)rsaAllocationCreateFromBitmap(con,
    jint id = (jint)rsAllocationCreateFromBitmap(con,
                                                  (RsType)type, (RsAllocationMipmapControl)mip,
                                                  ptr, bitmap.getSize(), usage);
    bitmap.unlockPixels();
@@ -451,7 +451,7 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint

    bitmap.lockPixels();
    const void* ptr = bitmap.getPixels();
    jint id = (jint)rsaAllocationCubeCreateFromBitmap(con,
    jint id = (jint)rsAllocationCubeCreateFromBitmap(con,
                                                      (RsType)type, (RsAllocationMipmapControl)mip,
                                                      ptr, bitmap.getSize(), usage);
    bitmap.unlockPixels();
+4 −4
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ ContextDeinitToClient {
    direct
}

aTypeCreate {
TypeCreate {
    direct
    param RsElement e
    param uint32_t dimX
@@ -77,7 +77,7 @@ aTypeCreate {
    ret RsType
}

aAllocationCreateTyped {
AllocationCreateTyped {
    direct
    param RsType vtype
    param RsAllocationMipmapControl mips
@@ -85,7 +85,7 @@ aAllocationCreateTyped {
    ret RsAllocation
}

aAllocationCreateFromBitmap {
AllocationCreateFromBitmap {
    direct
    param RsType vtype
    param RsAllocationMipmapControl mips
@@ -94,7 +94,7 @@ aAllocationCreateFromBitmap {
    ret RsAllocation
}

aAllocationCubeCreateFromBitmap {
AllocationCubeCreateFromBitmap {
    direct
    param RsType vtype
    param RsAllocationMipmapControl mips
+27 −29
Original line number Diff line number Diff line
@@ -649,11 +649,12 @@ void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY) {
//
#ifndef ANDROID_RS_SERIALIZE

static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va);

namespace android {
namespace renderscript {

static void AllocationGenerateScriptMips(RsContext con, RsAllocation va);

void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, bool genmip, uint32_t baseMipLevel) {
    Allocation *alloc = static_cast<Allocation *>(va);
    alloc->deferredUploadToTexture(rsc);
@@ -740,7 +741,7 @@ void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType

void rsi_AllocationGenerateMipmaps(Context *rsc, RsAllocation va) {
    Allocation *texAlloc = static_cast<Allocation *>(va);
    rsaAllocationGenerateScriptMips(rsc, texAlloc);
    AllocationGenerateScriptMips(rsc, texAlloc);
}

void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) {
@@ -795,10 +796,7 @@ void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32
    a->resize2D(rsc, dimX, dimY);
}

}
}

static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va) {
static void AllocationGenerateScriptMips(RsContext con, RsAllocation va) {
    Context *rsc = static_cast<Context *>(con);
    Allocation *texAlloc = static_cast<Allocation *>(va);
    uint32_t numFaces = texAlloc->getType()->getDimFaces() ? 6 : 1;
@@ -815,29 +813,20 @@ static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va) {
    }
}

const void * rsaAllocationGetType(RsContext con, RsAllocation va) {
    Allocation *a = static_cast<Allocation *>(va);
    a->getType()->incUserRef();

    return a->getType();
}

RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype,
RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype,
                                       RsAllocationMipmapControl mips,
                                       uint32_t usages) {
    Context *rsc = static_cast<Context *>(con);
    Allocation * alloc = new Allocation(rsc, static_cast<Type *>(vtype), usages, mips);
    alloc->incUserRef();
    return alloc;
}

RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype,
RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, RsType vtype,
                                            RsAllocationMipmapControl mips,
                                            const void *data, size_t data_length, uint32_t usages) {
    Context *rsc = static_cast<Context *>(con);
    Type *t = static_cast<Type *>(vtype);

    RsAllocation vTexAlloc = rsaAllocationCreateTyped(rsc, vtype, mips, usages);
    RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages);
    Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
    if (texAlloc == NULL) {
        LOGE("Memory allocation failure");
@@ -846,23 +835,22 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype,

    memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes());
    if (mips == RS_ALLOCATION_MIPMAP_FULL) {
        rsaAllocationGenerateScriptMips(rsc, texAlloc);
        AllocationGenerateScriptMips(rsc, texAlloc);
    }

    texAlloc->deferredUploadToTexture(rsc);
    return texAlloc;
}

RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype,
RsAllocation rsi_AllocationCubeCreateFromBitmap(Context *rsc, RsType vtype,
                                                RsAllocationMipmapControl mips,
                                                const void *data, size_t data_length, uint32_t usages) {
    Context *rsc = static_cast<Context *>(con);
    Type *t = static_cast<Type *>(vtype);

    // Cubemap allocation's faces should be Width by Width each.
    // Source data should have 6 * Width by Width pixels
    // Error checking is done in the java layer
    RsAllocation vTexAlloc = rsaAllocationCreateTyped(rsc, t, mips, usages);
    RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages);
    Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
    if (texAlloc == NULL) {
        LOGE("Memory allocation failure");
@@ -887,11 +875,21 @@ RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype,
    }

    if (mips == RS_ALLOCATION_MIPMAP_FULL) {
        rsaAllocationGenerateScriptMips(rsc, texAlloc);
        AllocationGenerateScriptMips(rsc, texAlloc);
    }

    texAlloc->deferredUploadToTexture(rsc);
    return texAlloc;
}

}
}

const void * rsaAllocationGetType(RsContext con, RsAllocation va) {
    Allocation *a = static_cast<Allocation *>(va);
    a->getType()->incUserRef();

    return a->getType();
}

#endif //ANDROID_RS_SERIALIZE
+12 −17
Original line number Diff line number Diff line
@@ -740,25 +740,21 @@ void rsi_ContextDestroyWorker(Context *rsc) {
    rsc->destroyWorkerThreadResources();;
}

}
}

void rsContextDestroy(RsContext vcon) {
    LOGV("rsContextDestroy %p", vcon);
    Context *rsc = static_cast<Context *>(vcon);
void rsi_ContextDestroy(Context *rsc) {
    LOGV("rsContextDestroy %p", rsc);
    rsContextDestroyWorker(rsc);
    delete rsc;
    LOGV("rsContextDestroy 2 %p", vcon);
    LOGV("rsContextDestroy 2 %p", rsc);
}

RsContext rsContextCreate(RsDevice vdev, uint32_t version) {
RsContext rsi_ContextCreate(RsDevice vdev, uint32_t version) {
    LOGV("rsContextCreate %p", vdev);
    Device * dev = static_cast<Device *>(vdev);
    Context *rsc = Context::createContext(dev, NULL);
    return rsc;
}

RsContext rsContextCreateGL(RsDevice vdev, uint32_t version,
RsContext rsi_ContextCreateGL(RsDevice vdev, uint32_t version,
                            RsSurfaceConfig sc, uint32_t dpi) {
    LOGV("rsContextCreateGL %p", vdev);
    Device * dev = static_cast<Device *>(vdev);
@@ -768,32 +764,31 @@ RsContext rsContextCreateGL(RsDevice vdev, uint32_t version,
    return rsc;
}

RsMessageToClientType rsContextPeekMessage(RsContext vrsc,
RsMessageToClientType rsi_ContextPeekMessage(Context *rsc,
                                           size_t * receiveLen, size_t receiveLen_length,
                                           uint32_t * subID, size_t subID_length, bool wait) {
    Context * rsc = static_cast<Context *>(vrsc);
    return rsc->peekMessageToClient(receiveLen, subID, wait);
}

RsMessageToClientType rsContextGetMessage(RsContext vrsc, void * data, size_t data_length,
RsMessageToClientType rsi_ContextGetMessage(Context *rsc, void * data, size_t data_length,
                                          size_t * receiveLen, size_t receiveLen_length,
                                          uint32_t * subID, size_t subID_length, bool wait) {
    Context * rsc = static_cast<Context *>(vrsc);
    rsAssert(subID_length == sizeof(uint32_t));
    rsAssert(receiveLen_length == sizeof(size_t));
    return rsc->getMessageToClient(data, receiveLen, subID, data_length, wait);
}

void rsContextInitToClient(RsContext vrsc) {
    Context * rsc = static_cast<Context *>(vrsc);
void rsi_ContextInitToClient(Context *rsc) {
    rsc->initToClient();
}

void rsContextDeinitToClient(RsContext vrsc) {
    Context * rsc = static_cast<Context *>(vrsc);
void rsi_ContextDeinitToClient(Context *rsc) {
    rsc->deinitToClient();
}

}
}

// Only to be called at a3d load time, before object is visible to user
// not thread safe
void rsaGetName(RsContext con, void * obj, const char **name) {
+8 −3
Original line number Diff line number Diff line
@@ -40,17 +40,20 @@ void Device::removeContext(Context *rsc) {
    }
}

RsDevice rsDeviceCreate() {
namespace android {
namespace renderscript {

RsDevice rsi_DeviceCreate() {
    Device * d = new Device();
    return d;
}

void rsDeviceDestroy(RsDevice dev) {
void rsi_DeviceDestroy(RsDevice dev) {
    Device * d = static_cast<Device *>(dev);
    delete d;
}

void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) {
void rsi_DeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) {
    Device * d = static_cast<Device *>(dev);
    if (p == RS_DEVICE_PARAM_FORCE_SOFTWARE_GL) {
        d->mForceSW = value != 0;
@@ -59,3 +62,5 @@ void rsDeviceSetConfig(RsDevice dev, RsDeviceParam p, int32_t value) {
    rsAssert(0);
}

}
}
Loading