diff options
author | Jason Sams <jsams@google.com> | 2015-01-12 23:04:28 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-01-12 23:04:29 +0000 |
commit | 6000c26e0e382d12e4e97bf5839912e500dc47c5 (patch) | |
tree | 676d1c239d3be0e1e9a7a0ae15efe4c0d808420a /rsType.cpp | |
parent | 0d28fbf52964d8a15435ef37c78ad1188d247552 (diff) | |
parent | c7968a0ac24f05d978616a79a5068b6b16dbbda6 (diff) | |
download | rs-6000c26e0e382d12e4e97bf5839912e500dc47c5.tar.gz |
Merge "Array type and allocation support"
Diffstat (limited to 'rsType.cpp')
-rw-r--r-- | rsType.cpp | 97 |
1 files changed, 72 insertions, 25 deletions
@@ -62,6 +62,9 @@ void Type::clear() { delete [] mHal.state.lodDimY; delete [] mHal.state.lodDimZ; } + if (mHal.state.arrayCount > 0) { + delete [] mHal.state.arrays; + } mElement.clear(); memset(&mHal, 0, sizeof(mHal)); } @@ -192,12 +195,14 @@ Type *Type::createFromStream(Context *rsc, IStream *stream) { return nullptr; } - 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(); - Type *type = Type::getType(rsc, elem, x, y, z, lod != 0, faces !=0, 0); + RsTypeCreateParams p; + memset(&p, 0, sizeof(p)); + p.dimX = stream->loadU32(); + p.dimY = stream->loadU32(); + p.dimZ = stream->loadU32(); + p.mipmaps = stream->loadU8(); + p.faces = stream->loadU8(); + Type *type = Type::getType(rsc, elem, &p, sizeof(p)); elem->decUserRef(); delete [] name; @@ -222,8 +227,7 @@ bool Type::getIsNp2() const { } ObjectBaseRef<Type> Type::getTypeRef(Context *rsc, const Element *e, - uint32_t dimX, uint32_t dimY, uint32_t dimZ, - bool dimLOD, bool dimFaces, uint32_t dimYuv) { + const RsTypeCreateParams *params, size_t len) { ObjectBaseRef<Type> returnRef; TypeState * stc = &rsc->mStateType; @@ -232,12 +236,16 @@ ObjectBaseRef<Type> Type::getTypeRef(Context *rsc, const Element *e, 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; - if (t->getDimYuv() != dimYuv) continue; + if (t->getDimX() != params->dimX) continue; + if (t->getDimY() != params->dimY) continue; + if (t->getDimZ() != params->dimZ) continue; + if (t->getDimLOD() != params->mipmaps) continue; + if (t->getDimFaces() != params->faces) continue; + if (t->getDimYuv() != params->yuv) continue; + if (t->getArray(0) != params->array0) continue; + if (t->getArray(1) != params->array1) continue; + if (t->getArray(2) != params->array2) continue; + if (t->getArray(3) != params->array3) continue; returnRef.set(t); ObjectBase::asyncUnlock(); return returnRef; @@ -258,14 +266,28 @@ ObjectBaseRef<Type> Type::getTypeRef(Context *rsc, const Element *e, ALOGE("pointer for type.drv: %p", &nt->mHal.drv); #endif - nt->mDimLOD = dimLOD; + nt->mDimLOD = params->mipmaps; returnRef.set(nt); nt->mElement.set(e); - nt->mHal.state.dimX = dimX; - nt->mHal.state.dimY = dimY; - nt->mHal.state.dimZ = dimZ; - nt->mHal.state.faces = dimFaces; - nt->mHal.state.dimYuv = dimYuv; + nt->mHal.state.dimX = params->dimX; + nt->mHal.state.dimY = params->dimY; + nt->mHal.state.dimZ = params->dimZ; + nt->mHal.state.faces = params->faces; + nt->mHal.state.dimYuv = params->yuv; + + nt->mHal.state.arrayCount = 0; + if (params->array0 > 0) nt->mHal.state.arrayCount ++; + if (params->array1 > 0) nt->mHal.state.arrayCount ++; + if (params->array2 > 0) nt->mHal.state.arrayCount ++; + if (params->array3 > 0) nt->mHal.state.arrayCount ++; + if (nt->mHal.state.arrayCount > 0) { + nt->mHal.state.arrays = new uint32_t[nt->mHal.state.arrayCount]; + if (params->array0 > 0) nt->mHal.state.arrays[0] = params->array0; + if (params->array1 > 1) nt->mHal.state.arrays[1] = params->array1; + if (params->array2 > 2) nt->mHal.state.arrays[2] = params->array2; + if (params->array3 > 3) nt->mHal.state.arrays[3] = params->array3; + } + nt->compute(); ObjectBase::asyncLock(); @@ -276,15 +298,27 @@ ObjectBaseRef<Type> Type::getTypeRef(Context *rsc, const Element *e, } ObjectBaseRef<Type> Type::cloneAndResize1D(Context *rsc, uint32_t dimX) const { - return getTypeRef(rsc, mElement.get(), dimX, - getDimY(), getDimZ(), getDimLOD(), getDimFaces(), getDimYuv()); + RsTypeCreateParams p; + memset(&p, 0, sizeof(p)); + p.dimX = dimX; + p.dimY = getDimY(); + p.dimZ = getDimZ(); + p.mipmaps = getDimLOD(); + return getTypeRef(rsc, mElement.get(), &p, sizeof(p)); } ObjectBaseRef<Type> Type::cloneAndResize2D(Context *rsc, uint32_t dimX, uint32_t dimY) const { - return getTypeRef(rsc, mElement.get(), dimX, dimY, - getDimZ(), getDimLOD(), getDimFaces(), getDimYuv()); + RsTypeCreateParams p; + memset(&p, 0, sizeof(p)); + p.dimX = dimX; + p.dimY = dimY; + p.dimZ = getDimZ(); + p.mipmaps = getDimLOD(); + p.faces = getDimFaces(); + p.yuv = getDimYuv(); + return getTypeRef(rsc, mElement.get(), &p, sizeof(p)); } @@ -335,7 +369,20 @@ RsType rsi_TypeCreate(Context *rsc, RsElement _e, uint32_t dimX, uint32_t dimY, uint32_t dimZ, bool mipmaps, bool faces, uint32_t yuv) { Element *e = static_cast<Element *>(_e); - return Type::getType(rsc, e, dimX, dimY, dimZ, mipmaps, faces, yuv); + RsTypeCreateParams p; + memset(&p, 0, sizeof(p)); + p.dimX = dimX; + p.dimY = dimY; + p.dimZ = dimZ; + p.mipmaps = mipmaps; + p.faces = faces; + p.yuv = yuv; + return Type::getType(rsc, e, &p, sizeof(p)); +} + +RsType rsi_TypeCreate2(Context *rsc, const RsTypeCreateParams *p, uint32_t len) { + Element *e = static_cast<Element *>(p->e); + return Type::getType(rsc, e, p, len); } } |