Index: src/core/SkPath.cpp |
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp |
index 2cb33e20127879c7ab65354e19ba59fc4cd0fca2..f8280bd6d21651724dd9e3501055d9e2754b975d 100644 |
--- a/src/core/SkPath.cpp |
+++ b/src/core/SkPath.cpp |
@@ -2021,24 +2021,11 @@ size_t SkPath::readFromMemory(const void* storage, size_t length) { |
/////////////////////////////////////////////////////////////////////////////// |
-#include "SkString.h" |
+#include "SkStringUtils.h" |
#include "SkStream.h" |
-static void append_scalar(SkString* str, SkScalar value, bool dumpAsHex) { |
- if (dumpAsHex) { |
- str->appendf("SkBits2Float(0x%08x)", SkFloat2Bits(value)); |
- return; |
- } |
- SkString tmp; |
- tmp.printf("%g", value); |
- if (tmp.contains('.')) { |
- tmp.appendUnichar('f'); |
- } |
- str->append(tmp); |
-} |
- |
static void append_params(SkString* str, const char label[], const SkPoint pts[], |
- int count, bool dumpAsHex, SkScalar conicWeight = -1) { |
+ int count, SkScalarAsStringType strType, SkScalar conicWeight = -1) { |
str->append(label); |
str->append("("); |
@@ -2046,33 +2033,34 @@ static void append_params(SkString* str, const char label[], const SkPoint pts[] |
count *= 2; |
for (int i = 0; i < count; ++i) { |
- append_scalar(str, values[i], dumpAsHex); |
+ SkAppendScalar(str, values[i], strType); |
if (i < count - 1) { |
str->append(", "); |
} |
} |
if (conicWeight >= 0) { |
str->append(", "); |
- append_scalar(str, conicWeight, dumpAsHex); |
+ SkAppendScalar(str, conicWeight, strType); |
} |
str->append(");"); |
- if (dumpAsHex) { |
+ if (kHex_SkScalarAsStringType == strType) { |
str->append(" // "); |
for (int i = 0; i < count; ++i) { |
- append_scalar(str, values[i], false); |
+ SkAppendScalarDec(str, values[i]); |
if (i < count - 1) { |
str->append(", "); |
} |
} |
if (conicWeight >= 0) { |
str->append(", "); |
- append_scalar(str, conicWeight, false); |
+ SkAppendScalarDec(str, conicWeight); |
} |
} |
str->append("\n"); |
} |
void SkPath::dump(SkWStream* wStream, bool forceClose, bool dumpAsHex) const { |
+ SkScalarAsStringType asType = dumpAsHex ? kHex_SkScalarAsStringType : kDec_SkScalarAsStringType; |
Iter iter(*this, forceClose); |
SkPoint pts[4]; |
Verb verb; |
@@ -2085,19 +2073,19 @@ void SkPath::dump(SkWStream* wStream, bool forceClose, bool dumpAsHex) const { |
while ((verb = iter.next(pts, false)) != kDone_Verb) { |
switch (verb) { |
case kMove_Verb: |
- append_params(&builder, "path.moveTo", &pts[0], 1, dumpAsHex); |
+ append_params(&builder, "path.moveTo", &pts[0], 1, asType); |
break; |
case kLine_Verb: |
- append_params(&builder, "path.lineTo", &pts[1], 1, dumpAsHex); |
+ append_params(&builder, "path.lineTo", &pts[1], 1, asType); |
break; |
case kQuad_Verb: |
- append_params(&builder, "path.quadTo", &pts[1], 2, dumpAsHex); |
+ append_params(&builder, "path.quadTo", &pts[1], 2, asType); |
break; |
case kConic_Verb: |
- append_params(&builder, "path.conicTo", &pts[1], 2, dumpAsHex, iter.conicWeight()); |
+ append_params(&builder, "path.conicTo", &pts[1], 2, asType, iter.conicWeight()); |
break; |
case kCubic_Verb: |
- append_params(&builder, "path.cubicTo", &pts[1], 3, dumpAsHex); |
+ append_params(&builder, "path.cubicTo", &pts[1], 3, asType); |
break; |
case kClose_Verb: |
builder.append("path.close();\n"); |