Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: src/pdf/SkPDFStream.cpp

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFStream.h ('k') | src/ports/SkFontConfigTypeface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFStream.cpp
diff --git a/src/pdf/SkPDFStream.cpp b/src/pdf/SkPDFStream.cpp
index 837de7a9698565a97a5bca2183d7ab48ea3e0360..5eaa6c28b69b3968247b0f72cc11f0dff2d3d0a5 100644
--- a/src/pdf/SkPDFStream.cpp
+++ b/src/pdf/SkPDFStream.cpp
@@ -61,25 +61,19 @@ void SkPDFStream::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
SkPDFStream::SkPDFStream() : fState(kUnused_State) {}
void SkPDFStream::setData(SkData* data) {
- fMemoryStream.setData(data);
- if (&fMemoryStream != fDataStream.get()) {
- fDataStream.reset(SkRef(&fMemoryStream));
- }
+ // FIXME: Don't swap if the data is the same.
+ fDataStream.reset(SkNEW_ARGS(SkMemoryStream, (data)));
}
void SkPDFStream::setData(SkStream* stream) {
// Code assumes that the stream starts at the beginning and is rewindable.
- if (&fMemoryStream == fDataStream.get()) {
- SkASSERT(&fMemoryStream != stream);
- fMemoryStream.setData(NULL);
- }
- SkASSERT(0 == fMemoryStream.getLength());
if (stream) {
// SkStreamRewindableFromSkStream will try stream->duplicate().
fDataStream.reset(SkStreamRewindableFromSkStream(stream));
SkASSERT(fDataStream.get());
} else {
- fDataStream.reset(SkRef(&fMemoryStream));
+ // Use an empty memory stream.
+ fDataStream.reset(SkNEW(SkMemoryStream));
}
}
@@ -97,7 +91,7 @@ bool SkPDFStream::populate(SkPDFCatalog* catalog) {
SkFlate::Deflate(fDataStream.get(), &compressedData));
SkAssertResult(fDataStream->rewind());
if (compressedData.getOffset() < this->dataSize()) {
- SkAutoTUnref<SkStream> compressed(
+ SkAutoTDelete<SkStream> compressed(
compressedData.detachAsStream());
this->setData(compressed.get());
insertName("Filter", "FlateDecode");
« no previous file with comments | « src/pdf/SkPDFStream.h ('k') | src/ports/SkFontConfigTypeface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698