当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectBaseRef类代码示例

本文整理汇总了C++中ObjectBaseRef的典型用法代码示例。如果您正苦于以下问题:C++ ObjectBaseRef类的具体用法?C++ ObjectBaseRef怎么用?C++ ObjectBaseRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectBaseRef类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Element

ObjectBaseRef<const Element> Element::createRef(Context *rsc, RsDataType dt, RsDataKind dk,
                                bool isNorm, uint32_t vecSize) {
    ObjectBaseRef<const Element> returnRef;
    // Look for an existing match.
    ObjectBase::asyncLock();
    for (uint32_t ct=0; ct < rsc->mStateElement.mElements.size(); ct++) {
        const Element *ee = rsc->mStateElement.mElements[ct];
        if (!ee->getFieldCount() &&
            (ee->getComponent().getType() == dt) &&
            (ee->getComponent().getKind() == dk) &&
            (ee->getComponent().getIsNormalized() == isNorm) &&
            (ee->getComponent().getVectorSize() == vecSize)) {
            // Match
            returnRef.set(ee);
            ObjectBase::asyncUnlock();
            return ee;
        }
    }
    ObjectBase::asyncUnlock();

    Element *e = new Element(rsc);
    returnRef.set(e);
    e->mComponent.set(dt, dk, isNorm, vecSize);
    e->compute();

    ObjectBase::asyncLock();
    rsc->mStateElement.mElements.push(e);
    ObjectBase::asyncUnlock();

    return returnRef;
}
开发者ID:28vicky,项目名称:platform_frameworks_base,代码行数:31,代码来源:rsElement.cpp

示例2: rsi_SamplerCreate

RsSampler rsi_SamplerCreate(Context * rsc,
                            RsSamplerValue magFilter,
                            RsSamplerValue minFilter,
                            RsSamplerValue wrapS,
                            RsSamplerValue wrapT,
                            RsSamplerValue wrapR,
                            float aniso) {
    ObjectBaseRef<Sampler> s = Sampler::getSampler(rsc, magFilter, minFilter,
                                                   wrapS, wrapT, wrapR, aniso);
    s->incUserRef();
    return s.get();
}
开发者ID:SundownerROM,项目名称:frameworks_rs,代码行数:12,代码来源:rsSampler.cpp

示例3: init

void ProgramVertexState::init(Context *rsc) {
    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");
    shaderString.append("varying vec2 varTex0;\n");
    shaderString.append("void main() {\n");
    shaderString.append("  gl_Position = UNI_MVP * ATTRIB_position;\n");
    shaderString.append("  gl_PointSize = 1.0;\n");
    shaderString.append("  varColor = ATTRIB_color;\n");
    shaderString.append("  varTex0 = ATTRIB_texture0;\n");
    shaderString.append("}\n");

    uint32_t tmp[4];
    tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
    tmp[1] = (uint32_t)inputType.get();
    tmp[2] = RS_PROGRAM_PARAM_INPUT;
    tmp[3] = (uint32_t)attrElem.get();

    ProgramVertex *pv = new ProgramVertex(rsc, shaderString.string(),
                                          shaderString.length(), tmp, 4);
    Allocation *alloc = Allocation::createAllocation(rsc, inputType.get(),
                              RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS);
    pv->bindAllocation(rsc, alloc, 0);

    mDefaultAlloc.set(alloc);
    mDefault.set(pv);

    updateSize(rsc);
}
开发者ID:10x-Amin,项目名称:frameworks_base,代码行数:53,代码来源:rsProgramVertex.cpp

示例4: decRefs

void Allocation::resize1D(Context *rsc, uint32_t dimX) {
    uint32_t oldDimX = mHal.state.dimensionX;
    if (dimX == oldDimX) {
        return;
    }

    ObjectBaseRef<Type> t = mHal.state.type->cloneAndResize1D(rsc, dimX);
    if (dimX < oldDimX) {
        decRefs(getPtr(), oldDimX - dimX, dimX);
    }
    rsc->mHal.funcs.allocation.resize(rsc, this, t.get(), mHal.state.hasReferences);
    setType(t.get());
    updateCache();
}
开发者ID:Bmetz,项目名称:platform_frameworks_base,代码行数:14,代码来源:rsAllocation.cpp

示例5: main

void FontState::initRenderState() {
    const char *shaderString = "varying vec2 varTex0;\n"
                               "void main() {\n"
                               "  lowp vec4 col = UNI_Color;\n"
                               "  col.a = texture2D(UNI_Tex0, varTex0.xy).a;\n"
                               "  col.a = pow(col.a, UNI_Gamma);\n"
                               "  gl_FragColor = col;\n"
                               "}\n";

    const char *textureNames[] = { "Tex0" };
    const size_t textureNamesLengths[] = { 4 };
    size_t numTextures = sizeof(textureNamesLengths)/sizeof(*textureNamesLengths);

    ObjectBaseRef<const Element> colorElem = Element::createRef(mRSC, RS_TYPE_FLOAT_32,
                                                                RS_KIND_USER, false, 4);
    ObjectBaseRef<const Element> gammaElem = Element::createRef(mRSC, RS_TYPE_FLOAT_32,
                                                                RS_KIND_USER, false, 1);

    const char *ebn1[] = { "Color", "Gamma" };
    const Element *ebe1[] = {colorElem.get(), gammaElem.get()};
    ObjectBaseRef<const Element> constInput = Element::create(mRSC, 2, ebe1, ebn1);

    ObjectBaseRef<Type> inputType = Type::getTypeRef(mRSC, constInput.get(), 1, 0, 0, false, false, 0);

    uintptr_t tmp[4];
    tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
    tmp[1] = (uintptr_t)inputType.get();
    tmp[2] = RS_PROGRAM_PARAM_TEXTURE_TYPE;
    tmp[3] = RS_TEXTURE_2D;

    mFontShaderFConstant.set(Allocation::createAllocation(mRSC, inputType.get(),
                                                          RS_ALLOCATION_USAGE_SCRIPT |
                                                          RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS));
    ProgramFragment *pf = new ProgramFragment(mRSC, shaderString, strlen(shaderString),
                                              textureNames, numTextures, textureNamesLengths,
                                              tmp, 4);
    mFontShaderF.set(pf);
    mFontShaderF->bindAllocation(mRSC, mFontShaderFConstant.get(), 0);

    mFontSampler.set(Sampler::getSampler(mRSC, RS_SAMPLER_NEAREST, RS_SAMPLER_NEAREST,
                                         RS_SAMPLER_CLAMP, RS_SAMPLER_CLAMP,
                                         RS_SAMPLER_CLAMP).get());
    mFontShaderF->bindSampler(mRSC, 0, mFontSampler.get());

    mFontProgramStore.set(ProgramStore::getProgramStore(mRSC, true, true, true, true,
                                                        false, false,
                                                        RS_BLEND_SRC_SRC_ALPHA,
                                                        RS_BLEND_DST_ONE_MINUS_SRC_ALPHA,
                                                        RS_DEPTH_FUNC_ALWAYS).get());
    mFontProgramStore->init();
}
开发者ID:xin3liang,项目名称:platform_frameworks_rs,代码行数:51,代码来源:rsFont.cpp

示例6: shaderString

void ProgramFragmentState::init(Context *rsc) {
    String8 shaderString(RS_SHADER_INTERNAL);
    shaderString.append("varying lowp vec4 varColor;\n");
    shaderString.append("varying vec2 varTex0;\n");
    shaderString.append("void main() {\n");
    shaderString.append("  lowp vec4 col = UNI_Color;\n");
    shaderString.append("  gl_FragColor = col;\n");
    shaderString.append("}\n");

    ObjectBaseRef<const Element> colorElem = Element::createRef(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 4);
    Element::Builder builder;
    builder.add(colorElem.get(), "Color", 1);
    ObjectBaseRef<const Element> constInput = builder.create(rsc);

    ObjectBaseRef<Type> inputType = Type::getTypeRef(rsc, constInput.get(), 1, 0, 0, false, false);

    uint32_t tmp[2];
    tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
    tmp[1] = (uint32_t)inputType.get();

    Allocation *constAlloc = Allocation::createAllocation(rsc, inputType.get(),
                              RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS);
    ProgramFragment *pf = new ProgramFragment(rsc, shaderString.string(),
                                              shaderString.length(), tmp, 2);
    pf->bindAllocation(rsc, constAlloc, 0);
    pf->setConstantColor(rsc, 1.0f, 1.0f, 1.0f, 1.0f);

    mDefault.set(pf);
}
开发者ID:10x-Amin,项目名称:frameworks_base,代码行数:29,代码来源:rsProgramFragment.cpp

示例7: main

void ProgramFragmentState::init(Context *rsc) {
    const char *shaderString =
            RS_SHADER_INTERNAL
            "varying lowp vec4 varColor;\n"
            "varying vec2 varTex0;\n"
            "void main() {\n"
            "  lowp vec4 col = UNI_Color;\n"
            "  gl_FragColor = col;\n"
            "}\n";

    ObjectBaseRef<const Element> colorElem = Element::createRef(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 4);

    const char *enames[] = { "Color" };
    const Element *eins[] = {colorElem.get()};
    ObjectBaseRef<const Element> constInput = Element::create(rsc, 1, eins, enames);

    ObjectBaseRef<Type> inputType = Type::getTypeRef(rsc, constInput.get(), 1);

    uintptr_t tmp[2];
    tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
    tmp[1] = (uintptr_t)inputType.get();

    Allocation *constAlloc = Allocation::createAllocation(rsc, inputType.get(),
                              RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS);
    ProgramFragment *pf = new ProgramFragment(rsc, shaderString, strlen(shaderString),
                                              nullptr, 0, nullptr, tmp, 2);
    pf->bindAllocation(rsc, constAlloc, 0);
    pf->setConstantColor(rsc, 1.0f, 1.0f, 1.0f, 1.0f);

    mDefault.set(pf);
}
开发者ID:cpflayan,项目名称:android_frameworks_rs-dt,代码行数:31,代码来源:rsProgramFragment.cpp

示例8: new

ObjectBaseRef<Sampler> Sampler::getSampler(Context *rsc,
                                           RsSamplerValue magFilter,
                                           RsSamplerValue minFilter,
                                           RsSamplerValue wrapS,
                                           RsSamplerValue wrapT,
                                           RsSamplerValue wrapR,
                                           float aniso) {
    ObjectBaseRef<Sampler> returnRef;
    ObjectBase::asyncLock();
    for (uint32_t ct = 0; ct < rsc->mStateSampler.mAllSamplers.size(); ct++) {
        Sampler *existing = rsc->mStateSampler.mAllSamplers[ct];
        if (existing->mHal.state.magFilter != magFilter) continue;
        if (existing->mHal.state.minFilter != minFilter ) continue;
        if (existing->mHal.state.wrapS != wrapS) continue;
        if (existing->mHal.state.wrapT != wrapT) continue;
        if (existing->mHal.state.wrapR != wrapR) continue;
        if (existing->mHal.state.aniso != aniso) continue;
        returnRef.set(existing);
        ObjectBase::asyncUnlock();
        return returnRef;
    }
    ObjectBase::asyncUnlock();

    void* allocMem = rsc->mHal.funcs.allocRuntimeMem(sizeof(Sampler), 0);
    if (!allocMem) {
        rsc->setError(RS_ERROR_FATAL_DRIVER, "Couldn't allocate memory for Allocation");
        return NULL;
    }

    Sampler *s = new (allocMem) Sampler(rsc, magFilter, minFilter, wrapS, wrapT, wrapR, aniso);
    returnRef.set(s);

#ifdef RS_FIND_OFFSETS
    ALOGE("pointer for sampler: %p", s);
    ALOGE("pointer for sampler.drv: %p", &s->mHal.drv);
#endif

    ObjectBase::asyncLock();
    rsc->mStateSampler.mAllSamplers.push(s);
    ObjectBase::asyncUnlock();

    return returnRef;
}
开发者ID:SundownerROM,项目名称:frameworks_rs,代码行数:43,代码来源:rsSampler.cpp

示例9: ProgramRaster

ObjectBaseRef<ProgramRaster> ProgramRaster::getProgramRaster(Context *rsc,
                                                             bool pointSprite,
                                                             RsCullMode cull) {
    ObjectBaseRef<ProgramRaster> returnRef;
    ObjectBase::asyncLock();
    for (uint32_t ct = 0; ct < rsc->mStateRaster.mRasterPrograms.size(); ct++) {
        ProgramRaster *existing = rsc->mStateRaster.mRasterPrograms[ct];
        if (existing->mHal.state.pointSprite != pointSprite) continue;
        if (existing->mHal.state.cull != cull) continue;
        returnRef.set(existing);
        ObjectBase::asyncUnlock();
        return returnRef;
    }
    ObjectBase::asyncUnlock();

    ProgramRaster *pr = new ProgramRaster(rsc, pointSprite, cull);
    returnRef.set(pr);

    ObjectBase::asyncLock();
    rsc->mStateRaster.mRasterPrograms.push(pr);
    ObjectBase::asyncUnlock();

    return returnRef;
}
开发者ID:cpflayan,项目名称:android_frameworks_rs-dt,代码行数:24,代码来源:rsProgramRaster.cpp

示例10: initVertexArrayBuffers

// Avoid having to reallocate memory and render quad by quad
void FontState::initVertexArrayBuffers() {
    // Now lets write index data
    ObjectBaseRef<const Element> indexElem = Element::createRef(mRSC, RS_TYPE_UNSIGNED_16, RS_KIND_USER, false, 1);
    ObjectBaseRef<Type> indexType = Type::getTypeRef(mRSC, indexElem.get(), mMaxNumberOfQuads * 6);

    Allocation *indexAlloc = Allocation::createAllocation(mRSC, indexType.get(),
                                                          RS_ALLOCATION_USAGE_SCRIPT |
                                                          RS_ALLOCATION_USAGE_GRAPHICS_VERTEX);
    uint16_t *indexPtr = (uint16_t*)mRSC->mHal.funcs.allocation.lock1D(mRSC, indexAlloc);

    // Four verts, two triangles , six indices per quad
    for (uint32_t i = 0; i < mMaxNumberOfQuads; i ++) {
        int32_t i6 = i * 6;
        int32_t i4 = i * 4;

        indexPtr[i6 + 0] = i4 + 0;
        indexPtr[i6 + 1] = i4 + 1;
        indexPtr[i6 + 2] = i4 + 2;

        indexPtr[i6 + 3] = i4 + 0;
        indexPtr[i6 + 4] = i4 + 2;
        indexPtr[i6 + 5] = i4 + 3;
    }

    indexAlloc->sendDirty(mRSC);

    ObjectBaseRef<const Element> posElem = Element::createRef(mRSC, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 3);
    ObjectBaseRef<const Element> texElem = Element::createRef(mRSC, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 2);

    const char *ebn1[] = { "position", "texture0" };
    const Element *ebe1[] = {posElem.get(), texElem.get()};
    ObjectBaseRef<const Element> vertexDataElem = Element::create(mRSC, 2, ebe1, ebn1);

    ObjectBaseRef<Type> vertexDataType = Type::getTypeRef(mRSC, vertexDataElem.get(), mMaxNumberOfQuads * 4);

    Allocation *vertexAlloc = Allocation::createAllocation(mRSC, vertexDataType.get(),
                                                           RS_ALLOCATION_USAGE_SCRIPT);
    mTextMeshPtr = (float*)mRSC->mHal.funcs.allocation.lock1D(mRSC, vertexAlloc);

    mMesh.set(new Mesh(mRSC, 1, 1));
    mMesh->setVertexBuffer(vertexAlloc, 0);
    mMesh->setPrimitive(indexAlloc, RS_PRIMITIVE_TRIANGLE, 0);
    mMesh->init();
    mRSC->mHal.funcs.allocation.unlock1D(mRSC, indexAlloc);
    mRSC->mHal.funcs.allocation.unlock1D(mRSC, vertexAlloc);
}
开发者ID:electrikjesus,项目名称:aosp_android_frameworks_rs,代码行数:47,代码来源:rsFont.cpp

示例11: initTextTexture

void FontState::initTextTexture() {
    ObjectBaseRef<const Element> alphaElem = Element::createRef(mRSC, RS_TYPE_UNSIGNED_8,
                                                                RS_KIND_PIXEL_A, true, 1);

    // We will allocate a texture to initially hold 32 character bitmaps
    mCacheHeight = 256;
    mCacheWidth = 1024;
    ObjectBaseRef<Type> texType = Type::getTypeRef(mRSC, alphaElem.get(), mCacheWidth, mCacheHeight);

    mCacheBuffer = new uint8_t[mCacheWidth * mCacheHeight];


    Allocation *cacheAlloc = Allocation::createAllocation(mRSC, texType.get(),
                                RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE);
    mTextTexture.set(cacheAlloc);

    // Split up our cache texture into lines of certain widths
    int32_t nextLine = 0;
    mCacheLines.push(new CacheTextureLine(16, texType->getDimX(), nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(24, texType->getDimX(), nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(24, texType->getDimX(), nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(32, texType->getDimX(), nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(32, texType->getDimX(), nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(40, texType->getDimX(), nextLine, 0));
    nextLine += mCacheLines.top()->mMaxHeight;
    mCacheLines.push(new CacheTextureLine(texType->getDimY() - nextLine, texType->getDimX(), nextLine, 0));
}
开发者ID:electrikjesus,项目名称:aosp_android_frameworks_rs,代码行数:32,代码来源:rsFont.cpp

示例12: init

void ProgramVertexState::init(Context *rsc) {
    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);

    const char *ebn1[] = { "MV", "P", "TexMatrix", "MVP" };
    const Element *ebe1[] = {matrixElem.get(), matrixElem.get(),
            matrixElem.get(), matrixElem.get()};
    ObjectBaseRef<const Element> constInput = Element::create(rsc, 4, ebe1, ebn1);

    const char *ebn2[] = { "position", "color", "normal", "texture0" };
    const Element *ebe2[] = {f4Elem.get(), f4Elem.get(), f3Elem.get(), f2Elem.get()};
    ObjectBaseRef<const Element> attrElem = Element::create(rsc, 4, ebe2, ebn2);

    ObjectBaseRef<Type> inputType = Type::getTypeRef(rsc, constInput.get(), 1, 0, 0, false, false, 0);

    const char *shaderString =
            RS_SHADER_INTERNAL
            "varying vec4 varColor;\n"
            "varying vec2 varTex0;\n"
            "void main() {\n"
            "  gl_Position = UNI_MVP * ATTRIB_position;\n"
            "  gl_PointSize = 1.0;\n"
            "  varColor = ATTRIB_color;\n"
            "  varTex0 = ATTRIB_texture0;\n"
            "}\n";

    uintptr_t tmp[4];
    tmp[0] = RS_PROGRAM_PARAM_CONSTANT;
    tmp[1] = (uintptr_t)inputType.get();
    tmp[2] = RS_PROGRAM_PARAM_INPUT;
    tmp[3] = (uintptr_t)attrElem.get();

    ProgramVertex *pv = new ProgramVertex(rsc, shaderString, strlen(shaderString),
                                          NULL, 0, NULL, tmp, 4);
    Allocation *alloc = Allocation::createAllocation(rsc, inputType.get(),
                              RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS);
    pv->bindAllocation(rsc, alloc, 0);

    mDefaultAlloc.set(alloc);
    mDefault.set(pv);

    updateSize(rsc);
}
开发者ID:DroidSim,项目名称:platform_frameworks_rs,代码行数:49,代码来源:rsProgramVertex.cpp

示例13: rsi_ProgramRasterCreate

RsProgramRaster rsi_ProgramRasterCreate(Context * rsc, bool pointSprite, RsCullMode cull) {
    ObjectBaseRef<ProgramRaster> pr = ProgramRaster::getProgramRaster(rsc, pointSprite, cull);
    pr->incUserRef();
    return pr.get();
}
开发者ID:cpflayan,项目名称:android_frameworks_rs-dt,代码行数:5,代码来源:rsProgramRaster.cpp


注:本文中的ObjectBaseRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。