本文整理汇总了C++中GrMatrix::hasPerspective方法的典型用法代码示例。如果您正苦于以下问题:C++ GrMatrix::hasPerspective方法的具体用法?C++ GrMatrix::hasPerspective怎么用?C++ GrMatrix::hasPerspective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrMatrix
的用法示例。
在下文中一共展示了GrMatrix::hasPerspective方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TextureMatrixOptFlags
int GrGpuGL::TextureMatrixOptFlags(const GrGLTexture* texture,
const GrEffectStage& stage) {
GrAssert(NULL != texture);
GrMatrix matrix;
stage.getTotalMatrix(&matrix);
bool canBeIndentity = GrSurface::kTopLeft_Origin == texture->origin();
if (canBeIndentity && matrix.isIdentity()) {
return GrGLProgram::StageDesc::kIdentityMatrix_OptFlagBit;
} else if (!matrix.hasPerspective()) {
return GrGLProgram::StageDesc::kNoPerspective_OptFlagBit;
}
return 0;
}
示例2: createGeom
bool GrAAHairLinePathRenderer::createGeom(GrDrawTarget::StageBitfield stages) {
int rtHeight = fTarget->getRenderTarget()->height();
GrIRect clip;
if (fTarget->getClip().hasConservativeBounds()) {
GrRect clipRect = fTarget->getClip().getConservativeBounds();
clipRect.roundOut(&clip);
} else {
clip.setLargest();
}
// If none of the inputs that affect generation of path geometry have
// have changed since last previous path draw then we can reuse the
// previous geoemtry.
if (stages == fPreviousStages &&
fPreviousViewMatrix == fTarget->getViewMatrix() &&
fPreviousTranslate == fTranslate &&
rtHeight == fPreviousRTHeight &&
fClipRect == clip) {
return true;
}
GrVertexLayout layout = GrDrawTarget::kEdge_VertexLayoutBit;
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if ((1 << s) & stages) {
layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(s);
}
}
GrMatrix viewM = fTarget->getViewMatrix();
PREALLOC_PTARRAY(128) lines;
PREALLOC_PTARRAY(128) quads;
IntArray qSubdivs;
fQuadCnt = generate_lines_and_quads(*fPath, viewM, fTranslate, clip,
&lines, &quads, &qSubdivs);
fLineSegmentCnt = lines.count() / 2;
int vertCnt = kVertsPerLineSeg * fLineSegmentCnt + kVertsPerQuad * fQuadCnt;
GrAssert(sizeof(Vertex) == GrDrawTarget::VertexSize(layout));
Vertex* verts;
if (!fTarget->reserveVertexSpace(layout, vertCnt, (void**)&verts)) {
return false;
}
Vertex* base = verts;
const GrMatrix* toDevice = NULL;
const GrMatrix* toSrc = NULL;
GrMatrix ivm;
if (viewM.hasPerspective()) {
if (viewM.invert(&ivm)) {
toDevice = &viewM;
toSrc = &ivm;
}
}
for (int i = 0; i < fLineSegmentCnt; ++i) {
add_line(&lines[2*i], rtHeight, toSrc, &verts);
}
int unsubdivQuadCnt = quads.count() / 3;
for (int i = 0; i < unsubdivQuadCnt; ++i) {
GrAssert(qSubdivs[i] >= 0);
add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts);
}
fPreviousStages = stages;
fPreviousViewMatrix = fTarget->getViewMatrix();
fPreviousRTHeight = rtHeight;
fClipRect = clip;
fPreviousTranslate = fTranslate;
return true;
}
示例3: onDrawPath
bool GrAAConvexPathRenderer::onDrawPath(const SkPath& origPath,
GrPathFill fill,
const GrVec* translate,
GrDrawTarget* target,
GrDrawState::StageMask stageMask,
bool antiAlias) {
const SkPath* path = &origPath;
if (path->isEmpty()) {
return true;
}
GrDrawTarget::AutoStateRestore asr(target,
GrDrawTarget::kPreserve_ASRInit);
GrDrawState* drawState = target->drawState();
GrMatrix vm = drawState->getViewMatrix();
if (NULL != translate) {
vm.postTranslate(translate->fX, translate->fY);
}
GrMatrix ivm;
if (vm.invert(&ivm)) {
drawState->preConcatSamplerMatrices(stageMask, ivm);
}
drawState->viewMatrix()->reset();
GrVertexLayout layout = 0;
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
if ((1 << s) & stageMask) {
layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(s);
}
}
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.reset();
}
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);
drawState->setVertexEdgeType(GrDrawState::kQuad_EdgeType);
target->drawIndexed(kTriangles_PrimitiveType,
0, // start vertex
0, // start index
vCount,
iCount);
return true;
}
示例4: createGeom
bool GrAAHairLinePathRenderer::createGeom(
const SkPath& path,
const GrVec* translate,
GrDrawTarget* target,
GrDrawState::StageMask stageMask,
int* lineCnt,
int* quadCnt,
GrDrawTarget::AutoReleaseGeometry* arg) {
const GrDrawState& drawState = target->getDrawState();
int rtHeight = drawState.getRenderTarget()->height();
GrIRect clip;
if (target->getClip().hasConservativeBounds()) {
GrRect clipRect = target->getClip().getConservativeBounds();
clipRect.roundOut(&clip);
} else {
clip.setLargest();
}
GrVertexLayout layout = GrDrawTarget::kEdge_VertexLayoutBit;
GrMatrix viewM = drawState.getViewMatrix();
PREALLOC_PTARRAY(128) lines;
PREALLOC_PTARRAY(128) quads;
IntArray qSubdivs;
static const GrVec gZeroVec = {0, 0};
if (NULL == translate) {
translate = &gZeroVec;
}
*quadCnt = generate_lines_and_quads(path, viewM, *translate, clip,
&lines, &quads, &qSubdivs);
*lineCnt = lines.count() / 2;
int vertCnt = kVertsPerLineSeg * *lineCnt + kVertsPerQuad * *quadCnt;
GrAssert(sizeof(Vertex) == GrDrawTarget::VertexSize(layout));
if (!arg->set(target, layout, vertCnt, 0)) {
return false;
}
Vertex* verts = reinterpret_cast<Vertex*>(arg->vertices());
const GrMatrix* toDevice = NULL;
const GrMatrix* toSrc = NULL;
GrMatrix ivm;
if (viewM.hasPerspective()) {
if (viewM.invert(&ivm)) {
toDevice = &viewM;
toSrc = &ivm;
}
}
for (int i = 0; i < *lineCnt; ++i) {
add_line(&lines[2*i], rtHeight, toSrc, &verts);
}
int unsubdivQuadCnt = quads.count() / 3;
for (int i = 0; i < unsubdivQuadCnt; ++i) {
GrAssert(qSubdivs[i] >= 0);
add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts);
}
return true;
}