Index: src/core/SkStringUtils.cpp |
diff --git a/src/core/SkStringUtils.cpp b/src/core/SkStringUtils.cpp |
index 0f93b8e30dcdb46a81de9bf32f7f90c2b8e28267..390de7f264b599598366f54b38d724e9a6ac4afb 100644 |
--- a/src/core/SkStringUtils.cpp |
+++ b/src/core/SkStringUtils.cpp |
@@ -17,3 +17,21 @@ void SkAddFlagToString(SkString* string, bool flag, const char* flagStr, bool* n |
*needSeparator = true; |
} |
} |
+ |
+void SkAppendScalar(SkString* str, SkScalar value, SkScalarAsStringType asType) { |
+ switch (asType) { |
+ case kHex_SkScalarAsStringType: |
+ str->appendf("SkBits2Float(0x%08x)", SkFloat2Bits(value)); |
+ break; |
+ case kDec_SkScalarAsStringType: { |
+ SkString tmp; |
+ tmp.printf("%g", value); |
+ if (tmp.contains('.')) { |
+ tmp.appendUnichar('f'); |
+ } |
+ str->append(tmp); |
+ break; |
+ } |
+ } |
+} |
+ |