aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-02-23 12:17:59 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-23 12:18:00 -0800
commit7af21501a61886cac94f0bd5e1c14be2dce9ae63 (patch)
treee4ebfeb6e19aa288edbbc35cc80605d9d8a7a18a /src
parent52057c870777b72971962e90f13475b31c9f635f (diff)
SkStream: Add SkDynamicMemoryWStream::writeToStream(SkWStream*)
Diffstat (limited to 'src')
-rw-r--r--src/core/SkStream.cpp6
-rw-r--r--src/pdf/SkPDFDevice.cpp3
-rw-r--r--src/pdf/SkPDFUtils.cpp8
3 files changed, 9 insertions, 8 deletions
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index 38432c4b69..65e1bee1a0 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -621,6 +621,12 @@ void SkDynamicMemoryWStream::copyTo(void* dst) const
}
}
+void SkDynamicMemoryWStream::writeToStream(SkWStream* dst) const {
+ for (Block* block = fHead; block != NULL; block = block->fNext) {
+ dst->write(block->start(), block->written());
+ }
+}
+
void SkDynamicMemoryWStream::padToAlign4()
{
// cast to remove unary-minus warning
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 90f0a4a7c8..b6acf34bec 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1321,8 +1321,7 @@ void SkPDFDevice::copyContentEntriesToData(ContentEntry* entry,
gsState.updateMatrix(entry->fState.fMatrix);
gsState.updateDrawingState(entry->fState);
- SkAutoDataUnref copy(entry->fContent.copyToData());
- data->write(copy->data(), copy->size());
+ entry->fContent.writeToStream(data);
entry = entry->fNext.get();
}
gsState.drainStack();
diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp
index e488f7da06..0a5be3b076 100644
--- a/src/pdf/SkPDFUtils.cpp
+++ b/src/pdf/SkPDFUtils.cpp
@@ -175,9 +175,7 @@ void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
case SkPath::kClose_Verb:
if (fillState != kSingleLine_SkipFillState) {
ClosePath(&currentSegment);
- SkData* data = currentSegment.copyToData();
- content->write(data->data(), data->size());
- data->unref();
+ currentSegment.writeToStream(content);
}
currentSegment.reset();
break;
@@ -187,9 +185,7 @@ void SkPDFUtils::EmitPath(const SkPath& path, SkPaint::Style paintStyle,
}
}
if (currentSegment.bytesWritten() > 0) {
- SkData* data = currentSegment.copyToData();
- content->write(data->data(), data->size());
- data->unref();
+ currentSegment.writeToStream(content);
}
}