本文整理汇总了C++中Allocation::getPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ Allocation::getPtr方法的具体用法?C++ Allocation::getPtr怎么用?C++ Allocation::getPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Allocation
的用法示例。
在下文中一共展示了Allocation::getPtr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rsi_AllocationCopyToBitmap
void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) {
Allocation *texAlloc = static_cast<Allocation *>(va);
const Type * t = texAlloc->getType();
size_t s = t->getDimX() * t->getDimY() * t->getElementSizeBytes();
if (s != dataLen) {
rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size");
return;
}
memcpy(data, texAlloc->getPtr(), s);
}
示例2: setupUserConstants
void RsdShader::setupUserConstants(const Context *rsc, RsdShaderCache *sc, bool isFragment) {
uint32_t uidx = 0;
for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) {
Allocation *alloc = mRSProgram->mHal.state.constants[ct];
if (!alloc) {
LOGE("Attempting to set constants on shader id %u, but alloc at slot %u is not set",
(uint32_t)this, ct);
rsc->setError(RS_ERROR_BAD_SHADER, "No constant allocation bound");
continue;
}
const uint8_t *data = static_cast<const uint8_t *>(alloc->getPtr());
const Element *e = mRSProgram->mHal.state.constantTypes[ct]->getElement();
for (uint32_t field=0; field < e->getFieldCount(); field++) {
const Element *f = e->getField(field);
const char *fieldName = e->getFieldName(field);
// If this field is padding, skip it
if (fieldName[0] == '#') {
continue;
}
uint32_t offset = e->getFieldOffsetBytes(field);
const float *fd = reinterpret_cast<const float *>(&data[offset]);
int32_t slot = -1;
uint32_t arraySize = 1;
if (!isFragment) {
slot = sc->vtxUniformSlot(uidx);
arraySize = sc->vtxUniformSize(uidx);
} else {
slot = sc->fragUniformSlot(uidx);
arraySize = sc->fragUniformSize(uidx);
}
if (rsc->props.mLogShadersUniforms) {
LOGV("Uniform slot=%i, offset=%i, constant=%i, field=%i, uidx=%i, name=%s",
slot, offset, ct, field, uidx, fieldName);
}
uidx ++;
if (slot < 0) {
continue;
}
if (rsc->props.mLogShadersUniforms) {
logUniform(f, fd, arraySize);
}
setUniform(rsc, f, fd, slot, arraySize);
}
}
}
示例3: rsi_AllocationCreateFromBitmap
RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, RsType vtype,
RsAllocationMipmapControl mips,
const void *data, size_t data_length, uint32_t usages) {
Type *t = static_cast<Type *>(vtype);
RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, vtype, mips, usages);
Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
if (texAlloc == NULL) {
ALOGE("Memory allocation failure");
return NULL;
}
memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes());
if (mips == RS_ALLOCATION_MIPMAP_FULL) {
AllocationGenerateScriptMips(rsc, texAlloc);
}
texAlloc->sendDirty(rsc);
return texAlloc;
}