Merge "Begin adding async allocation creation."
This commit is contained in:
@@ -194,11 +194,15 @@ public class Allocation extends BaseObj {
|
||||
mRS.nAllocationRead(mID, d);
|
||||
}
|
||||
|
||||
public void resize(int dimX) {
|
||||
public synchronized void resize(int dimX) {
|
||||
if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.getFaces() || mType.getLOD()) {
|
||||
throw new IllegalStateException("Resize only support for 1D allocations at this time.");
|
||||
}
|
||||
mRS.nAllocationResize1D(mID, dimX);
|
||||
|
||||
int typeID = mRS.nAllocationGetType(mID);
|
||||
mType = new Type(typeID, mRS);
|
||||
mType.updateFromNative();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -112,12 +112,10 @@ public class Script extends BaseObj {
|
||||
|
||||
public static class FieldBase {
|
||||
protected Element mElement;
|
||||
protected Type mType;
|
||||
protected Allocation mAllocation;
|
||||
|
||||
protected void init(RenderScript rs, int dimx) {
|
||||
mAllocation = Allocation.createSized(rs, mElement, dimx);
|
||||
mType = mAllocation.getType();
|
||||
}
|
||||
|
||||
protected FieldBase() {
|
||||
@@ -128,7 +126,7 @@ public class Script extends BaseObj {
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return mType;
|
||||
return mAllocation.getType();
|
||||
}
|
||||
|
||||
public Allocation getAllocation() {
|
||||
@@ -138,19 +136,6 @@ public class Script extends BaseObj {
|
||||
//@Override
|
||||
public void updateAllocation() {
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
/*
|
||||
public class ScriptField_UserField
|
||||
extends android.renderscript.Script.FieldBase {
|
||||
|
||||
protected
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ static jint
|
||||
nAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint e)
|
||||
{
|
||||
LOG_API("nAllocationCreateTyped, con(%p), e(%p)", con, (RsElement)e);
|
||||
return (jint) rsAllocationCreateTyped(con, (RsElement)e);
|
||||
return (jint) rsaAllocationCreateTyped(con, (RsElement)e);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -428,7 +428,7 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint dst
|
||||
const int w = bitmap.width();
|
||||
const int h = bitmap.height();
|
||||
const void* ptr = bitmap.getPixels();
|
||||
jint id = (jint)rsAllocationCreateFromBitmap(con, w, h, (RsElement)dstFmt, e, genMips, ptr);
|
||||
jint id = (jint)rsaAllocationCreateFromBitmap(con, w, h, (RsElement)dstFmt, e, genMips, ptr);
|
||||
bitmap.unlockPixels();
|
||||
return id;
|
||||
}
|
||||
@@ -488,7 +488,7 @@ nAllocationCreateFromAssetStream(JNIEnv *_env, jobject _this, RsContext con, jin
|
||||
const int w = bitmap.width();
|
||||
const int h = bitmap.height();
|
||||
const void* ptr = bitmap.getPixels();
|
||||
jint id = (jint)rsAllocationCreateFromBitmap(con, w, h, (RsElement)dstFmt, e, genMips, ptr);
|
||||
jint id = (jint)rsaAllocationCreateFromBitmap(con, w, h, (RsElement)dstFmt, e, genMips, ptr);
|
||||
bitmap.unlockPixels();
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -290,6 +290,8 @@ typedef struct {
|
||||
// Async commands for returning new IDS
|
||||
RsType rsaTypeCreate(RsContext, RsElement, uint32_t dimCount,
|
||||
const RsDimension *dims, const uint32_t *vals);
|
||||
RsAllocation rsaAllocationCreateTyped(RsContext rsc, RsType vtype);
|
||||
RsAllocation rsaAllocationCreateFromBitmap(RsContext con, uint32_t w, uint32_t h, RsElement _dst, RsElement _src, bool genMips, const void *data);
|
||||
|
||||
|
||||
#ifndef NO_RS_FUNCS
|
||||
|
||||
@@ -104,17 +104,6 @@ TypeGetNativeData {
|
||||
param uint32_t typeDataSize
|
||||
}
|
||||
|
||||
AllocationCreateTyped {
|
||||
param RsType type
|
||||
ret RsAllocation
|
||||
}
|
||||
|
||||
AllocationCreateSized {
|
||||
param RsElement e
|
||||
param size_t count
|
||||
ret RsAllocation
|
||||
}
|
||||
|
||||
AllocationUpdateFromBitmap {
|
||||
param RsAllocation alloc
|
||||
param RsElement srcFmt
|
||||
@@ -129,17 +118,6 @@ AllocationCreateBitmapRef {
|
||||
ret RsAllocation
|
||||
}
|
||||
|
||||
AllocationCreateFromBitmap {
|
||||
param uint32_t width
|
||||
param uint32_t height
|
||||
param RsElement dstFmt
|
||||
param RsElement srcFmt
|
||||
param bool genMips
|
||||
param const void * data
|
||||
ret RsAllocation
|
||||
}
|
||||
|
||||
|
||||
AllocationUploadToTexture {
|
||||
param RsAllocation alloc
|
||||
param bool genMipMaps
|
||||
|
||||
@@ -563,24 +563,6 @@ void Allocation::resize2D(Context *rsc, uint32_t dimX, uint32_t dimY)
|
||||
namespace android {
|
||||
namespace renderscript {
|
||||
|
||||
RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype)
|
||||
{
|
||||
const Type * type = static_cast<const Type *>(vtype);
|
||||
|
||||
Allocation * alloc = new Allocation(rsc, type);
|
||||
alloc->incUserRef();
|
||||
return alloc;
|
||||
}
|
||||
|
||||
RsAllocation rsi_AllocationCreateSized(Context *rsc, RsElement e, size_t count)
|
||||
{
|
||||
Type * type = new Type(rsc);
|
||||
type->setDimX(count);
|
||||
type->setElement(static_cast<Element *>(e));
|
||||
type->compute();
|
||||
return rsi_AllocationCreateTyped(rsc, type);
|
||||
}
|
||||
|
||||
void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, bool genmip, uint32_t baseMipLevel)
|
||||
{
|
||||
Allocation *alloc = static_cast<Allocation *>(va);
|
||||
@@ -786,42 +768,6 @@ void rsi_AllocationUpdateFromBitmap(Context *rsc, RsAllocation va, RsElement _sr
|
||||
}
|
||||
}
|
||||
|
||||
RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h, RsElement _dst, RsElement _src, bool genMips, const void *data)
|
||||
{
|
||||
const Element *src = static_cast<const Element *>(_src);
|
||||
const Element *dst = static_cast<const Element *>(_dst);
|
||||
|
||||
//LOGE("%p rsi_AllocationCreateFromBitmap %i %i %i", rsc, w, h, genMips);
|
||||
RsDimension dims[] = {RS_DIMENSION_X, RS_DIMENSION_Y, RS_DIMENSION_LOD};
|
||||
uint32_t dimValues[] = {w, h, genMips};
|
||||
RsType type = rsaTypeCreate(rsc, _dst, 3, dims, dimValues);
|
||||
|
||||
RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, type);
|
||||
Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
|
||||
if (texAlloc == NULL) {
|
||||
LOGE("Memory allocation failure");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ElementConverter_t cvt = pickConverter(dst, src);
|
||||
if (cvt) {
|
||||
cvt(texAlloc->getPtr(), data, w * h);
|
||||
if (genMips) {
|
||||
Adapter2D adapt(rsc, texAlloc);
|
||||
Adapter2D adapt2(rsc, texAlloc);
|
||||
for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
|
||||
adapt.setLOD(lod);
|
||||
adapt2.setLOD(lod + 1);
|
||||
mip(adapt2, adapt);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rsc->setError(RS_ERROR_BAD_VALUE, "Unsupported bitmap format");
|
||||
}
|
||||
|
||||
return texAlloc;
|
||||
}
|
||||
|
||||
void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes)
|
||||
{
|
||||
Allocation *a = static_cast<Allocation *>(va);
|
||||
@@ -882,3 +828,49 @@ const void* rsi_AllocationGetType(Context *rsc, RsAllocation va)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype)
|
||||
{
|
||||
Context *rsc = static_cast<Context *>(con);
|
||||
Allocation * alloc = new Allocation(rsc, static_cast<Type *>(vtype));
|
||||
alloc->incUserRef();
|
||||
return alloc;
|
||||
}
|
||||
|
||||
RsAllocation rsaAllocationCreateFromBitmap(RsContext con, uint32_t w, uint32_t h, RsElement _dst, RsElement _src, bool genMips, const void *data)
|
||||
{
|
||||
Context *rsc = static_cast<Context *>(con);
|
||||
const Element *src = static_cast<const Element *>(_src);
|
||||
const Element *dst = static_cast<const Element *>(_dst);
|
||||
|
||||
//LOGE("%p rsi_AllocationCreateFromBitmap %i %i %i", rsc, w, h, genMips);
|
||||
RsDimension dims[] = {RS_DIMENSION_X, RS_DIMENSION_Y, RS_DIMENSION_LOD};
|
||||
uint32_t dimValues[] = {w, h, genMips};
|
||||
RsType type = rsaTypeCreate(rsc, _dst, 3, dims, dimValues);
|
||||
|
||||
RsAllocation vTexAlloc = rsaAllocationCreateTyped(rsc, type);
|
||||
Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
|
||||
if (texAlloc == NULL) {
|
||||
LOGE("Memory allocation failure");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ElementConverter_t cvt = pickConverter(dst, src);
|
||||
if (cvt) {
|
||||
cvt(texAlloc->getPtr(), data, w * h);
|
||||
if (genMips) {
|
||||
Adapter2D adapt(rsc, texAlloc);
|
||||
Adapter2D adapt2(rsc, texAlloc);
|
||||
for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
|
||||
adapt.setLOD(lod);
|
||||
adapt2.setLOD(lod + 1);
|
||||
mip(adapt2, adapt);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rsc->setError(RS_ERROR_BAD_VALUE, "Unsupported bitmap format");
|
||||
}
|
||||
|
||||
return texAlloc;
|
||||
}
|
||||
|
||||
|
||||
@@ -399,6 +399,7 @@ void rsi_ElementGetSubElements(Context *rsc, RsElement elem, uint32_t *ids, cons
|
||||
rsAssert(e->getFieldCount() == dataSize);
|
||||
|
||||
for(uint32_t i = 0; i < dataSize; i ++) {
|
||||
e->getField(i)->incUserRef();
|
||||
ids[i] = (uint32_t)e->getField(i);
|
||||
names[i] = e->getFieldName(i);
|
||||
}
|
||||
|
||||
@@ -511,10 +511,7 @@ void FontState::initRenderState()
|
||||
mRSC->mStateElement.elementBuilderAdd(gammaElem, "Gamma", 1);
|
||||
const Element *constInput = mRSC->mStateElement.elementBuilderCreate(mRSC);
|
||||
|
||||
Type *inputType = new Type(mRSC);
|
||||
inputType->setElement(constInput);
|
||||
inputType->setDimX(1);
|
||||
inputType->compute();
|
||||
Type *inputType = Type::getType(mRSC, constInput, 1, 0, 0, false, false);
|
||||
|
||||
uint32_t tmp[4];
|
||||
tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
|
||||
@@ -546,11 +543,7 @@ void FontState::initTextTexture()
|
||||
const Element *alphaElem = Element::create(mRSC, RS_TYPE_UNSIGNED_8, RS_KIND_PIXEL_A, true, 1);
|
||||
|
||||
// We will allocate a texture to initially hold 32 character bitmaps
|
||||
Type *texType = new Type(mRSC);
|
||||
texType->setElement(alphaElem);
|
||||
texType->setDimX(1024);
|
||||
texType->setDimY(256);
|
||||
texType->compute();
|
||||
Type *texType = Type::getType(mRSC, alphaElem, 1024, 256, 0, false, false);
|
||||
|
||||
Allocation *cacheAlloc = new Allocation(mRSC, texType);
|
||||
mTextTexture.set(cacheAlloc);
|
||||
@@ -578,11 +571,8 @@ void FontState::initVertexArrayBuffers()
|
||||
{
|
||||
// Now lets write index data
|
||||
const Element *indexElem = Element::create(mRSC, RS_TYPE_UNSIGNED_16, RS_KIND_USER, false, 1);
|
||||
Type *indexType = new Type(mRSC);
|
||||
uint32_t numIndicies = mMaxNumberOfQuads * 6;
|
||||
indexType->setDimX(numIndicies);
|
||||
indexType->setElement(indexElem);
|
||||
indexType->compute();
|
||||
Type *indexType = Type::getType(mRSC, indexElem, numIndicies, 0, 0, false, false);
|
||||
|
||||
Allocation *indexAlloc = new Allocation(mRSC, indexType);
|
||||
uint16_t *indexPtr = (uint16_t*)indexAlloc->getPtr();
|
||||
@@ -612,10 +602,9 @@ void FontState::initVertexArrayBuffers()
|
||||
mRSC->mStateElement.elementBuilderAdd(texElem, "texture0", 1);
|
||||
const Element *vertexDataElem = mRSC->mStateElement.elementBuilderCreate(mRSC);
|
||||
|
||||
Type *vertexDataType = new Type(mRSC);
|
||||
vertexDataType->setDimX(mMaxNumberOfQuads * 4);
|
||||
vertexDataType->setElement(vertexDataElem);
|
||||
vertexDataType->compute();
|
||||
Type *vertexDataType = Type::getType(mRSC, vertexDataElem,
|
||||
mMaxNumberOfQuads * 4,
|
||||
0, 0, false, false);
|
||||
|
||||
Allocation *vertexAlloc = new Allocation(mRSC, vertexDataType);
|
||||
mTextMeshPtr = (float*)vertexAlloc->getPtr();
|
||||
|
||||
@@ -120,8 +120,15 @@ bool ObjectBase::checkDelete(const ObjectBase *ref)
|
||||
|
||||
bool ObjectBase::decUserRef() const
|
||||
{
|
||||
//LOGV("ObjectBase %p decU ref %i, %i", this, mUserRefCount, mSysRefCount);
|
||||
rsAssert(mUserRefCount > 0);
|
||||
#if RS_OBJECT_DEBUG
|
||||
LOGV("ObjectBase %p decU ref %i, %i", this, mUserRefCount, mSysRefCount);
|
||||
if (mUserRefCount <= 0) {
|
||||
mStack.dump();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if ((android_atomic_dec(&mUserRefCount) <= 1) &&
|
||||
(android_atomic_acquire_load(&mSysRefCount) <= 0)) {
|
||||
return checkDelete(this);
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
|
||||
#define RS_OBJECT_DEBUG 0
|
||||
|
||||
#if RS_OBJECT_DEBUG
|
||||
#include <utils/CallStack.h>
|
||||
#endif
|
||||
#include <utils/CallStack.h>
|
||||
|
||||
namespace android {
|
||||
namespace renderscript {
|
||||
|
||||
@@ -198,10 +198,7 @@ void ProgramFragmentState::init(Context *rsc)
|
||||
rsc->mStateElement.elementBuilderAdd(colorElem, "Color", 1);
|
||||
const Element *constInput = rsc->mStateElement.elementBuilderCreate(rsc);
|
||||
|
||||
Type *inputType = new Type(rsc);
|
||||
inputType->setElement(constInput);
|
||||
inputType->setDimX(1);
|
||||
inputType->compute();
|
||||
Type *inputType = Type::getType(rsc, constInput, 1, 0, 0, false, false);
|
||||
|
||||
uint32_t tmp[4];
|
||||
tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
|
||||
|
||||
@@ -257,10 +257,7 @@ void ProgramVertexState::init(Context *rsc)
|
||||
rsc->mStateElement.elementBuilderAdd(f2Elem, "texture0", 1);
|
||||
const Element *attrElem = rsc->mStateElement.elementBuilderCreate(rsc);
|
||||
|
||||
Type *inputType = new Type(rsc);
|
||||
inputType->setElement(constInput);
|
||||
inputType->setDimX(1);
|
||||
inputType->compute();
|
||||
Type *inputType = Type::getType(rsc, constInput, 1, 0, 0, false, false);
|
||||
|
||||
String8 shaderString(RS_SHADER_INTERNAL);
|
||||
shaderString.append("varying vec4 varColor;\n");
|
||||
|
||||
@@ -276,20 +276,12 @@ Type *Type::createFromStream(Context *rsc, IStream *stream)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Type *type = new Type(rsc);
|
||||
type->mDimX = stream->loadU32();
|
||||
type->mDimY = stream->loadU32();
|
||||
type->mDimZ = stream->loadU32();
|
||||
|
||||
uint8_t temp = stream->loadU8();
|
||||
type->mDimLOD = temp != 0;
|
||||
|
||||
temp = stream->loadU8();
|
||||
type->mFaces = temp != 0;
|
||||
|
||||
type->setElement(elem);
|
||||
|
||||
return type;
|
||||
uint32_t x = stream->loadU32();
|
||||
uint32_t y = stream->loadU32();
|
||||
uint32_t z = stream->loadU32();
|
||||
uint8_t lod = stream->loadU8();
|
||||
uint8_t faces = stream->loadU8();
|
||||
return Type::getType(rsc, elem, x, y, z, lod != 0, faces !=0 );
|
||||
}
|
||||
|
||||
bool Type::getIsNp2() const
|
||||
@@ -325,56 +317,55 @@ bool Type::isEqual(const Type *other) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
Type * Type::cloneAndResize1D(Context *rsc, uint32_t dimX) const
|
||||
Type * Type::getType(Context *rsc, const Element *e,
|
||||
uint32_t dimX, uint32_t dimY, uint32_t dimZ,
|
||||
bool dimLOD, bool dimFaces)
|
||||
{
|
||||
TypeState * stc = &rsc->mStateType;
|
||||
|
||||
ObjectBase::asyncLock();
|
||||
for (uint32_t ct=0; ct < stc->mTypes.size(); ct++) {
|
||||
Type *t = stc->mTypes[ct];
|
||||
if (t->getElement() != mElement.get()) continue;
|
||||
if (t->getElement() != e) continue;
|
||||
if (t->getDimX() != dimX) continue;
|
||||
if (t->getDimY() != mDimY) continue;
|
||||
if (t->getDimZ() != mDimZ) continue;
|
||||
if (t->getDimLOD() != mDimLOD) continue;
|
||||
if (t->getDimFaces() != mFaces) continue;
|
||||
if (t->getDimY() != dimY) continue;
|
||||
if (t->getDimZ() != dimZ) continue;
|
||||
if (t->getDimLOD() != dimLOD) continue;
|
||||
if (t->getDimFaces() != dimFaces) continue;
|
||||
t->incUserRef();
|
||||
ObjectBase::asyncUnlock();
|
||||
return t;
|
||||
}
|
||||
ObjectBase::asyncUnlock();
|
||||
|
||||
|
||||
Type *nt = new Type(rsc);
|
||||
nt->mElement.set(mElement);
|
||||
nt->mElement.set(e);
|
||||
nt->mDimX = dimX;
|
||||
nt->mDimY = mDimY;
|
||||
nt->mDimZ = mDimZ;
|
||||
nt->mDimLOD = mDimLOD;
|
||||
nt->mFaces = mFaces;
|
||||
nt->mDimY = dimY;
|
||||
nt->mDimZ = dimZ;
|
||||
nt->mDimLOD = dimLOD;
|
||||
nt->mFaces = dimFaces;
|
||||
nt->compute();
|
||||
nt->incUserRef();
|
||||
|
||||
ObjectBase::asyncLock();
|
||||
stc->mTypes.push(nt);
|
||||
ObjectBase::asyncUnlock();
|
||||
|
||||
return nt;
|
||||
}
|
||||
|
||||
Type * Type::cloneAndResize1D(Context *rsc, uint32_t dimX) const
|
||||
{
|
||||
return getType(rsc, mElement.get(), dimX,
|
||||
mDimY, mDimZ, mDimLOD, mFaces);
|
||||
}
|
||||
|
||||
Type * Type::cloneAndResize2D(Context *rsc, uint32_t dimX, uint32_t dimY) const
|
||||
{
|
||||
TypeState * stc = &rsc->mStateType;
|
||||
for (uint32_t ct=0; ct < stc->mTypes.size(); ct++) {
|
||||
Type *t = stc->mTypes[ct];
|
||||
if (t->getElement() != mElement.get()) continue;
|
||||
if (t->getDimX() != dimX) continue;
|
||||
if (t->getDimY() != dimY) continue;
|
||||
if (t->getDimZ() != mDimZ) continue;
|
||||
if (t->getDimLOD() != mDimLOD) continue;
|
||||
if (t->getDimFaces() != mFaces) continue;
|
||||
t->incUserRef();
|
||||
return t;
|
||||
}
|
||||
|
||||
Type *nt = new Type(rsc);
|
||||
nt->mElement.set(mElement);
|
||||
nt->mDimX = dimX;
|
||||
nt->mDimY = dimY;
|
||||
nt->mDimZ = mDimZ;
|
||||
nt->mDimLOD = mDimLOD;
|
||||
nt->mFaces = mFaces;
|
||||
nt->compute();
|
||||
return nt;
|
||||
return getType(rsc, mElement.get(), dimX, dimY,
|
||||
mDimZ, mDimLOD, mFaces);
|
||||
}
|
||||
|
||||
|
||||
@@ -396,7 +387,7 @@ void rsi_TypeGetNativeData(Context *rsc, RsType type, uint32_t *typeData, uint32
|
||||
(*typeData++) = t->getDimLOD();
|
||||
(*typeData++) = t->getDimFaces() ? 1 : 0;
|
||||
(*typeData++) = (uint32_t)t->getElement();
|
||||
|
||||
t->getElement()->incUserRef();
|
||||
}
|
||||
|
||||
|
||||
@@ -430,34 +421,6 @@ RsType rsaTypeCreate(RsContext con, RsElement _e, uint32_t dimCount,
|
||||
}
|
||||
}
|
||||
|
||||
ObjectBase::asyncLock();
|
||||
for (uint32_t ct=0; ct < stc->mTypes.size(); ct++) {
|
||||
Type *t = stc->mTypes[ct];
|
||||
if (t->getElement() != e) continue;
|
||||
if (t->getDimX() != dimX) continue;
|
||||
if (t->getDimY() != dimY) continue;
|
||||
if (t->getDimZ() != dimZ) continue;
|
||||
if (t->getDimLOD() != dimLOD) continue;
|
||||
if (t->getDimFaces() != dimFaces) continue;
|
||||
t->incUserRef();
|
||||
ObjectBase::asyncUnlock();
|
||||
return t;
|
||||
}
|
||||
ObjectBase::asyncUnlock();
|
||||
|
||||
Type * st = new Type(rsc);
|
||||
st->incUserRef();
|
||||
st->setDimX(dimX);
|
||||
st->setDimY(dimY);
|
||||
st->setDimZ(dimZ);
|
||||
st->setElement(e);
|
||||
st->setDimLOD(dimLOD);
|
||||
st->setDimFaces(dimFaces);
|
||||
st->compute();
|
||||
|
||||
ObjectBase::asyncLock();
|
||||
stc->mTypes.push(st);
|
||||
ObjectBase::asyncUnlock();
|
||||
return st;
|
||||
return Type::getType(rsc, e, dimX, dimY, dimZ, dimLOD, dimFaces);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,6 @@ namespace renderscript {
|
||||
class Type : public ObjectBase
|
||||
{
|
||||
public:
|
||||
Type(Context *);
|
||||
virtual ~Type();
|
||||
|
||||
Type * createTex2D(const Element *, size_t w, size_t h, bool mip);
|
||||
|
||||
|
||||
@@ -58,15 +55,6 @@ public:
|
||||
uint32_t getLODCount() const {return mLODCount;}
|
||||
bool getIsNp2() const;
|
||||
|
||||
|
||||
void setElement(const Element *e) {mElement.set(e);}
|
||||
void setDimX(uint32_t v) {mDimX = v;}
|
||||
void setDimY(uint32_t v) {mDimY = v;}
|
||||
void setDimZ(uint32_t v) {mDimZ = v;}
|
||||
void setDimFaces(bool v) {mFaces = v;}
|
||||
void setDimLOD(bool v) {mDimLOD = v;}
|
||||
|
||||
|
||||
void clear();
|
||||
void compute();
|
||||
|
||||
@@ -82,6 +70,10 @@ public:
|
||||
Type * cloneAndResize1D(Context *rsc, uint32_t dimX) const;
|
||||
Type * cloneAndResize2D(Context *rsc, uint32_t dimX, uint32_t dimY) const;
|
||||
|
||||
static Type * getType(Context *rsc, const Element *e,
|
||||
uint32_t dimX, uint32_t dimY, uint32_t dimZ,
|
||||
bool dimLOD, bool dimFaces);
|
||||
|
||||
protected:
|
||||
struct LOD {
|
||||
size_t mX;
|
||||
@@ -124,10 +116,13 @@ protected:
|
||||
bool isValidGLComponent(uint32_t fieldIdx);
|
||||
void makeGLComponents();
|
||||
|
||||
|
||||
protected:
|
||||
virtual void preDestroy();
|
||||
virtual ~Type();
|
||||
|
||||
private:
|
||||
Type(Context *);
|
||||
Type(const Type &);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user