aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/src/GrInOrderDrawBuffer.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-03 13:54:13 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-03 13:54:13 +0000
commitd302f1401b3c9aea094804bad4e76de98782cfe8 (patch)
treeb46ec6c4de175842aef051d7b812785dacbd1d73 /gpu/src/GrInOrderDrawBuffer.cpp
parent1d12b1fd66e5be27fb4769ee09ce4fcd6bcc5979 (diff)
Add support for clipstack to Gr. GrClip is now a list of rects and paths with set operations to combine them. The stencil buffer is used to perform the set operations to put the clip into the stencil buffer. Building Gr's clip from Skia's clipStack is currently disabled due to the fact that Skia's clipStack is relative to the root layer not the current layer. This will be fixed in a subsequent CL.
git-svn-id: http://skia.googlecode.com/svn/trunk@878 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/GrInOrderDrawBuffer.cpp')
-rw-r--r--gpu/src/GrInOrderDrawBuffer.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/gpu/src/GrInOrderDrawBuffer.cpp b/gpu/src/GrInOrderDrawBuffer.cpp
index 68590fc8ab..a249364752 100644
--- a/gpu/src/GrInOrderDrawBuffer.cpp
+++ b/gpu/src/GrInOrderDrawBuffer.cpp
@@ -67,17 +67,17 @@ void GrInOrderDrawBuffer::setQuadIndexBuffer(const GrIndexBuffer* indexBuffer) {
fCurrQuad = 0;
fMaxQuads = (NULL == indexBuffer) ? 0 : indexBuffer->maxQuads();
} else {
- GrAssert((NULL == indexBuffer && 0 == fMaxQuads) ||
+ GrAssert((NULL == indexBuffer && 0 == fMaxQuads) ||
(indexBuffer->maxQuads() == fMaxQuads));
}
}
-void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
+void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
const GrMatrix* matrix,
StageBitfield stageEnableBitfield,
const GrRect* srcRects[],
const GrMatrix* srcMatrices[]) {
-
+
GrAssert(!(NULL == fQuadIndexBuffer && fCurrQuad));
GrAssert(!(fDraws.empty() && fCurrQuad));
GrAssert(!(0 != fMaxQuads && NULL == fQuadIndexBuffer));
@@ -85,7 +85,7 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
// if we have a quad IB then either append to the previous run of
// rects or start a new run
if (fMaxQuads) {
-
+
bool appendToPreviousDraw = false;
GrVertexLayout layout = GetRectVertexLayout(stageEnableBitfield, srcRects);
AutoReleaseGeometry geo(this, layout, 4, 0);
@@ -103,10 +103,14 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
// the rect.
bool disabledClip = false;
if (this->isClipState() && fClip.isRect()) {
- GrRect clipRect = GrRect(*fClip.getRects());
+
+ // single rect clip should have bounds
+ GrAssert(fClip.hasBounds());
+
+ GrRect clipRect = GrRect(fClip.getBounds());
// 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
+ // We might consider a more exact clip to viewport if this
// conservative test fails.
const GrRenderTarget* target = this->getRenderTarget();
if (0 >= clipRect.fLeft) {
@@ -135,11 +139,11 @@ void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
disabledClip = true;
}
}
- if (!needsNewClip() && !needsNewState() && fCurrQuad > 0 &&
+ if (!needsNewClip() && !needsNewState() && fCurrQuad > 0 &&
fCurrQuad < fMaxQuads && layout == fLastRectVertexLayout) {
int vsize = VertexSize(layout);
-
+
Draw& lastDraw = fDraws.back();
GrAssert(lastDraw.fIndexBuffer == fQuadIndexBuffer);
@@ -500,7 +504,7 @@ void GrInOrderDrawBuffer::pushState() {
}
this->saveCurrentDrawState(&fStates.push_back());
}
-
+
bool GrInOrderDrawBuffer::needsNewClip() const {
if (fCurrDrawState.fFlagBits & kClip_StateBit) {
if (fClips.empty() || (fClipSet && fClips.back() != fClip)) {
@@ -509,12 +513,12 @@ bool GrInOrderDrawBuffer::needsNewClip() const {
}
return false;
}
-
+
void GrInOrderDrawBuffer::pushClip() {
fClips.push_back() = fClip;
fClipSet = false;
}
-
+
void GrInOrderDrawBuffer::clipWillBeSet(const GrClip& newClip) {
fClipSet = true;
}