diff options
author | bsalomon <bsalomon@google.com> | 2015-08-18 09:20:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-18 09:20:09 -0700 |
commit | 5346983b2e0726b4009cc546b01c58a8919e6c36 (patch) | |
tree | d2b83b17e9f0c2482278d9b808199f95462d942d /src/core/SkStringUtils.cpp | |
parent | d55d13af4f73d00e9d8f95d233f977de3df83d05 (diff) |
Put clear and discard into GrBatch.
Review URL: https://codereview.chromium.org/1293563003
Diffstat (limited to 'src/core/SkStringUtils.cpp')
-rw-r--r-- | src/core/SkStringUtils.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/core/SkStringUtils.cpp b/src/core/SkStringUtils.cpp index 390de7f264..35e55570c3 100644 --- a/src/core/SkStringUtils.cpp +++ b/src/core/SkStringUtils.cpp @@ -35,3 +35,29 @@ void SkAppendScalar(SkString* str, SkScalar value, SkScalarAsStringType asType) } } +SkString SkTabString(const SkString& string, int tabCnt) { + if (tabCnt <= 0) { + return string; + } + SkString tabs; + for (int i = 0; i < tabCnt; ++i) { + tabs.append("\t"); + } + SkString result; + static const char newline[] = "\n"; + const char* input = string.c_str(); + int nextNL = SkStrFind(input, newline); + while (nextNL >= 0) { + if (nextNL > 0) { + result.append(tabs); + } + result.append(input, nextNL + 1); + input += nextNL + 1; + nextNL = SkStrFind(input, newline); + } + if (*input != '\0') { + result.append(tabs); + } + result.append(input); + return result; +} |