本文整理汇总了C++中GrMesh::initInstanced方法的典型用法代码示例。如果您正苦于以下问题:C++ GrMesh::initInstanced方法的具体用法?C++ GrMesh::initInstanced怎么用?C++ GrMesh::initInstanced使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrMesh
的用法示例。
在下文中一共展示了GrMesh::initInstanced方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flush
void GrAtlasTextBatch::flush(GrVertexBatch::Target* target, FlushInfo* flushInfo) const {
GrMesh mesh;
int maxGlyphsPerDraw =
static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6);
mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer,
flushInfo->fIndexBuffer, flushInfo->fVertexOffset,
kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
maxGlyphsPerDraw);
target->draw(flushInfo->fGeometryProcessor.get(), mesh);
flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
flushInfo->fGlyphsToFlush = 0;
}
示例2: onPrepareDraws
void AAHairlineOp::onPrepareDraws(Target* target) const {
// Setup the viewmatrix and localmatrix for the GrGeometryProcessor.
SkMatrix invert;
if (!this->viewMatrix().invert(&invert)) {
return;
}
// we will transform to identity space if the viewmatrix does not have perspective
bool hasPerspective = this->viewMatrix().hasPerspective();
const SkMatrix* geometryProcessorViewM = &SkMatrix::I();
const SkMatrix* geometryProcessorLocalM = &invert;
const SkMatrix* toDevice = nullptr;
const SkMatrix* toSrc = nullptr;
if (hasPerspective) {
geometryProcessorViewM = &this->viewMatrix();
geometryProcessorLocalM = &SkMatrix::I();
toDevice = &this->viewMatrix();
toSrc = &invert;
}
// This is hand inlined for maximum performance.
PREALLOC_PTARRAY(128) lines;
PREALLOC_PTARRAY(128) quads;
PREALLOC_PTARRAY(128) conics;
IntArray qSubdivs;
FloatArray cWeights;
int quadCount = 0;
int instanceCount = fPaths.count();
for (int i = 0; i < instanceCount; i++) {
const PathData& args = fPaths[i];
quadCount += gather_lines_and_quads(args.fPath, args.fViewMatrix, args.fDevClipBounds,
&lines, &quads, &conics, &qSubdivs, &cWeights);
}
int lineCount = lines.count() / 2;
int conicCount = conics.count() / 3;
// do lines first
if (lineCount) {
sk_sp<GrGeometryProcessor> lineGP;
{
using namespace GrDefaultGeoProcFactory;
Color color(this->color());
LocalCoords localCoords(this->usesLocalCoords() ? LocalCoords::kUsePosition_Type :
LocalCoords::kUnused_Type);
localCoords.fMatrix = geometryProcessorLocalM;
lineGP = GrDefaultGeoProcFactory::Make(color, Coverage::kAttribute_Type, localCoords,
*geometryProcessorViewM);
}
sk_sp<const GrBuffer> linesIndexBuffer(
ref_lines_index_buffer(target->resourceProvider()));
const GrBuffer* vertexBuffer;
int firstVertex;
size_t vertexStride = lineGP->getVertexStride();
int vertexCount = kLineSegNumVertices * lineCount;
LineVertex* verts = reinterpret_cast<LineVertex*>(
target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex));
if (!verts|| !linesIndexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex));
for (int i = 0; i < lineCount; ++i) {
add_line(&lines[2*i], toSrc, this->coverage(), &verts);
}
GrMesh mesh;
mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIndexBuffer.get(),
firstVertex, kLineSegNumVertices, kIdxsPerLineSeg, lineCount,
kLineSegsNumInIdxBuffer);
target->draw(lineGP.get(), this->pipeline(), mesh);
}
if (quadCount || conicCount) {
sk_sp<GrGeometryProcessor> quadGP(
GrQuadEffect::Make(this->color(),
*geometryProcessorViewM,
kHairlineAA_GrProcessorEdgeType,
target->caps(),
*geometryProcessorLocalM,
this->usesLocalCoords(),
this->coverage()));
sk_sp<GrGeometryProcessor> conicGP(
GrConicEffect::Make(this->color(),
*geometryProcessorViewM,
kHairlineAA_GrProcessorEdgeType,
target->caps(),
*geometryProcessorLocalM,
this->usesLocalCoords(),
this->coverage()));
//.........这里部分代码省略.........