diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-01 20:08:47 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-01 20:08:47 +0000 |
commit | a2d71482db8b6d752a51c96da74768d7dfc27932 (patch) | |
tree | 09e01d817528c81670352fda4abc63d8fd352afb /src/gpu | |
parent | eef938c0a764ca24bfebf38655124c8fcb8144f2 (diff) |
Removed GrClip & related classes
http://codereview.appspot.com/6450071/
git-svn-id: http://skia.googlecode.com/svn/trunk@4899 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrClip.cpp | 266 | ||||
-rw-r--r-- | src/gpu/GrClipData.cpp | 35 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.h | 1 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 4 | ||||
-rw-r--r-- | src/gpu/GrGpu.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.h | 1 | ||||
-rw-r--r-- | src/gpu/GrStencil.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrStencilBuffer.h | 2 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 63 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.h | 2 |
12 files changed, 41 insertions, 341 deletions
diff --git a/src/gpu/GrClip.cpp b/src/gpu/GrClip.cpp deleted file mode 100644 index 4fbac8a714..0000000000 --- a/src/gpu/GrClip.cpp +++ /dev/null @@ -1,266 +0,0 @@ - -/* - * Copyright 2010 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "GrClip.h" -#include "GrSurface.h" -#include "GrRect.h" - -GrClip::GrClip() - : fRequiresAA(false) { - fConservativeBounds.setEmpty(); - fConservativeBoundsValid = true; -} - -GrClip::GrClip(const GrClip& src) { - *this = src; -} - -GrClip::GrClip(const GrIRect& rect) { - this->setFromIRect(rect); -} - -GrClip::GrClip(const GrRect& rect) { - this->setFromRect(rect); -} - -GrClip::GrClip(GrClipIterator* iter, const GrRect& bounds) { - this->setFromIterator(iter, bounds); -} - -GrClip::~GrClip() {} - -GrClip& GrClip::operator=(const GrClip& src) { - fList = src.fList; - fConservativeBounds = src.fConservativeBounds; - fConservativeBoundsValid = src.fConservativeBoundsValid; - fRequiresAA = src.fRequiresAA; - return *this; -} - -void GrClip::setEmpty() { - fList.reset(); - fConservativeBounds.setEmpty(); - fConservativeBoundsValid = true; - fRequiresAA = false; -} - -void GrClip::setFromRect(const GrRect& r) { - fList.reset(); - if (r.isEmpty()) { - // use a canonical empty rect for == testing. - setEmpty(); - } else { - fList.push_back(); - fList.back().fRect = r; - fList.back().fType = kRect_ClipType; - fList.back().fOp = SkRegion::kReplace_Op; - fList.back().fDoAA = false; - fConservativeBounds = r; - fConservativeBoundsValid = true; - fRequiresAA = false; - } -} - -void GrClip::setFromIRect(const GrIRect& r) { - fList.reset(); - if (r.isEmpty()) { - // use a canonical empty rect for == testing. - setEmpty(); - } else { - fList.push_back(); - fList.back().fRect.set(r); - fList.back().fType = kRect_ClipType; - fList.back().fOp = SkRegion::kReplace_Op; - fList.back().fDoAA = false; - fConservativeBounds.set(r); - fConservativeBoundsValid = true; - fRequiresAA = false; - } -} - -static void intersectWith(SkRect* dst, const SkRect& src) { - if (!dst->intersect(src)) { - dst->setEmpty(); - } -} - -void GrClip::setFromIterator(GrClipIterator* iter, - const GrRect& conservativeBounds) { - fList.reset(); - fRequiresAA = false; - - int rectCount = 0; - - // compute bounds for common case of series of intersecting rects. - bool isectRectValid = true; - - if (iter) { - for (iter->rewind(); !iter->isDone(); iter->next()) { - Element& e = fList.push_back(); - e.fType = iter->getType(); - e.fOp = iter->getOp(); - e.fDoAA = iter->getDoAA(); - if (e.fDoAA) { - fRequiresAA = true; - } - // iterators should not emit replace - GrAssert(SkRegion::kReplace_Op != e.fOp); - switch (e.fType) { - case kRect_ClipType: - iter->getRect(&e.fRect); - ++rectCount; - if (isectRectValid) { - if (SkRegion::kIntersect_Op == e.fOp) { - GrAssert(fList.count() <= 2); - if (fList.count() > 1) { - GrAssert(2 == rectCount); - rectCount = 1; - fList.pop_back(); - GrAssert(kRect_ClipType == fList.back().fType); - intersectWith(&fList.back().fRect, e.fRect); - } - } else { - isectRectValid = false; - } - } - break; - case kPath_ClipType: - e.fPath = *iter->getPath(); - e.fPathFill = iter->getPathFill(); - isectRectValid = false; - break; - default: - GrCrash("Unknown clip element type."); - } - } - } - fConservativeBoundsValid = false; - if (isectRectValid && rectCount) { - fConservativeBounds = fList[0].fRect; - fConservativeBoundsValid = true; - } else { - fConservativeBounds = conservativeBounds; - fConservativeBoundsValid = true; - } -} - -/////////////////////////////////////////////////////////////////////////////// - -GrClip::Iter::Iter() - : fStack(NULL) - , fCurIndex(0) { -} - -GrClip::Iter::Iter(const GrClip& stack, IterStart startLoc) - : fStack(&stack) { - this->reset(stack, startLoc); -} - -const GrClip::Iter::Clip* GrClip::Iter::updateClip(int index) { - - if (NULL == fStack) { - return NULL; - } - - GrAssert(0 <= index && index < fStack->getElementCount()); - - - - switch (fStack->getElementType(index)) { - case kRect_ClipType: - fClip.fRect = &fStack->getRect(index); - fClip.fPath = NULL; - break; - case kPath_ClipType: - fClip.fRect = NULL; - fClip.fPath = &fStack->getPath(index); - break; - } - fClip.fOp = fStack->getOp(index); - fClip.fDoAA = fStack->getDoAA(index); - return &fClip; -} - -const GrClip::Iter::Clip* GrClip::Iter::next() { - - if (NULL == fStack) { - return NULL; - } - - if (0 > fCurIndex || fCurIndex >= fStack->getElementCount()) { - return NULL; - } - - int oldIndex = fCurIndex; - ++fCurIndex; - - return this->updateClip(oldIndex); -} - -const GrClip::Iter::Clip* GrClip::Iter::prev() { - - if (NULL == fStack) { - return NULL; - } - - if (0 > fCurIndex || fCurIndex >= fStack->getElementCount()) { - return NULL; - } - - int oldIndex = fCurIndex; - --fCurIndex; - - return this->updateClip(oldIndex); -} - -const GrClip::Iter::Clip* GrClip::Iter::skipToTopmost(SkRegion::Op op) { - - GrAssert(SkRegion::kReplace_Op == op); - - if (NULL == fStack) { - return NULL; - } - - // GrClip removes all clips below the topmost replace - this->reset(*fStack, kBottom_IterStart); - - return this->next(); -} - -void GrClip::Iter::reset(const GrClip& stack, IterStart startLoc) { - fStack = &stack; - if (kBottom_IterStart == startLoc) { - fCurIndex = 0; - } else { - fCurIndex = fStack->getElementCount()-1; - } -} - -/////////////////////////////////////////////////////////////////////////////// - -/** - * getConservativeBounds returns the conservative bounding box of the clip - * in device (as opposed to canvas) coordinates. If the bounding box is - * the result of purely intersections of rects (with an initial replace) - * isIntersectionOfRects will be set to true. - */ -void GrClipData::getConservativeBounds(const GrSurface* surface, - GrIRect* devResult, - bool* isIntersectionOfRects) const { - GrRect devBounds; - - fClipStack->getConservativeBounds(-fOrigin.fX, - -fOrigin.fY, - surface->width(), - surface->height(), - &devBounds, - isIntersectionOfRects); - - devBounds.roundOut(devResult); -} - diff --git a/src/gpu/GrClipData.cpp b/src/gpu/GrClipData.cpp new file mode 100644 index 0000000000..488643d1d1 --- /dev/null +++ b/src/gpu/GrClipData.cpp @@ -0,0 +1,35 @@ + +/* + * Copyright 2010 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "GrClipData.h" +#include "GrSurface.h" +#include "GrRect.h" + +/////////////////////////////////////////////////////////////////////////////// + +/** + * getConservativeBounds returns the conservative bounding box of the clip + * in device (as opposed to canvas) coordinates. If the bounding box is + * the result of purely intersections of rects (with an initial replace) + * isIntersectionOfRects will be set to true. + */ +void GrClipData::getConservativeBounds(const GrSurface* surface, + GrIRect* devResult, + bool* isIntersectionOfRects) const { + GrRect devBounds; + + fClipStack->getConservativeBounds(-fOrigin.fX, + -fOrigin.fY, + surface->width(), + surface->height(), + &devBounds, + isIntersectionOfRects); + + devBounds.roundOut(devResult); +} + diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index ff473069df..0abe86262b 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -651,10 +651,6 @@ bool GrClipMaskManager::createAlphaClipMask(const GrClipData& clipDataIn, } if (SkRegion::kReplace_Op == op) { - // TODO: replace is actually a lot faster then intersection - // for this path - refactor the stencil path so it can handle - // replace ops and alter GrClip to allow them through - // clear the accumulator and draw the new object directly into it fGpu->clear(NULL, 0x00000000, accum->asRenderTarget()); diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h index d22838e6e7..a8a00742f2 100644 --- a/src/gpu/GrClipMaskManager.h +++ b/src/gpu/GrClipMaskManager.h @@ -9,7 +9,6 @@ #ifndef GrClipMaskManager_DEFINED #define GrClipMaskManager_DEFINED -#include "GrClip.h" #include "GrContext.h" #include "GrNoncopyable.h" #include "GrRect.h" diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index f801b26edd..49cbec4db9 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -14,7 +14,6 @@ #include "effects/GrSingleTextureEffect.h" #include "GrBufferAllocPool.h" -#include "GrClipIterator.h" #include "GrGpu.h" #include "GrIndexBuffer.h" #include "GrInOrderDrawBuffer.h" diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index 3fb6201324..030b0921d5 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -11,7 +11,6 @@ #ifndef GrDrawTarget_DEFINED #define GrDrawTarget_DEFINED -#include "GrClip.h" #include "GrDrawState.h" #include "GrIndexBuffer.h" #include "GrMatrix.h" @@ -20,8 +19,9 @@ #include "SkXfermode.h" #include "SkTLazy.h" +#include "SkTArray.h" -class GrClipIterator; +class GrClipData; class GrPath; class GrVertexBuffer; diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 0385b25285..a9306f49e4 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -10,7 +10,6 @@ #include "GrGpu.h" #include "GrBufferAllocPool.h" -#include "GrClipIterator.h" #include "GrContext.h" #include "GrIndexBuffer.h" #include "GrStencilBuffer.h" diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h index 4bdaa6ecdc..73a9068fee 100644 --- a/src/gpu/GrInOrderDrawBuffer.h +++ b/src/gpu/GrInOrderDrawBuffer.h @@ -15,7 +15,6 @@ #include "GrAllocPool.h" #include "GrAllocator.h" #include "GrPath.h" -#include "GrClip.h" #include "SkClipStack.h" #include "SkTemplates.h" diff --git a/src/gpu/GrStencil.cpp b/src/gpu/GrStencil.cpp index ac2d6d801c..decfd2df14 100644 --- a/src/gpu/GrStencil.cpp +++ b/src/gpu/GrStencil.cpp @@ -195,7 +195,7 @@ GR_STATIC_CONST_SAME_STENCIL(gInvUserToClipRDiffPass1, // only modify the in/out status of samples covered by the clip element. // this one only works if used right after stencil clip was cleared. -// Our GrClip doesn't allow midstream replace ops. +// Our clip mask creation code doesn't allow midstream replace ops. GR_STATIC_CONST_SAME_STENCIL(gReplaceClip, kReplace_StencilOp, kReplace_StencilOp, diff --git a/src/gpu/GrStencilBuffer.h b/src/gpu/GrStencilBuffer.h index 77843a3baf..9767b1733f 100644 --- a/src/gpu/GrStencilBuffer.h +++ b/src/gpu/GrStencilBuffer.h @@ -10,7 +10,7 @@ #ifndef GrStencilBuffer_DEFINED #define GrStencilBuffer_DEFINED -#include "GrClip.h" +#include "GrClipData.h" #include "GrResource.h" class GrRenderTarget; diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index dca0858d20..f6ee7efb11 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -164,69 +164,6 @@ void GrUnlockCachedBitmapTexture(GrContext* ctx, GrContext::TextureCacheEntry ca /////////////////////////////////////////////////////////////////////////////// -void SkGrClipIterator::reset(const SkClipStack& clipStack) { - fClipStack = &clipStack; - fIter.reset(clipStack); - // Gr has no notion of replace, skip to the - // last replace in the clip stack. - int lastReplace = 0; - int curr = 0; - while (NULL != (fCurr = fIter.next())) { - if (SkRegion::kReplace_Op == fCurr->fOp) { - lastReplace = curr; - } - ++curr; - } - fIter.reset(clipStack); - for (int i = 0; i < lastReplace+1; ++i) { - fCurr = fIter.next(); - } -} - -GrClipType SkGrClipIterator::getType() const { - GrAssert(!this->isDone()); - if (NULL == fCurr->fPath) { - return kRect_ClipType; - } else { - return kPath_ClipType; - } -} - -SkRegion::Op SkGrClipIterator::getOp() const { - // we skipped to the last "replace" op - // when this iter was reset. - // GrClip doesn't allow replace, so treat it as - // intersect. - if (SkRegion::kReplace_Op == fCurr->fOp) { - return SkRegion::kIntersect_Op; - } - - return fCurr->fOp; - -} - -bool SkGrClipIterator::getDoAA() const { - return fCurr->fDoAA; -} - -GrPathFill SkGrClipIterator::getPathFill() const { - switch (fCurr->fPath->getFillType()) { - case SkPath::kWinding_FillType: - return kWinding_GrPathFill; - case SkPath::kEvenOdd_FillType: - return kEvenOdd_GrPathFill; - case SkPath::kInverseWinding_FillType: - return kInverseWinding_GrPathFill; - case SkPath::kInverseEvenOdd_FillType: - return kInverseEvenOdd_GrPathFill; - default: - GrCrash("Unsupported path fill in clip."); - return kWinding_GrPathFill; // suppress warning - } -} - -/////////////////////////////////////////////////////////////////////////////// - GrPixelConfig SkBitmapConfig2GrPixelConfig(SkBitmap::Config config) { switch (config) { case SkBitmap::kA8_Config: diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 322e7339f7..2acfbd74ae 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -9,6 +9,8 @@ #ifndef GrGLCaps_DEFINED #define GrGLCaps_DEFINED +#include "SkTArray.h" +#include "SkTDArray.h" #include "GrGLStencilBuffer.h" class GrGLContextInfo; |