本文整理汇总了C++中GrRect::intersectWith方法的典型用法代码示例。如果您正苦于以下问题:C++ GrRect::intersectWith方法的具体用法?C++ GrRect::intersectWith怎么用?C++ GrRect::intersectWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrRect
的用法示例。
在下文中一共展示了GrRect::intersectWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupClipAndFlushState
bool GrGpu::setupClipAndFlushState(GrPrimitiveType type) {
const GrIRect* r = NULL;
GrIRect clipRect;
// we check this early because we need a valid
// render target to setup stencil clipping
// before even going into flushGraphicsState
if (NULL == fCurrDrawState.fRenderTarget) {
GrAssert(!"No render target bound.");
return false;
}
if (fCurrDrawState.fFlagBits & kClip_StateBit) {
GrRenderTarget& rt = *fCurrDrawState.fRenderTarget;
GrRect bounds;
GrRect rtRect;
rtRect.setLTRB(0, 0,
GrIntToScalar(rt.width()), GrIntToScalar(rt.height()));
if (fClip.hasConservativeBounds()) {
bounds = fClip.getConservativeBounds();
bounds.intersectWith(rtRect);
} else {
bounds = rtRect;
}
bounds.roundOut(&clipRect);
if (clipRect.isEmpty()) {
clipRect.setLTRB(0,0,0,0);
}
r = &clipRect;
fClipState.fClipInStencil = !fClip.isRect() &&
!fClip.isEmpty() &&
!bounds.isEmpty();
if (fClipState.fClipInStencil &&
(fClipState.fClipIsDirty ||
fClip != rt.fLastStencilClip)) {
rt.fLastStencilClip = fClip;
// we set the current clip to the bounds so that our recursive
// draws are scissored to them. We use the copy of the complex clip
// in the rt to render
const GrClip& clip = rt.fLastStencilClip;
fClip.setFromRect(bounds);
AutoStateRestore asr(this);
AutoInternalDrawGeomRestore aidgr(this);
this->setViewMatrix(GrMatrix::I());
this->eraseStencilClip(clipRect);
this->flushScissor(NULL);
#if !VISUALIZE_COMPLEX_CLIP
this->enableState(kNoColorWrites_StateBit);
#else
this->disableState(kNoColorWrites_StateBit);
#endif
int count = clip.getElementCount();
int clipBit = rt.stencilBits();
clipBit = (1 << (clipBit-1));
// often we'll see the first two elements of the clip are
// the full rt size and another element intersected with it.
// We can skip the first full-size rect and save a big rect draw.
int firstElement = 0;
if (clip.getElementCount() > 1 &&
kRect_ClipType == clip.getElementType(0) &&
kIntersect_SetOp == clip.getOp(1)&&
clip.getRect(0).contains(bounds)) {
firstElement = 1;
}
// walk through each clip element and perform its set op
// with the existing clip.
for (int c = firstElement; c < count; ++c) {
GrPathFill fill;
// enabled at bottom of loop
this->disableState(kModifyStencilClip_StateBit);
bool canDrawDirectToClip;
if (kRect_ClipType == clip.getElementType(c)) {
canDrawDirectToClip = true;
fill = kEvenOdd_PathFill;
} else {
fill = clip.getPathFill(c);
GrPathRenderer* pr = this->getPathRenderer();
canDrawDirectToClip = pr->requiresStencilPass(this, clip.getPath(c), fill);
}
GrSetOp op = firstElement == c ? kReplace_SetOp : clip.getOp(c);
int passes;
GrStencilSettings stencilSettings[GrStencilSettings::kMaxStencilClipPasses];
canDrawDirectToClip = GrStencilSettings::GetClipPasses(op, canDrawDirectToClip,
clipBit, IsFillInverted(fill),
&passes, stencilSettings);
// draw the element to the client stencil bits if necessary
if (!canDrawDirectToClip) {
//.........这里部分代码省略.........