diff options
author | 2012-07-24 18:20:10 +0000 | |
---|---|---|
committer | 2012-07-24 18:20:10 +0000 | |
commit | b99225c92bc6d7d0ea7030716ade6a302862e84f (patch) | |
tree | d2bacdb0a72261e922046c6bb440dc30e6d3d5e7 | |
parent | afe56de6361a81eef537ddd8f6d5626c8546d4c7 (diff) |
Added requires_AA method to GrClipMaskManager.cpp to replace GrClip capability
http://codereview.appspot.com/6422062/
git-svn-id: http://skia.googlecode.com/svn/trunk@4738 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/gpu/GrClip.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.cpp | 33 |
2 files changed, 28 insertions, 7 deletions
diff --git a/src/gpu/GrClip.cpp b/src/gpu/GrClip.cpp index 84f58c63ce..ace765f6cb 100644 --- a/src/gpu/GrClip.cpp +++ b/src/gpu/GrClip.cpp @@ -63,6 +63,7 @@ void GrClip::setFromRect(const GrRect& r) { fList.back().fDoAA = false; fConservativeBounds = r; fConservativeBoundsValid = true; + fRequiresAA = false; } } @@ -79,6 +80,7 @@ void GrClip::setFromIRect(const GrIRect& r) { fList.back().fDoAA = false; fConservativeBounds.set(r); fConservativeBoundsValid = true; + fRequiresAA = false; } } diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index ceba429319..4deebf4218 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -69,6 +69,27 @@ GrPathFill get_path_fill(const SkPath& path) { } } +/** + * Does any individual clip in 'clipIn' use anti-aliasing? + */ +bool requires_AA(const GrClip& clipIn) { + + GrClip::Iter iter; + iter.reset(clipIn, GrClip::Iter::kBottom_IterStart); + + const GrClip::Iter::Clip* clip = NULL; + for (clip = iter.skipToTopmost(SkRegion::kReplace_Op); + NULL != clip; + clip = iter.next()) { + + if (clip->fDoAA) { + return true; + } + } + + return false; +} + } /* @@ -78,11 +99,6 @@ GrPathFill get_path_fill(const SkPath& path) { */ bool GrClipMaskManager::useSWOnlyPath(const GrClip& clipIn) { - if (!clipIn.requiresAA()) { - // The stencil buffer can handle this case - return false; - } - // TODO: generalize this function so that when // a clip gets complex enough it can just be done in SW regardless // of whether it would invoke the GrSoftwarePathRenderer. @@ -144,12 +160,15 @@ bool GrClipMaskManager::setupClipping(const GrClip& clipIn) { return false; } + bool requiresAA = requires_AA(clipIn); + GrAssert(requiresAA == clipIn.requiresAA()); + #if GR_SW_CLIP // If MSAA is enabled we can do everything in the stencil buffer. // Otherwise check if we should just create the entire clip mask // in software (this will only happen if the clip mask is anti-aliased // and too complex for the gpu to handle in its entirety) - if (0 == rt->numSamples() && this->useSWOnlyPath(clipIn)) { + if (0 == rt->numSamples() && requiresAA && this->useSWOnlyPath(clipIn)) { // The clip geometry is complex enough that it will be more // efficient to create it entirely in software GrTexture* result = NULL; @@ -169,7 +188,7 @@ bool GrClipMaskManager::setupClipping(const GrClip& clipIn) { #if GR_AA_CLIP // If MSAA is enabled use the (faster) stencil path for AA clipping // otherwise the alpha clip mask is our only option - if (0 == rt->numSamples() && clipIn.requiresAA()) { + if (0 == rt->numSamples() && requiresAA) { // Since we are going to create a destination texture of the correct // size for the mask (rather than being bound by the size of the // render target) we aren't going to use scissoring like the stencil |