aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-03-23 16:05:19 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-03-23 16:05:19 +0000
commit8898363b2ee02e36dfa4bb166b59c09c4e835b0f (patch)
tree6f11f16318a2cb61fc4196bac37eaf5fed6dd7ca /src
parentae64551e2e36fee00bf206666fdfe2b873922eda (diff)
add check/hack to avoid drawing outside of the clip for hairlines
git-svn-id: http://skia.googlecode.com/svn/trunk@134 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkScan_Antihair.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp
index 3344698f86..b54057344d 100644
--- a/src/core/SkScan_Antihair.cpp
+++ b/src/core/SkScan_Antihair.cpp
@@ -21,6 +21,21 @@
#include "SkRegion.h"
#include "SkFDot6.h"
+/* Our attempt to compute the worst case "bounds" for the horizontal and
+ vertical cases has some numerical bug in it, and we sometimes undervalue
+ our extends. The bug is that when this happens, we will set the clip to
+ NULL (for speed), and thus draw outside of the clip by a pixel, which might
+ only look bad, but it might also access memory outside of the valid range
+ allcoated for the device bitmap.
+
+ This define enables our fix to outset our "bounds" by 1, thus avoiding the
+ chance of the bug, but at the cost of sometimes taking the rectblitter
+ case (i.e. not setting the clip to NULL) when we might not actually need
+ to. If we can improve/fix the actual calculations, then we can remove this
+ step.
+ */
+#define OUTSET_BEFORE_CLIP_TEST true
+
#define HLINE_STACK_BUFFER 100
static inline int SmallDot6Scale(int value, int dot6) {
@@ -290,6 +305,10 @@ static void do_anti_hairline(SkFDot6 x0, SkFDot6 y0, SkFDot6 x1, SkFDot6 y1,
bottom = SkFixedCeil(fstart + SK_FixedHalf);
top = SkFixedFloor(fstart + (istop - istart - 1) * slope - SK_FixedHalf);
}
+ if (OUTSET_BEFORE_CLIP_TEST) {
+ top -= 1;
+ bottom += 1;
+ }
if (top >= clip->fBottom || bottom <= clip->fTop)
return;
if (clip->fTop <= top && clip->fBottom >= bottom)
@@ -363,6 +382,10 @@ static void do_anti_hairline(SkFDot6 x0, SkFDot6 y0, SkFDot6 x1, SkFDot6 y1,
right = SkFixedCeil(fstart + SK_FixedHalf);
left = SkFixedFloor(fstart + (istop - istart - 1) * slope - SK_FixedHalf);
}
+ if (OUTSET_BEFORE_CLIP_TEST) {
+ left -= 1;
+ right += 1;
+ }
if (left >= clip->fRight || right <= clip->fLeft)
return;
if (clip->fLeft <= left && clip->fRight >= right)