diff options
author | 2011-10-12 20:23:55 +0000 | |
---|---|---|
committer | 2011-10-12 20:23:55 +0000 | |
commit | 1778564c75de5799d45126984f8faafd03523100 (patch) | |
tree | 2ee5d34d4d80ae090d6f2d18fb2d6fba6e388752 /src/core/SkAAClip.cpp | |
parent | d38f137e9b813f8193675ebd3dfbfe8bc42639e9 (diff) |
trim off extra alpha==0 spans before and after our bounds
git-svn-id: http://skia.googlecode.com/svn/trunk@2472 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkAAClip.cpp')
-rw-r--r-- | src/core/SkAAClip.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp index 32ff7c7339..3f38ddd4db 100644 --- a/src/core/SkAAClip.cpp +++ b/src/core/SkAAClip.cpp @@ -521,6 +521,8 @@ class SkAAClip::BuilderBlitter : public SkBlitter { public: BuilderBlitter(Builder* builder) { fBuilder = builder; + fLeft = builder->getBounds().fLeft; + fRight = builder->getBounds().fRight; } virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE @@ -545,7 +547,30 @@ public: if (count <= 0) { return; } - fBuilder->addRun(x, y, *alpha, count); + + // The supersampler's buffer can be the width of the device, so + // we may have to trim the run to our bounds. If so, we assert that + // the extra spans are always alpha==0 + int localX = x; + int localCount = count; + if (x < fLeft) { + SkASSERT(0 == *alpha); + int gap = fLeft - x; + SkASSERT(gap <= count); + localX += gap; + localCount -= gap; + } + int right = x + count; + if (right > fRight) { + SkASSERT(0 == *alpha); + localCount -= right - fRight; + SkASSERT(localCount >= 0); + } + + if (localCount) { + fBuilder->addRun(localX, y, *alpha, localCount); + } + NEXT_RUN: runs += count; alpha += count; x += count; @@ -554,6 +579,8 @@ public: private: Builder* fBuilder; + int fLeft; // cache of builder's bounds' left edge + int fRight; void unexpected() { SkDebugf("---- did not expect to get called here"); |