diff options
author | Alex Sakhartchouk <alexst@google.com> | 2011-08-16 13:09:46 -0700 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2011-08-16 13:09:46 -0700 |
commit | 117abdbc67123654d0754b686c5bbdee6b44bcdd (patch) | |
tree | 7531e3083956f7fc2db9310253425c32e9743b8f /libs/rs/rsProgramVertex.cpp | |
parent | 065fa8deb178f00ad9957d3212ec2620c46f78e4 (diff) | |
download | frameworks_base-117abdbc67123654d0754b686c5bbdee6b44bcdd.zip frameworks_base-117abdbc67123654d0754b686c5bbdee6b44bcdd.tar.gz frameworks_base-117abdbc67123654d0754b686c5bbdee6b44bcdd.tar.bz2 |
Fixing asynchronous performance issues.
Change-Id: I10f02cd37a33a6c655814d24e0a4291dc044fba3
Diffstat (limited to 'libs/rs/rsProgramVertex.cpp')
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index 058a456..51cb2a8a 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -150,26 +150,30 @@ ProgramVertexState::~ProgramVertexState() { } void ProgramVertexState::init(Context *rsc) { - const Element *matrixElem = Element::create(rsc, RS_TYPE_MATRIX_4X4, RS_KIND_USER, false, 1); - const Element *f2Elem = Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 2); - const Element *f3Elem = Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 3); - const Element *f4Elem = Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 4); - - rsc->mStateElement.elementBuilderBegin(); - rsc->mStateElement.elementBuilderAdd(matrixElem, "MV", 1); - rsc->mStateElement.elementBuilderAdd(matrixElem, "P", 1); - rsc->mStateElement.elementBuilderAdd(matrixElem, "TexMatrix", 1); - rsc->mStateElement.elementBuilderAdd(matrixElem, "MVP", 1); - const Element *constInput = rsc->mStateElement.elementBuilderCreate(rsc); - - rsc->mStateElement.elementBuilderBegin(); - rsc->mStateElement.elementBuilderAdd(f4Elem, "position", 1); - rsc->mStateElement.elementBuilderAdd(f4Elem, "color", 1); - rsc->mStateElement.elementBuilderAdd(f3Elem, "normal", 1); - rsc->mStateElement.elementBuilderAdd(f2Elem, "texture0", 1); - const Element *attrElem = rsc->mStateElement.elementBuilderCreate(rsc); - - Type *inputType = Type::getType(rsc, constInput, 1, 0, 0, false, false); + ObjectBaseRef<const Element> matrixElem = Element::createRef(rsc, RS_TYPE_MATRIX_4X4, + RS_KIND_USER, false, 1); + ObjectBaseRef<const Element> f2Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32, + RS_KIND_USER, false, 2); + ObjectBaseRef<const Element> f3Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32, + RS_KIND_USER, false, 3); + ObjectBaseRef<const Element> f4Elem = Element::createRef(rsc, RS_TYPE_FLOAT_32, + RS_KIND_USER, false, 4); + + Element::Builder constBuilder; + constBuilder.add(matrixElem.get(), "MV", 1); + constBuilder.add(matrixElem.get(), "P", 1); + constBuilder.add(matrixElem.get(), "TexMatrix", 1); + constBuilder.add(matrixElem.get(), "MVP", 1); + ObjectBaseRef<const Element> constInput = constBuilder.create(rsc); + + Element::Builder inputBuilder; + inputBuilder.add(f4Elem.get(), "position", 1); + inputBuilder.add(f4Elem.get(), "color", 1); + inputBuilder.add(f3Elem.get(), "normal", 1); + inputBuilder.add(f2Elem.get(), "texture0", 1); + ObjectBaseRef<const Element> attrElem = inputBuilder.create(rsc); + + ObjectBaseRef<Type> inputType = Type::getTypeRef(rsc, constInput.get(), 1, 0, 0, false, false); String8 shaderString(RS_SHADER_INTERNAL); shaderString.append("varying vec4 varColor;\n"); @@ -183,13 +187,13 @@ void ProgramVertexState::init(Context *rsc) { uint32_t tmp[4]; tmp[0] = RS_PROGRAM_PARAM_CONSTANT; - tmp[1] = (uint32_t)inputType; + tmp[1] = (uint32_t)inputType.get(); tmp[2] = RS_PROGRAM_PARAM_INPUT; - tmp[3] = (uint32_t)attrElem; + tmp[3] = (uint32_t)attrElem.get(); ProgramVertex *pv = new ProgramVertex(rsc, shaderString.string(), shaderString.length(), tmp, 4); - Allocation *alloc = Allocation::createAllocation(rsc, inputType, + Allocation *alloc = Allocation::createAllocation(rsc, inputType.get(), RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS); pv->bindAllocation(rsc, alloc, 0); |