Fix source repetition in debug traces.

This fix appeared in prior CL patchsets, but got lost through rebases
and CL splits.

Change-Id: I1befff3830b40740f1e52e3e88f74484122027ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/481680
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-12-08 16:44:53 -05:00 committed by SkCQ
parent 97f89808d1
commit 0ee3e0c959
2 changed files with 11 additions and 0 deletions

View File

@ -19,6 +19,7 @@ void SkVMDebugTrace::setTraceCoord(const SkIPoint& coord) {
}
void SkVMDebugTrace::setSource(std::string source) {
fSource.clear();
std::stringstream stream{std::move(source)};
while (stream.good()) {
fSource.push_back({});

View File

@ -23,6 +23,16 @@ DEF_TEST(SkVMDebugTraceSetSource, r) {
REPORTER_ASSERT(r, i.fSource[3] == "\t// third line");
}
DEF_TEST(SkVMDebugTraceSetSourceReplacesExistingText, r) {
SkSL::SkVMDebugTrace i;
i.setSource("One");
i.setSource("Two");
i.setSource("Three");
REPORTER_ASSERT(r, i.fSource.size() == 1);
REPORTER_ASSERT(r, i.fSource[0] == "Three");
}
DEF_TEST(SkVMDebugTraceWrite, r) {
SkSL::SkVMDebugTrace i;
i.fSource = {