aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkStream.h1
-rw-r--r--src/core/SkStream.cpp6
-rw-r--r--src/pdf/SkPDFDevice.cpp3
-rw-r--r--src/pdf/SkPDFUtils.cpp8
4 files changed, 10 insertions, 8 deletions
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 5ea6bf3822..9e6c261cbe 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -395,6 +395,7 @@ public:
// copy what has been written to the stream into dst
void copyTo(void* dst) const;
+ void writeToStream(SkWStream* dst) const;
/**
* Return a copy of the data written so far. This call is responsible for
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);
}
}