本文整理汇总了C++中GrDrawState::getVertexEdgeType方法的典型用法代码示例。如果您正苦于以下问题:C++ GrDrawState::getVertexEdgeType方法的具体用法?C++ GrDrawState::getVertexEdgeType怎么用?C++ GrDrawState::getVertexEdgeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrDrawState
的用法示例。
在下文中一共展示了GrDrawState::getVertexEdgeType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDrawPath
bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath,
GrPathFill fill,
GrDrawTarget* target,
bool antiAlias) {
const SkPath* path = &origPath;
if (path->isEmpty()) {
return true;
}
GrDrawState* drawState = target->drawState();
GrDrawState::AutoDeviceCoordDraw adcd(drawState);
if (!adcd.succeeded()) {
return false;
}
const GrMatrix* vm = &adcd.getOriginalMatrix();
GrVertexLayout layout = 0;
layout |= GrDrawTarget::kEdge_VertexLayoutBit;
// We use the fact that SkPath::transform path does subdivision based on
// perspective. Otherwise, we apply the view matrix when copying to the
// segment representation.
SkPath tmpPath;
if (vm->hasPerspective()) {
origPath.transform(*vm, &tmpPath);
path = &tmpPath;
vm = &GrMatrix::I();
}
QuadVertex *verts;
uint16_t* idxs;
int vCount;
int iCount;
enum {
kPreallocSegmentCnt = 512 / sizeof(Segment),
};
SkSTArray<kPreallocSegmentCnt, Segment, true> segments;
SkPoint fanPt;
if (!get_segments(*path, *vm, &segments, &fanPt, &vCount, &iCount)) {
return false;
}
GrDrawTarget::AutoReleaseGeometry arg(target, layout, vCount, iCount);
if (!arg.succeeded()) {
return false;
}
verts = reinterpret_cast<QuadVertex*>(arg.vertices());
idxs = reinterpret_cast<uint16_t*>(arg.indices());
create_vertices(segments, fanPt, verts, idxs);
GrDrawState::VertexEdgeType oldEdgeType = drawState->getVertexEdgeType();
drawState->setVertexEdgeType(GrDrawState::kQuad_EdgeType);
target->drawIndexed(kTriangles_GrPrimitiveType,
0, // start vertex
0, // start index
vCount,
iCount);
drawState->setVertexEdgeType(oldEdgeType);
return true;
}
示例2: onDrawPath
bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path,
const SkStrokeRec&,
GrDrawTarget* target,
bool antiAlias) {
int lineCnt;
int quadCnt;
GrDrawTarget::AutoReleaseGeometry arg;
if (!this->createGeom(path,
target,
&lineCnt,
&quadCnt,
&arg)) {
return false;
}
GrDrawState::AutoDeviceCoordDraw adcd;
GrDrawState* drawState = target->drawState();
// createGeom transforms the geometry to device space when the matrix does not have
// perspective.
if (!drawState->getViewMatrix().hasPerspective()) {
adcd.set(drawState);
if (!adcd.succeeded()) {
return false;
}
}
// TODO: See whether rendering lines as degenerate quads improves perf
// when we have a mix
GrDrawState::VertexEdgeType oldEdgeType = drawState->getVertexEdgeType();
target->setIndexSourceToBuffer(fLinesIndexBuffer);
int lines = 0;
int nBufLines = fLinesIndexBuffer->maxQuads();
drawState->setVertexEdgeType(GrDrawState::kHairLine_EdgeType);
while (lines < lineCnt) {
int n = GrMin(lineCnt - lines, nBufLines);
target->drawIndexed(kTriangles_GrPrimitiveType,
kVertsPerLineSeg*lines, // startV
0, // startI
kVertsPerLineSeg*n, // vCount
kIdxsPerLineSeg*n); // iCount
lines += n;
}
target->setIndexSourceToBuffer(fQuadsIndexBuffer);
int quads = 0;
drawState->setVertexEdgeType(GrDrawState::kHairQuad_EdgeType);
while (quads < quadCnt) {
int n = GrMin(quadCnt - quads, kNumQuadsInIdxBuffer);
target->drawIndexed(kTriangles_GrPrimitiveType,
4 * lineCnt + kVertsPerQuad*quads, // startV
0, // startI
kVertsPerQuad*n, // vCount
kIdxsPerQuad*n); // iCount
quads += n;
}
drawState->setVertexEdgeType(oldEdgeType);
return true;
}