Automated import from //branches/master/...@142205,142205
diff --git a/include/core/SkMask.h b/include/core/SkMask.h
index 764ead6..017a559 100644
--- a/include/core/SkMask.h
+++ b/include/core/SkMask.h
@@ -37,13 +37,14 @@
uint8_t* fImage;
SkIRect fBounds;
- uint16_t fRowBytes;
- uint8_t fFormat; // Format
+ uint32_t fRowBytes;
+ Format fFormat;
/** Return the byte size of the mask, assuming only 1 plane.
Does not account for k3D_Format. For that, use computeFormatImageSize()
*/
size_t computeImageSize() const;
+
/** Return the byte size of the mask, taking into account
any extra planes (e.g. k3D_Format).
*/
@@ -53,19 +54,18 @@
Asserts that the mask is kBW_Format, and that x,y are in range.
x,y are in the same coordiate space as fBounds.
*/
- uint8_t* getAddr1(int x, int y) const
- {
+ uint8_t* getAddr1(int x, int y) const {
SkASSERT(fFormat == kBW_Format);
SkASSERT(fBounds.contains(x, y));
SkASSERT(fImage != NULL);
return fImage + ((x - fBounds.fLeft) >> 3) + (y - fBounds.fTop) * fRowBytes;
}
+
/** Returns the address of the specified byte.
Asserts that the mask is kA8_Format, and that x,y are in range.
x,y are in the same coordiate space as fBounds.
*/
- uint8_t* getAddr(int x, int y) const
- {
+ uint8_t* getAddr(int x, int y) const {
SkASSERT(fFormat != kBW_Format);
SkASSERT(fBounds.contains(x, y));
SkASSERT(fImage != NULL);
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 5ca3601..bdc795f 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -893,7 +893,7 @@
level[i].fPixels = addr;
level[i].fWidth = SkToU16(width);
level[i].fHeight = SkToU16(height);
- level[i].fRowBytes = SkToU16(rowBytes);
+ level[i].fRowBytes = rowBytes;
dstBM.setConfig(config, width, height, rowBytes);
dstBM.setPixels(addr);
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index bc981f9..60c474a 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1250,7 +1250,7 @@
}
mask.fRowBytes = glyph.rowBytes();
- mask.fFormat = glyph.fMaskFormat;
+ mask.fFormat = static_cast<SkMask::Format>(glyph.fMaskFormat);
mask.fImage = aa;
state.fBlitter->blitMask(mask, *bounds);
}
@@ -1280,7 +1280,7 @@
}
mask.fRowBytes = glyph.rowBytes();
- mask.fFormat = glyph.fMaskFormat;
+ mask.fFormat = static_cast<SkMask::Format>(glyph.fMaskFormat);
mask.fImage = (uint8_t*)aa;
do {
state.fBlitter->blitMask(mask, cr);
@@ -1313,7 +1313,7 @@
if (state.fBounder->doIRect(cr)) {
mask.fRowBytes = glyph.rowBytes();
- mask.fFormat = glyph.fMaskFormat;
+ mask.fFormat = static_cast<SkMask::Format>(glyph.fMaskFormat);
mask.fImage = (uint8_t*)aa;
do {
state.fBlitter->blitMask(mask, cr);
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index e74ae24..da90227 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -62,6 +62,8 @@
fPath = path;
fDirty = path->fFastBoundsIsDirty;
fEmpty = path->isEmpty();
+ // Cannot use fRect for our bounds unless we know it is sorted
+ fRect.sort();
}
};
@@ -994,7 +996,7 @@
SkScalarIsNaN(fMoveTo.fX) && SkScalarIsNaN(fMoveTo.fY)) {
return kClose_Verb;
}
-
+
if (pts) {
pts[0] = fLastPt;
pts[1] = fMoveTo;
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index fe9477d..aad1dcd 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -50,7 +50,7 @@
class SkRefCntPlayback {
public:
SkRefCntPlayback();
- ~SkRefCntPlayback();
+ virtual ~SkRefCntPlayback();
int count() const { return fCount; }
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 4a3338a..421d5c2 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -458,7 +458,7 @@
fRegions = SkNEW_ARRAY(SkRegion, fRegionCount);
for (i = 0; i < fRegionCount; i++) {
uint32_t size = buffer.readU32();
- uint32_t bytes = fRegions[i].unflatten(buffer.skip(size));
+ SkDEBUGCODE(uint32_t bytes =) fRegions[i].unflatten(buffer.skip(size));
SkASSERT(size == bytes);
}
}
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index 8f84cbb..b271970 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -41,7 +41,7 @@
mask->fImage = (uint8_t*)fImage;
mask->fBounds.set(fLeft, fTop, fLeft + fWidth, fTop + fHeight);
mask->fRowBytes = this->rowBytes();
- mask->fFormat = fMaskFormat;
+ mask->fFormat = static_cast<SkMask::Format>(fMaskFormat);
}
size_t SkGlyph::computeImageSize() const {
diff --git a/src/core/SkScan_Antihair.cpp b/src/core/SkScan_Antihair.cpp
index 3344698..e3ee900 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 @@
bottom = SkFixedCeil(fstart + SK_FixedHalf);
top = SkFixedFloor(fstart + (istop - istart - 1) * slope - SK_FixedHalf);
}
+#ifdef OUTSET_BEFORE_CLIP_TEST
+ top -= 1;
+ bottom += 1;
+#endif
if (top >= clip->fBottom || bottom <= clip->fTop)
return;
if (clip->fTop <= top && clip->fBottom >= bottom)
@@ -363,6 +382,10 @@
right = SkFixedCeil(fstart + SK_FixedHalf);
left = SkFixedFloor(fstart + (istop - istart - 1) * slope - SK_FixedHalf);
}
+#ifdef OUTSET_BEFORE_CLIP_TEST
+ left -= 1;
+ right += 1;
+#endif
if (left >= clip->fRight || right <= clip->fLeft)
return;
if (clip->fLeft <= left && clip->fRight >= right)
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index 6571328..4def146 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -45,28 +45,28 @@
int8_t SkStream::readS8() {
int8_t value;
- size_t len = this->read(&value, 1);
+ SkDEBUGCODE(size_t len =) this->read(&value, 1);
SkASSERT(1 == len);
return value;
}
int16_t SkStream::readS16() {
int16_t value;
- size_t len = this->read(&value, 2);
+ SkDEBUGCODE(size_t len =) this->read(&value, 2);
SkASSERT(2 == len);
return value;
}
int32_t SkStream::readS32() {
int32_t value;
- size_t len = this->read(&value, 4);
+ SkDEBUGCODE(size_t len =) this->read(&value, 4);
SkASSERT(4 == len);
return value;
}
SkScalar SkStream::readScalar() {
SkScalar value;
- size_t len = this->read(&value, sizeof(SkScalar));
+ SkDEBUGCODE(size_t len =) this->read(&value, sizeof(SkScalar));
SkASSERT(sizeof(SkScalar) == len);
return value;
}
diff --git a/src/core/SkTSort.h b/src/core/SkTSort.h
index fba49e2..d9544d7 100644
--- a/src/core/SkTSort.h
+++ b/src/core/SkTSort.h
@@ -21,44 +21,29 @@
#include "SkTypes.h"
template <typename T>
-void SkTHeapSort_SiftDown(T array[], int root, int bottom)
-{
- int root2 = root << 1;
-
- while (root2 <= bottom)
- {
- int maxChild;
-
- if (root2 == bottom)
- maxChild = root2;
- else if (array[root2] > array[root2 + 1])
- maxChild = root2;
- else
- maxChild = root2 + 1;
-
- if (array[root] < array[maxChild])
- {
- SkTSwap<T>(array[root], array[maxChild]);
- root = maxChild;
- root2 = root << 1;
+void SkTHeapSort_SiftDown(T array[], int root, int bottom) {
+ while (root*2 + 1 <= bottom) {
+ int child = root * 2 + 1;
+ if (child+1 <= bottom && array[child] < array[child+1]) {
+ child += 1;
}
- else
+ if (array[root] < array[child]) {
+ SkTSwap<T>(array[root], array[child]);
+ root = child;
+ } else {
break;
+ }
}
}
-template <typename T>
-void SkTHeapSort(T array[], int count)
-{
+template <typename T> void SkTHeapSort(T array[], int count) {
int i;
-
- for (i = count/2 - 1; i >= 0; --i)
- SkTHeapSort_SiftDown<T>(array, i, count);
-
- for (i = count - 2; i >= 0; --i)
- {
- SkTSwap<T>(array[0], array[i + 1]);
- SkTHeapSort_SiftDown<T>(array, 0, i);
+ for (i = count/2 - 1; i >= 0; --i) {
+ SkTHeapSort_SiftDown<T>(array, i, count-1);
+ }
+ for (i = count - 1; i > 0; --i) {
+ SkTSwap<T>(array[0], array[i]);
+ SkTHeapSort_SiftDown<T>(array, 0, i-1);
}
}
diff --git a/src/effects/SkBlurMask.cpp b/src/effects/SkBlurMask.cpp
index a7b3202..416eda4 100644
--- a/src/effects/SkBlurMask.cpp
+++ b/src/effects/SkBlurMask.cpp
@@ -228,7 +228,7 @@
dst->fBounds.set(src.fBounds.fLeft - rx, src.fBounds.fTop - ry,
src.fBounds.fRight + rx, src.fBounds.fBottom + ry);
- dst->fRowBytes = SkToU16(dst->fBounds.width());
+ dst->fRowBytes = dst->fBounds.width();
dst->fFormat = SkMask::kA8_Format;
dst->fImage = NULL;
@@ -277,7 +277,7 @@
if (style == kInner_Style)
{
dst->fBounds = src.fBounds; // restore trimmed bounds
- dst->fRowBytes = SkToU16(dst->fBounds.width());
+ dst->fRowBytes = dst->fBounds.width();
}
#if 0
diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp
index 390e3a3..ad16ea8 100644
--- a/src/effects/SkLayerRasterizer.cpp
+++ b/src/effects/SkLayerRasterizer.cpp
@@ -107,7 +107,7 @@
if (SkMask::kComputeBoundsAndRenderImage_CreateMode == mode)
{
mask->fFormat = SkMask::kA8_Format;
- mask->fRowBytes = SkToU16(mask->fBounds.width());
+ mask->fRowBytes = mask->fBounds.width();
mask->fImage = SkMask::AllocImage(mask->computeImageSize());
memset(mask->fImage, 0, mask->computeImageSize());
}