diff options
author | 2012-07-31 19:15:58 +0000 | |
---|---|---|
committer | 2012-07-31 19:15:58 +0000 | |
commit | 641f8b19a6799b6d73ac17b9c2d2f8a5e6f5ad4d (patch) | |
tree | 0c916a12d18cc86343d601811a34229898a8c7f7 /src/gpu/GrInOrderDrawBuffer.cpp | |
parent | 4b2af9c91d39c2176a32e7ba42a0276dca68034a (diff) |
Replace GrClip with SkClipStack
http://codereview.appspot.com/6449070/
git-svn-id: http://skia.googlecode.com/svn/trunk@4865 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrInOrderDrawBuffer.cpp')
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index d5d03cd5cf..9f24c4e7a3 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -125,44 +125,52 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect, // the rect. bool disabledClip = false; - if (drawState->isClipState() && fClip->fClipStack->isRect()) { - - GrClip::Iter iter(*fClip->fClipStack, GrClip::Iter::kBottom_IterStart); - const GrClip::Iter::Clip* clip = iter.next(); - GrAssert(NULL != clip && NULL != clip->fRect); - - GrRect clipRect = *clip->fRect; - // If the clip rect touches the edge of the viewport, extended it - // out (close) to infinity to avoid bogus intersections. - // We might consider a more exact clip to viewport if this - // conservative test fails. - const GrRenderTarget* target = drawState->getRenderTarget(); - if (0 >= clipRect.fLeft) { - clipRect.fLeft = GR_ScalarMin; - } - if (target->width() <= clipRect.fRight) { - clipRect.fRight = GR_ScalarMax; - } - if (0 >= clipRect.top()) { - clipRect.fTop = GR_ScalarMin; - } - if (target->height() <= clipRect.fBottom) { - clipRect.fBottom = GR_ScalarMax; - } - int stride = VertexSize(layout); - bool insideClip = true; - for (int v = 0; v < 4; ++v) { - const GrPoint& p = *GetVertexPoint(geo.vertices(), v, stride); - if (!clipRect.contains(p)) { - insideClip = false; - break; + if (drawState->isClipState()) { + + GrRect devClipRect; + bool isIntersectionOfRects = false; + + fClip->fClipStack->getConservativeBounds(-fClip->fOrigin.fX, + -fClip->fOrigin.fY, + drawState->getRenderTarget()->width(), + drawState->getRenderTarget()->height(), + &devClipRect, + &isIntersectionOfRects); + + if (isIntersectionOfRects) { + // If the clip rect touches the edge of the viewport, extended it + // out (close) to infinity to avoid bogus intersections. + // We might consider a more exact clip to viewport if this + // conservative test fails. + const GrRenderTarget* target = drawState->getRenderTarget(); + if (0 >= devClipRect.fLeft) { + devClipRect.fLeft = GR_ScalarMin; + } + if (target->width() <= devClipRect.fRight) { + devClipRect.fRight = GR_ScalarMax; + } + if (0 >= devClipRect.top()) { + devClipRect.fTop = GR_ScalarMin; + } + if (target->height() <= devClipRect.fBottom) { + devClipRect.fBottom = GR_ScalarMax; + } + int stride = VertexSize(layout); + bool insideClip = true; + for (int v = 0; v < 4; ++v) { + const GrPoint& p = *GetVertexPoint(geo.vertices(), v, stride); + if (!devClipRect.contains(p)) { + insideClip = false; + break; + } + } + if (insideClip) { + drawState->disableState(GrDrawState::kClip_StateBit); + disabledClip = true; } - } - if (insideClip) { - drawState->disableState(GrDrawState::kClip_StateBit); - disabledClip = true; } } + if (!this->needsNewClip() && !this->needsNewState() && fCurrQuad > 0 && @@ -833,7 +841,7 @@ void GrInOrderDrawBuffer::recordClip() { } void GrInOrderDrawBuffer::recordDefaultClip() { - fClips.push_back() = GrClip(); + fClips.push_back() = SkClipStack(); fClipOrigins.push_back() = SkIPoint::Make(0, 0); fCmds.push_back(kSetClip_Cmd); } |