本文整理汇总了C++中GrDrawState::stage方法的典型用法代码示例。如果您正苦于以下问题:C++ GrDrawState::stage方法的具体用法?C++ GrDrawState::stage怎么用?C++ GrDrawState::stage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrDrawState
的用法示例。
在下文中一共展示了GrDrawState::stage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mergeMask
void GrClipMaskManager::mergeMask(GrTexture* dstMask,
GrTexture* srcMask,
SkRegion::Op op,
const GrIRect& dstBound,
const GrIRect& srcBound) {
GrDrawState* drawState = fGpu->drawState();
GrAssert(NULL != drawState);
SkMatrix oldMatrix = drawState->getViewMatrix();
drawState->viewMatrix()->reset();
drawState->setRenderTarget(dstMask->asRenderTarget());
setup_boolean_blendcoeffs(drawState, op);
SkMatrix sampleM;
sampleM.setIDiv(srcMask->width(), srcMask->height());
drawState->stage(0)->setEffect(
GrTextureDomainEffect::Create(srcMask,
sampleM,
GrTextureDomainEffect::MakeTexelDomain(srcMask, srcBound),
GrTextureDomainEffect::kDecal_WrapMode))->unref();
fGpu->drawSimpleRect(SkRect::MakeFromIRect(dstBound), NULL);
drawState->disableStage(0);
drawState->setViewMatrix(oldMatrix);
}
示例2: DrawToTargetWithPathMask
void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
GrDrawTarget* target,
const GrIRect& rect) {
GrDrawState* drawState = target->drawState();
GrDrawState::AutoDeviceCoordDraw adcd(drawState);
if (!adcd.succeeded()) {
return;
}
enum {
// the SW path renderer shares this stage with glyph
// rendering (kGlyphMaskStage in GrBatchedTextContext)
kPathMaskStage = GrPaint::kTotalStages,
};
GrAssert(!drawState->isStageEnabled(kPathMaskStage));
drawState->stage(kPathMaskStage)->reset();
drawState->createTextureEffect(kPathMaskStage, texture);
SkScalar w = SkIntToScalar(rect.width());
SkScalar h = SkIntToScalar(rect.height());
GrRect maskRect = GrRect::MakeWH(w / texture->width(),
h / texture->height());
const GrRect* srcRects[GrDrawState::kNumStages] = { NULL };
srcRects[kPathMaskStage] = &maskRect;
GrRect dstRect = GrRect::MakeLTRB(
SK_Scalar1 * rect.fLeft,
SK_Scalar1 * rect.fTop,
SK_Scalar1 * rect.fRight,
SK_Scalar1 * rect.fBottom);
target->drawRect(dstRect, NULL, srcRects, NULL);
drawState->disableStage(kPathMaskStage);
}
示例3: flushGlyphs
void GrTextContext::flushGlyphs() {
if (NULL == fDrawTarget) {
return;
}
GrDrawState* drawState = fDrawTarget->drawState();
if (fCurrVertex > 0) {
// setup our sampler state for our text texture/atlas
drawState->stage(kGlyphMaskStage)->reset();
GrAssert(GrIsALIGN4(fCurrVertex));
GrAssert(fCurrTexture);
GrTextureParams params(SkShader::kRepeat_TileMode, false);
drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture, SkMatrix::I(), params);
if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) {
if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() ||
fPaint.hasColorStage()) {
GrPrintf("LCD Text will not draw correctly.\n");
}
// setup blend so that we get mask * paintColor + (1-mask)*dstColor
drawState->setBlendConstant(fPaint.getColor());
drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff);
// don't modulate by the paint's color in the frag since we're
// already doing it via the blend const.
drawState->setColor(0xffffffff);
} else {
// set back to normal in case we took LCD path previously.
drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlendCoeff());
drawState->setColor(fPaint.getColor());
}
int nGlyphs = fCurrVertex / 4;
fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType,
nGlyphs,
4, 6);
fDrawTarget->resetVertexSource();
fVertices = NULL;
fMaxVertices = 0;
fCurrVertex = 0;
GrSafeSetNull(fCurrTexture);
}
drawState->disableStages();
fDrawTarget = NULL;
}