aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2010-04-14 10:16:53 -0400
committerMike Reed <reed@google.com>2010-04-14 12:09:33 -0400
commit4c1037238c8ebcef8c75b5d43730ed308a11102c (patch)
treead54f6a51e559b4bec0f2a67cb4f5c46621fd97d
parent97c126db9982665ba3792f30ce7f74b854462c69 (diff)
downloadexternal_skia-4c1037238c8ebcef8c75b5d43730ed308a11102c.zip
external_skia-4c1037238c8ebcef8c75b5d43730ed308a11102c.tar.gz
external_skia-4c1037238c8ebcef8c75b5d43730ed308a11102c.tar.bz2
refresh from trunk
Change-Id: I0175ec7482f8cf85d25165da360a5352979fd7a0
-rw-r--r--bench/RectBench.cpp13
-rw-r--r--bench/SkBenchmark.cpp1
-rw-r--r--bench/SkBenchmark.h16
-rw-r--r--bench/benchmain.cpp18
-rw-r--r--include/core/SkGraphics.h7
-rw-r--r--include/core/SkRect.h14
-rw-r--r--include/core/SkTypes.h6
-rw-r--r--include/effects/SkPorterDuff.h1
-rw-r--r--src/core/SkBitmapProcShader.cpp25
-rw-r--r--src/core/SkBitmapProcState.cpp11
-rw-r--r--src/core/SkBitmapProcState.h9
-rw-r--r--src/core/SkBitmapProcState_matrixProcs.cpp2
-rw-r--r--src/core/SkDraw.cpp2
-rw-r--r--src/core/SkGraphics.cpp12
-rw-r--r--src/core/SkRegion.cpp14
-rw-r--r--src/effects/SkPorterDuff.cpp3
-rw-r--r--src/images/SkImageDecoder_libico.cpp4
-rw-r--r--src/utils/SkCullPoints.cpp64
-rw-r--r--src/utils/SkDumpCanvas.cpp29
-rw-r--r--tests/MathTest.cpp1
20 files changed, 165 insertions, 87 deletions
diff --git a/bench/RectBench.cpp b/bench/RectBench.cpp
index 6f34eb5..3874bb3 100644
--- a/bench/RectBench.cpp
+++ b/bench/RectBench.cpp
@@ -89,14 +89,20 @@ public:
protected:
virtual void onDraw(SkCanvas* canvas) {
- static const SkScalar gSizes[] = {
+ SkScalar gSizes[] = {
SkIntToScalar(7), 0
};
+ size_t sizes = SK_ARRAY_COUNT(gSizes);
+
+ if (this->hasStrokeWidth()) {
+ gSizes[0] = this->getStrokeWidth();
+ sizes = 1;
+ }
SkPaint paint;
paint.setStrokeCap(SkPaint::kRound_Cap);
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(gSizes); i++) {
+
+ for (size_t i = 0; i < sizes; i++) {
paint.setStrokeWidth(gSizes[i]);
this->setupPaint(&paint);
canvas->drawPoints(fMode, N * 2,
@@ -132,4 +138,3 @@ static BenchRegistry gRRectReg2(RRectFactory2);
static BenchRegistry gPointsReg(PointsFactory);
static BenchRegistry gLinesReg(LinesFactory);
static BenchRegistry gPolygonReg(PolygonFactory);
-
diff --git a/bench/SkBenchmark.cpp b/bench/SkBenchmark.cpp
index e8bea6e..230a7af 100644
--- a/bench/SkBenchmark.cpp
+++ b/bench/SkBenchmark.cpp
@@ -9,6 +9,7 @@ SkBenchmark::SkBenchmark(void* defineDict) {
fForceAlpha = 0xFF;
fForceAA = true;
fDither = SkTriState::kDefault;
+ fHasStrokeWidth = false;
}
const char* SkBenchmark::getName() {
diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h
index bc9794a..945db80 100644
--- a/bench/SkBenchmark.h
+++ b/bench/SkBenchmark.h
@@ -42,6 +42,19 @@ public:
fDither = state;
}
+ void setStrokeWidth(SkScalar width) {
+ strokeWidth = width;
+ fHasStrokeWidth = true;
+ }
+
+ SkScalar getStrokeWidth() {
+ return strokeWidth;
+ }
+
+ bool hasStrokeWidth() {
+ return fHasStrokeWidth;
+ }
+
const char* findDefine(const char* key) const;
bool findDefine32(const char* key, int32_t* value) const;
bool findDefineScalar(const char* key, SkScalar* value) const;
@@ -60,9 +73,10 @@ private:
bool fForceAA;
bool fForceFilter;
SkTriState::State fDither;
+ bool fHasStrokeWidth;
+ SkScalar strokeWidth;
};
typedef SkTRegistry<SkBenchmark*, void*> BenchRegistry;
#endif
-
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 7443604..2f8b006 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -201,6 +201,8 @@ int main (int argc, char * const argv[]) {
bool doClip = false;
bool doPict = false;
const char* matchStr = NULL;
+ bool hasStrokeWidth = false;
+ float strokeWidth;
SkString outDir;
SkBitmap::Config outConfig = SkBitmap::kNo_Config;
@@ -260,6 +262,19 @@ int main (int argc, char * const argv[]) {
return -1;
}
forceAlpha = wantAlpha ? 0x80 : 0xFF;
+ } else if (strcmp(*argv, "-strokeWidth") == 0) {
+ argv++;
+ if (argv < stop) {
+ const char *strokeWidthStr = *argv;
+ if (sscanf(strokeWidthStr, "%f", &strokeWidth) != 1) {
+ log_error("bad arg for -strokeWidth\n");
+ return -1;
+ }
+ hasStrokeWidth = true;
+ } else {
+ log_error("missing arg for -strokeWidth\n");
+ return -1;
+ }
} else if (strcmp(*argv, "-match") == 0) {
argv++;
if (argv < stop) {
@@ -314,6 +329,9 @@ int main (int argc, char * const argv[]) {
bench->setForceAA(forceAA);
bench->setForceFilter(forceFilter);
bench->setDither(forceDither);
+ if (hasStrokeWidth) {
+ bench->setStrokeWidth(strokeWidth);
+ }
// only run benchmarks if their name contains matchStr
if (matchStr && strstr(bench->getName(), matchStr) == NULL) {
diff --git a/include/core/SkGraphics.h b/include/core/SkGraphics.h
index dd5808a..25c926f 100644
--- a/include/core/SkGraphics.h
+++ b/include/core/SkGraphics.h
@@ -33,7 +33,12 @@ public:
Returns true if some amount was purged from the font cache.
*/
static bool SetFontCacheUsed(size_t usageInBytes);
-
+
+ /** Return the version numbers for the library. If the parameter is not
+ null, it is set to the version number.
+ */
+ static void GetVersion(int32_t* major, int32_t* minor, int32_t* patch);
+
private:
/** This is automatically called by SkGraphics::Init(), and must be
implemented by the host OS. This allows the host OS to register a callback
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 879d81a..fbd9f7f 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -233,6 +233,18 @@ struct SkIRect {
struct SkRect {
SkScalar fLeft, fTop, fRight, fBottom;
+ static SkRect MakeEmpty() {
+ SkRect r;
+ r.setEmpty();
+ return r;
+ }
+
+ static SkRect MakeWH(SkScalar w, SkScalar h) {
+ SkRect r;
+ r.set(0, 0, w, h);
+ return r;
+ }
+
static SkRect MakeSize(const SkSize& size) {
SkRect r;
r.set(0, 0, size.width(), size.height());
@@ -250,7 +262,7 @@ struct SkRect {
r.set(x, y, x + w, y + h);
return r;
}
-
+
/** Return true if the rectangle's width or height are <= 0
*/
bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index fa21adc..1f8ecaa 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -30,6 +30,12 @@
/** \file SkTypes.h
*/
+/** See SkGraphics::GetVersion() to retrieve these at runtime
+ */
+#define SKIA_VERSION_MAJOR 1
+#define SKIA_VERSION_MINOR 0
+#define SKIA_VERSION_PATCH 0
+
/*
memory wrappers to be implemented by the porting layer (platform)
*/
diff --git a/include/effects/SkPorterDuff.h b/include/effects/SkPorterDuff.h
index df1c07e..6f4ac20 100644
--- a/include/effects/SkPorterDuff.h
+++ b/include/effects/SkPorterDuff.h
@@ -52,7 +52,6 @@ public:
kMultiply_Mode, //!< [Sa * Da, Sc * Dc]
kScreen_Mode, //!< [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc]
kAdd_Mode, //!< Saturate(S + D)
- kOverlay_Mode, //!< [Sa * Da, (Dc < 0.5 ? Sc * Dc : 1 - (1 - Dc) * (1 - Sc))]
kModeCount
};
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index bd4fece..c3fd7d0 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -137,6 +137,15 @@ bool SkBitmapProcShader::setContext(const SkBitmap& device,
#define BUF_MAX 128
+#define TEST_BUFFER_OVERRITEx
+
+#ifdef TEST_BUFFER_OVERRITE
+ #define TEST_BUFFER_EXTRA 32
+ #define TEST_PATTERN 0x88888888
+#else
+ #define TEST_BUFFER_EXTRA 0
+#endif
+
void SkBitmapProcShader::shadeSpan(int x, int y, SkPMColor dstC[], int count) {
const SkBitmapProcState& state = fState;
if (state.fShaderProc32) {
@@ -144,10 +153,10 @@ void SkBitmapProcShader::shadeSpan(int x, int y, SkPMColor dstC[], int count) {
return;
}
- uint32_t buffer[BUF_MAX];
+ uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA];
SkBitmapProcState::MatrixProc mproc = state.fMatrixProc;
SkBitmapProcState::SampleProc32 sproc = state.fSampleProc32;
- int max = fState.maxCountForBufferSize(sizeof(buffer));
+ int max = fState.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX);
SkASSERT(state.fBitmap->getPixels());
SkASSERT(state.fBitmap->pixelRef() == NULL ||
@@ -158,12 +167,24 @@ void SkBitmapProcShader::shadeSpan(int x, int y, SkPMColor dstC[], int count) {
if (n > max) {
n = max;
}
+ SkASSERT(n > 0 && n < BUF_MAX*2);
+#ifdef TEST_BUFFER_OVERRITE
+ for (int i = 0; i < TEST_BUFFER_EXTRA; i++) {
+ buffer[BUF_MAX + i] = TEST_PATTERN;
+ }
+#endif
mproc(state, buffer, n, x, y);
+#ifdef TEST_BUFFER_OVERRITE
+ for (int j = 0; j < TEST_BUFFER_EXTRA; j++) {
+ SkASSERT(buffer[BUF_MAX + j] == TEST_PATTERN);
+ }
+#endif
sproc(state, buffer, n, dstC);
if ((count -= n) == 0) {
break;
}
+ SkASSERT(count > 0);
x += n;
dstC += n;
}
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index eabd966..e54818d 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -543,7 +543,6 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
*/
int SkBitmapProcState::maxCountForBufferSize(size_t bufferSize) const {
int32_t size = static_cast<int32_t>(bufferSize);
- int perElemShift;
size &= ~3; // only care about 4-byte aligned chunks
if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
@@ -551,11 +550,15 @@ int SkBitmapProcState::maxCountForBufferSize(size_t bufferSize) const {
if (size < 0) {
size = 0;
}
- perElemShift = fDoFilter ? 2 : 1;
+ size >>= 1;
} else {
- perElemShift = fDoFilter ? 3 : 2;
+ size >>= 2;
}
- return size >> perElemShift;
+ if (fDoFilter) {
+ size >>= 1;
+ }
+
+ return size;
}
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index dd73c33..303696f 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -91,10 +91,11 @@ struct SkBitmapProcState {
*/
void platformProcs();
- /** Given the size of a buffer, to be used for calling the matrix and
- sample procs, this return the maximum count that can be stored in the
- buffer, taking into account that filtering and scale-vs-affine affect
- this value.
+ /** Given the byte size of the index buffer to be passed to the matrix proc,
+ return the maximum number of resulting pixels that can be computed
+ (i.e. the number of SkPMColor values to be written by the sample proc).
+ This routine takes into account that filtering and scale-vs-affine
+ affect the amount of buffer space needed.
Only valid to call after chooseProcs (setContext) has been called. It is
safe to call this inside the shader's shadeSpan() method.
diff --git a/src/core/SkBitmapProcState_matrixProcs.cpp b/src/core/SkBitmapProcState_matrixProcs.cpp
index 6654312..d0bc8d8 100644
--- a/src/core/SkBitmapProcState_matrixProcs.cpp
+++ b/src/core/SkBitmapProcState_matrixProcs.cpp
@@ -368,7 +368,7 @@ static void clampx_nofilter_trans(const SkBitmapProcState& s,
}
// fill the remaining with the max value
- sk_memset16(xptr, width - 1, count * sizeof(uint16_t));
+ sk_memset16(xptr, width - 1, count);
}
static void repeatx_nofilter_trans(const SkBitmapProcState& s,
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 45b4c35..b3ce813 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -789,7 +789,7 @@ static bool map_radius(const SkMatrix& matrix, SkScalar* value) {
matrix.mapVectors(dst, src, 2);
SkScalar len0 = fast_len(dst[0]);
SkScalar len1 = fast_len(dst[1]);
- if (len0 < SK_Scalar1 && len1 < SK_Scalar1) {
+ if (len0 <= SK_Scalar1 && len1 <= SK_Scalar1) {
*value = SkScalarAve(len0, len1);
return true;
}
diff --git a/src/core/SkGraphics.cpp b/src/core/SkGraphics.cpp
index 65a16e2..40f0ea3 100644
--- a/src/core/SkGraphics.cpp
+++ b/src/core/SkGraphics.cpp
@@ -374,3 +374,15 @@ bool SkGraphics::SetFontCacheUsed(size_t usageInBytes) {
return SkGlyphCache::SetCacheUsed(usageInBytes);
}
+void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) {
+ if (major) {
+ *major = SKIA_VERSION_MAJOR;
+ }
+ if (minor) {
+ *minor = SKIA_VERSION_MINOR;
+ }
+ if (patch) {
+ *patch = SKIA_VERSION_PATCH;
+ }
+}
+
diff --git a/src/core/SkRegion.cpp b/src/core/SkRegion.cpp
index 032dc81..a5a1555 100644
--- a/src/core/SkRegion.cpp
+++ b/src/core/SkRegion.cpp
@@ -783,7 +783,13 @@ static int operate( const SkRegion::RunType a_runs[],
SkRegion::RunType dst[],
SkRegion::Op op)
{
- const SkRegion::RunType sentinel = SkRegion::kRunTypeSentinel;
+ const SkRegion::RunType gSentinel[] = {
+ SkRegion::kRunTypeSentinel,
+ // just need a 2nd value, since spanRec.init() reads 2 values, even
+ // though if the first value is the sentinel, it ignores the 2nd value.
+ // w/o the 2nd value here, we might read uninitialized memory.
+ 0,
+ };
int a_top = *a_runs++;
int a_bot = *a_runs++;
@@ -803,8 +809,8 @@ static int operate( const SkRegion::RunType a_runs[],
while (a_bot < SkRegion::kRunTypeSentinel || b_bot < SkRegion::kRunTypeSentinel)
{
int top, bot SK_INIT_TO_AVOID_WARNING;
- const SkRegion::RunType* run0 = &sentinel;
- const SkRegion::RunType* run1 = &sentinel;
+ const SkRegion::RunType* run0 = gSentinel;
+ const SkRegion::RunType* run1 = gSentinel;
bool a_flush = false;
bool b_flush = false;
int inside;
@@ -854,7 +860,7 @@ static int operate( const SkRegion::RunType a_runs[],
}
if (top > prevBot)
- oper.addSpan(top, &sentinel, &sentinel);
+ oper.addSpan(top, gSentinel, gSentinel);
// if ((unsigned)(inside - oper.fMin) <= (unsigned)(oper.fMax - oper.fMin))
{
diff --git a/src/effects/SkPorterDuff.cpp b/src/effects/SkPorterDuff.cpp
index 3ee4b19..58447ad 100644
--- a/src/effects/SkPorterDuff.cpp
+++ b/src/effects/SkPorterDuff.cpp
@@ -29,8 +29,7 @@ static const struct Pair {
MAKE_PAIR(Lighten),
MAKE_PAIR(Multiply),
MAKE_PAIR(Screen),
- { SkPorterDuff::kAdd_Mode, SkXfermode::kPlus_Mode },
- MAKE_PAIR(Overlay)
+ { SkPorterDuff::kAdd_Mode, SkXfermode::kPlus_Mode }
};
static bool find_pdmode(SkXfermode::Mode src, SkPorterDuff::Mode* dst) {
diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp
index ef5b7ac..52e9e4f 100644
--- a/src/images/SkImageDecoder_libico.cpp
+++ b/src/images/SkImageDecoder_libico.cpp
@@ -351,7 +351,7 @@ static void editPixelBit24(const int pixelNo, const unsigned char* buf,
int alphaBit = (alphaByte & m) >> shift;
//alphaBit == 1 => alpha = 0
int alpha = (alphaBit-1) & 0xFF;
- *address = SkPackARGB32(alpha, red & alpha, green & alpha, blue & alpha);
+ *address = SkPreMultiplyARGB(alpha, red, green, blue);
}
static void editPixelBit32(const int pixelNo, const unsigned char* buf,
@@ -364,7 +364,7 @@ static void editPixelBit32(const int pixelNo, const unsigned char* buf,
int red = readByte(buf, xorOffset + 4*pixelNo + 2);
int alphaBit = (alphaByte & m) >> shift;
int alpha = readByte(buf, xorOffset + 4*pixelNo + 3) & ((alphaBit-1)&0xFF);
- *address = SkPackARGB32(alpha, red & alpha, green & alpha, blue & alpha);
+ *address = SkPreMultiplyARGB(alpha, red, green, blue);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/utils/SkCullPoints.cpp b/src/utils/SkCullPoints.cpp
index 23d00b6..03bfa99 100644
--- a/src/utils/SkCullPoints.cpp
+++ b/src/utils/SkCullPoints.cpp
@@ -18,8 +18,7 @@
#include "SkCullPoints.h"
#include "Sk64.h"
-static bool cross_product_is_neg(const SkIPoint& v, int dx, int dy)
-{
+static bool cross_product_is_neg(const SkIPoint& v, int dx, int dy) {
#if 0
return v.fX * dy - v.fY * dx < 0;
#else
@@ -32,19 +31,20 @@ static bool cross_product_is_neg(const SkIPoint& v, int dx, int dy)
#endif
}
-bool SkCullPoints::sect_test(int x0, int y0, int x1, int y1) const
-{
+bool SkCullPoints::sect_test(int x0, int y0, int x1, int y1) const {
const SkIRect& r = fR;
- if (x0 < r.fLeft && x1 < r.fLeft ||
- x0 > r.fRight && x1 > r.fRight ||
- y0 < r.fTop && y1 < r.fTop ||
- y0 > r.fBottom && y1 > r.fBottom)
+ if ((x0 < r.fLeft && x1 < r.fLeft) ||
+ (x0 > r.fRight && x1 > r.fRight) ||
+ (y0 < r.fTop && y1 < r.fTop) ||
+ (y0 > r.fBottom && y1 > r.fBottom)) {
return false;
+ }
// since the crossprod test is a little expensive, check for easy-in cases first
- if (r.contains(x0, y0) || r.contains(x1, y1))
+ if (r.contains(x0, y0) || r.contains(x1, y1)) {
return true;
+ }
// At this point we're not sure, so we do a crossprod test
SkIPoint vec;
@@ -53,16 +53,14 @@ bool SkCullPoints::sect_test(int x0, int y0, int x1, int y1) const
vec.set(x1 - x0, y1 - y0);
bool isNeg = cross_product_is_neg(vec, x0 - rAsQuad[0].fX, y0 - rAsQuad[0].fY);
for (int i = 1; i < 4; i++) {
- if (cross_product_is_neg(vec, x0 - rAsQuad[i].fX, y0 - rAsQuad[i].fY) != isNeg)
- {
+ if (cross_product_is_neg(vec, x0 - rAsQuad[i].fX, y0 - rAsQuad[i].fY) != isNeg) {
return true;
}
}
return false; // we didn't intersect
}
-static void toQuad(const SkIRect& r, SkIPoint quad[4])
-{
+static void toQuad(const SkIRect& r, SkIPoint quad[4]) {
SkASSERT(quad);
quad[0].set(r.fLeft, r.fTop);
@@ -71,34 +69,29 @@ static void toQuad(const SkIRect& r, SkIPoint quad[4])
quad[3].set(r.fLeft, r.fBottom);
}
-SkCullPoints::SkCullPoints()
-{
+SkCullPoints::SkCullPoints() {
SkIRect r;
r.setEmpty();
this->reset(r);
}
-SkCullPoints::SkCullPoints(const SkIRect& r)
-{
+SkCullPoints::SkCullPoints(const SkIRect& r) {
this->reset(r);
}
-void SkCullPoints::reset(const SkIRect& r)
-{
+void SkCullPoints::reset(const SkIRect& r) {
fR = r;
toQuad(fR, fAsQuad);
fPrevPt.set(0, 0);
fPrevResult = kNo_Result;
}
-void SkCullPoints::moveTo(int x, int y)
-{
+void SkCullPoints::moveTo(int x, int y) {
fPrevPt.set(x, y);
fPrevResult = kNo_Result; // so we trigger a movetolineto later
}
-SkCullPoints::LineToResult SkCullPoints::lineTo(int x, int y, SkIPoint line[])
-{
+SkCullPoints::LineToResult SkCullPoints::lineTo(int x, int y, SkIPoint line[]) {
SkASSERT(line != NULL);
LineToResult result = kNo_Result;
@@ -108,15 +101,15 @@ SkCullPoints::LineToResult SkCullPoints::lineTo(int x, int y, SkIPoint line[])
// need to upgrade sect_test to chop the result
// and to correctly return kLineTo_Result when the result is connected
// to the previous call-out
- if (this->sect_test(x0, y0, x, y))
- {
+ if (this->sect_test(x0, y0, x, y)) {
line[0].set(x0, y0);
line[1].set(x, y);
- if (fPrevResult != kNo_Result && fPrevPt.equals(x0, y0))
+ if (fPrevResult != kNo_Result && fPrevPt.equals(x0, y0)) {
result = kLineTo_Result;
- else
+ } else {
result = kMoveToLineTo_Result;
+ }
}
fPrevPt.set(x, y);
@@ -130,28 +123,23 @@ SkCullPoints::LineToResult SkCullPoints::lineTo(int x, int y, SkIPoint line[])
#include "SkPath.h"
SkCullPointsPath::SkCullPointsPath()
- : fCP(), fPath(NULL)
-{
+ : fCP(), fPath(NULL) {
}
SkCullPointsPath::SkCullPointsPath(const SkIRect& r, SkPath* dst)
- : fCP(r), fPath(dst)
-{
+ : fCP(r), fPath(dst) {
}
-void SkCullPointsPath::reset(const SkIRect& r, SkPath* dst)
-{
+void SkCullPointsPath::reset(const SkIRect& r, SkPath* dst) {
fCP.reset(r);
fPath = dst;
}
-
-void SkCullPointsPath::moveTo(int x, int y)
-{
+
+void SkCullPointsPath::moveTo(int x, int y) {
fCP.moveTo(x, y);
}
-void SkCullPointsPath::lineTo(int x, int y)
-{
+void SkCullPointsPath::lineTo(int x, int y) {
SkIPoint pts[2];
switch (fCP.lineTo(x, y, pts)) {
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 737307c..4ff7a50 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -121,8 +121,7 @@ static void toString(const SkBitmap& bm, SkString* str) {
}
static void toString(const void* text, size_t len, SkPaint::TextEncoding enc,
- SkString* str, const SkPaint& paint,
- const SkScalar xpos[] = NULL) {
+ SkString* str) {
switch (enc) {
case SkPaint::kUTF8_TextEncoding:
str->printf("\"%.*s\"%s", SkMax32(len, 32), text,
@@ -132,21 +131,9 @@ static void toString(const void* text, size_t len, SkPaint::TextEncoding enc,
str->printf("\"%.*S\"%s", SkMax32(len, 32), text,
len > 64 ? "..." : "");
break;
- case SkPaint::kGlyphID_TextEncoding: {
- const uint16_t* glyphs = (const uint16_t*)text;
- const int max = 32;
- SkUnichar uni[max];
- int count = SkMin32(len >> 1, max);
- paint.glyphsToUnichars(glyphs, count, uni);
- str->append("\"");
- for (int i = 0; i < count; i++) {
- str->appendUnichar(uni[i]);
- }
- if ((size_t)count < (len >> 1)) {
- str->append("...");
- }
- str->append("\"");
- } break;
+ case SkPaint::kGlyphID_TextEncoding:
+ str->set("<glyphs>");
+ break;
}
}
@@ -331,7 +318,7 @@ void SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
void SkDumpCanvas::drawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, const SkPaint& paint) {
SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str, paint);
+ toString(text, byteLength, paint.getTextEncoding(), &str);
this->dump(kDrawText_Verb, &paint, "drawText(%s [%d] %g %g)", str.c_str(),
byteLength, SkScalarToFloat(x), SkScalarToFloat(y));
}
@@ -339,7 +326,7 @@ void SkDumpCanvas::drawText(const void* text, size_t byteLength, SkScalar x,
void SkDumpCanvas::drawPosText(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint) {
SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str, paint);
+ toString(text, byteLength, paint.getTextEncoding(), &str);
this->dump(kDrawText_Verb, &paint, "drawPosText(%s [%d] %g %g ...)",
str.c_str(), byteLength, SkScalarToFloat(pos[0].fX),
SkScalarToFloat(pos[0].fY));
@@ -349,7 +336,7 @@ void SkDumpCanvas::drawPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY,
const SkPaint& paint) {
SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str, paint, xpos);
+ toString(text, byteLength, paint.getTextEncoding(), &str);
this->dump(kDrawText_Verb, &paint, "drawPosTextH(%s [%d] %g %g ...)",
str.c_str(), byteLength, SkScalarToFloat(xpos[0]),
SkScalarToFloat(constY));
@@ -359,7 +346,7 @@ void SkDumpCanvas::drawTextOnPath(const void* text, size_t byteLength,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint) {
SkString str;
- toString(text, byteLength, paint.getTextEncoding(), &str, paint);
+ toString(text, byteLength, paint.getTextEncoding(), &str);
this->dump(kDrawText_Verb, &paint, "drawTextOnPath(%s [%d])",
str.c_str(), byteLength);
}
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index dec93de..4bfbd94 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -1,4 +1,5 @@
#include "Test.h"
+#include "SkFloatingPoint.h"
#include "SkPoint.h"
#include "SkRandom.h"