本文整理汇总了C++中GrRect::offset方法的典型用法代码示例。如果您正苦于以下问题:C++ GrRect::offset方法的具体用法?C++ GrRect::offset怎么用?C++ GrRect::offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrRect
的用法示例。
在下文中一共展示了GrRect::offset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createAlphaClipMask
////////////////////////////////////////////////////////////////////////////////
// Create a 8-bit clip mask in alpha
GrTexture* GrClipMaskManager::createAlphaClipMask(int32_t clipStackGenID,
InitialState initialState,
const ElementList& elements,
const SkIRect& clipSpaceIBounds) {
GrAssert(kNone_ClipMaskType == fCurrClipMaskType);
GrTexture* result;
if (this->getMaskTexture(clipStackGenID, clipSpaceIBounds, &result)) {
fCurrClipMaskType = kAlpha_ClipMaskType;
return result;
}
if (NULL == result) {
fAACache.reset();
return NULL;
}
GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_ASRInit);
GrDrawState* drawState = fGpu->drawState();
// The top-left of the mask corresponds to the top-left corner of the bounds.
SkVector clipToMaskOffset = {
SkIntToScalar(-clipSpaceIBounds.fLeft),
SkIntToScalar(-clipSpaceIBounds.fTop)
};
// The texture may be larger than necessary, this rect represents the part of the texture
// we populate with a rasterization of the clip.
SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpaceIBounds.height());
// We're drawing a coverage mask and want coverage to be run through the blend function.
drawState->enableState(GrDrawState::kCoverageDrawing_StateBit);
// Set the matrix so that rendered clip elements are transformed to mask space from clip space.
drawState->viewMatrix()->setTranslate(clipToMaskOffset);
// The scratch texture that we are drawing into can be substantially larger than the mask. Only
// clear the part that we care about.
fGpu->clear(&maskSpaceIBounds,
kAllIn_InitialState == initialState ? 0xffffffff : 0x00000000,
result->asRenderTarget());
// When we use the stencil in the below loop it is important to have this clip installed.
// The second pass that zeros the stencil buffer renders the rect maskSpaceIBounds so the first
// pass must not set values outside of this bounds or stencil values outside the rect won't be
// cleared.
GrDrawTarget::AutoClipRestore acr(fGpu, maskSpaceIBounds);
drawState->enableState(GrDrawState::kClip_StateBit);
GrAutoScratchTexture temp;
// walk through each clip element and perform its set op
for (ElementList::Iter iter = elements.headIter(); iter.get(); iter.next()) {
const Element* element = iter.get();
SkRegion::Op op = element->getOp();
bool invert = element->isInverseFilled();
if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) {
GrPathRenderer* pr = NULL;
bool useTemp = !this->canStencilAndDrawElement(result, element, &pr);
GrTexture* dst;
// This is the bounds of the clip element in the space of the alpha-mask. The temporary
// mask buffer can be substantially larger than the actually clip stack element. We
// touch the minimum number of pixels necessary and use decal mode to combine it with
// the accumulator.
GrIRect maskSpaceElementIBounds;
if (useTemp) {
if (invert) {
maskSpaceElementIBounds = maskSpaceIBounds;
} else {
GrRect elementBounds = element->getBounds();
elementBounds.offset(clipToMaskOffset);
elementBounds.roundOut(&maskSpaceElementIBounds);
}
this->getTemp(maskSpaceIBounds.fRight, maskSpaceIBounds.fBottom, &temp);
if (NULL == temp.texture()) {
fAACache.reset();
return NULL;
}
dst = temp.texture();
// clear the temp target and set blend to replace
fGpu->clear(&maskSpaceElementIBounds,
invert ? 0xffffffff : 0x00000000,
dst->asRenderTarget());
setup_boolean_blendcoeffs(drawState, SkRegion::kReplace_Op);
} else {
// draw directly into the result with the stencil set to make the pixels affected
// by the clip shape be non-zero.
dst = result;
GR_STATIC_CONST_SAME_STENCIL(kStencilInElement,
kReplace_StencilOp,
kReplace_StencilOp,
kAlways_StencilFunc,
0xffff,
0xffff,
0xffff);
drawState->setStencil(kStencilInElement);
//.........这里部分代码省略.........
示例2: onDrawPath
//.........这里部分代码省略.........
case kWinding_PathFill:
if (fSeparateStencil) {
if (fStencilWrapOps) {
passes[0] = &gWindStencilSeparateWithWrap;
} else {
passes[0] = &gWindStencilSeparateNoWrap;
}
passCount = 2;
drawFace[0] = GrDrawTarget::kBoth_DrawFace;
} else {
if (fStencilWrapOps) {
passes[0] = &gWindSingleStencilWithWrapInc;
passes[1] = &gWindSingleStencilWithWrapDec;
} else {
passes[0] = &gWindSingleStencilNoWrapInc;
passes[1] = &gWindSingleStencilNoWrapDec;
}
// which is cw and which is ccw is arbitrary.
drawFace[0] = GrDrawTarget::kCW_DrawFace;
drawFace[1] = GrDrawTarget::kCCW_DrawFace;
passCount = 3;
}
if (stencilOnly) {
lastPassIsBounds = false;
--passCount;
} else {
lastPassIsBounds = true;
drawFace[passCount-1] = GrDrawTarget::kBoth_DrawFace;
if (reverse) {
passes[passCount-1] = &gInvWindColorPass;
} else {
passes[passCount-1] = &gWindColorPass;
}
}
break;
default:
GrAssert(!"Unknown path fFill!");
return;
}
}
}
{
for (int p = 0; p < passCount; ++p) {
fTarget->setDrawFace(drawFace[p]);
if (NULL != passes[p]) {
fTarget->setStencil(*passes[p]);
}
if (lastPassIsBounds && (p == passCount-1)) {
if (!colorWritesWereDisabled) {
fTarget->disableState(GrDrawTarget::kNoColorWrites_StateBit);
}
GrRect bounds;
if (reverse) {
GrAssert(NULL != fTarget->getRenderTarget());
// draw over the whole world.
bounds.setLTRB(0, 0,
GrIntToScalar(fTarget->getRenderTarget()->width()),
GrIntToScalar(fTarget->getRenderTarget()->height()));
GrMatrix vmi;
// mapRect through persp matrix may not be correct
if (!fTarget->getViewMatrix().hasPerspective() &&
fTarget->getViewInverse(&vmi)) {
vmi.mapRect(&bounds);
} else {
if (stages) {
if (!fTarget->getViewInverse(&vmi)) {
GrPrintf("Could not invert matrix.");
return;
}
fTarget->preConcatSamplerMatrices(stages, vmi);
}
fTarget->setViewMatrix(GrMatrix::I());
}
} else {
bounds = fPath->getBounds();
bounds.offset(fTranslate);
}
GrDrawTarget::AutoGeometryPush agp(fTarget);
fTarget->drawSimpleRect(bounds, NULL, stages);
} else {
if (passCount > 1) {
fTarget->enableState(GrDrawTarget::kNoColorWrites_StateBit);
}
if (fUseIndexedDraw) {
fTarget->drawIndexed(fPrimitiveType, 0, 0,
fVertexCnt, fIndexCnt);
} else {
int baseVertex = 0;
for (int sp = 0; sp < fSubpathCount; ++sp) {
fTarget->drawNonIndexed(fPrimitiveType, baseVertex,
fSubpathVertCount[sp]);
baseVertex += fSubpathVertCount[sp];
}
}
}
}
}
}
示例3: createAlphaClipMask
////////////////////////////////////////////////////////////////////////////////
// Create a 8-bit clip mask in alpha
bool GrClipMaskManager::createAlphaClipMask(const GrClipData& clipDataIn,
GrTexture** result,
GrIRect *devResultBounds) {
GrAssert(NULL != devResultBounds);
GrAssert(kNone_ClipMaskType == fCurrClipMaskType);
if (this->clipMaskPreamble(clipDataIn, result, devResultBounds)) {
fCurrClipMaskType = kAlpha_ClipMaskType;
return true;
}
// Note: 'resultBounds' is in device (as opposed to canvas) coordinates
GrTexture* accum = fAACache.getLastMask();
if (NULL == accum) {
fAACache.reset();
return false;
}
GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
GrDrawState* drawState = fGpu->drawState();
GrDrawTarget::AutoGeometryPush agp(fGpu);
// The mask we generate is translated so that its upper-left corner is at devResultBounds
// upper-left corner in device space.
GrIRect maskResultBounds = GrIRect::MakeWH(devResultBounds->width(), devResultBounds->height());
// Set the matrix so that rendered clip elements are transformed from the space of the clip
// stack to the alpha-mask. This accounts for both translation due to the clip-origin and the
// placement of the mask within the device.
SkVector clipToMaskOffset = {
SkIntToScalar(-devResultBounds->fLeft - clipDataIn.fOrigin.fX),
SkIntToScalar(-devResultBounds->fTop - clipDataIn.fOrigin.fY)
};
drawState->viewMatrix()->setTranslate(clipToMaskOffset);
bool clearToInside;
SkRegion::Op firstOp = SkRegion::kReplace_Op; // suppress warning
SkClipStack::Iter iter(*clipDataIn.fClipStack,
SkClipStack::Iter::kBottom_IterStart);
const SkClipStack::Iter::Clip* clip = process_initial_clip_elements(&iter,
*devResultBounds,
&clearToInside,
&firstOp,
clipDataIn);
// The scratch texture that we are drawing into can be substantially larger than the mask. Only
// clear the part that we care about.
fGpu->clear(&maskResultBounds,
clearToInside ? 0xffffffff : 0x00000000,
accum->asRenderTarget());
bool accumClearedToZero = !clearToInside;
GrAutoScratchTexture temp;
bool first = true;
// walk through each clip element and perform its set op
for ( ; NULL != clip; clip = iter.nextCombined()) {
SkRegion::Op op = clip->fOp;
if (first) {
first = false;
op = firstOp;
}
if (SkRegion::kReplace_Op == op) {
// clear the accumulator and draw the new object directly into it
if (!accumClearedToZero) {
fGpu->clear(&maskResultBounds, 0x00000000, accum->asRenderTarget());
}
setup_boolean_blendcoeffs(drawState, op);
this->drawClipShape(accum, clip, *devResultBounds);
} else if (SkRegion::kReverseDifference_Op == op ||
SkRegion::kIntersect_Op == op) {
// there is no point in intersecting a screen filling rectangle.
if (SkRegion::kIntersect_Op == op && NULL != clip->fRect &&
contains(*clip->fRect, *devResultBounds, clipDataIn.fOrigin)) {
continue;
}
getTemp(*devResultBounds, &temp);
if (NULL == temp.texture()) {
fAACache.reset();
return false;
}
// this is the bounds of the clip element in the space of the alpha-mask. The temporary
// mask buffer can be substantially larger than the actually clip stack element. We
// touch the minimum number of pixels necessary and use decal mode to combine it with
// the accumulator
GrRect elementMaskBounds = clip->getBounds();
elementMaskBounds.offset(clipToMaskOffset);
GrIRect elementMaskIBounds;
elementMaskBounds.roundOut(&elementMaskIBounds);
// clear the temp target & draw into it
//.........这里部分代码省略.........