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

Unified Diff: src/pdf/SkPDFStream.h

Issue 1227913008: SkPDF: Memory improvements for PDF Streams (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-18 (Tuesday) 16:37:32 EDT Created 5 years, 4 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
Index: src/pdf/SkPDFStream.h
diff --git a/src/pdf/SkPDFStream.h b/src/pdf/SkPDFStream.h
index d29d9b19badc352071c0866173b282d166af8888..ee062e9d1110df295ea17d936e35b68b4e365a54 100644
--- a/src/pdf/SkPDFStream.h
+++ b/src/pdf/SkPDFStream.h
@@ -27,15 +27,15 @@ class SkPDFStream : public SkPDFDict {
public:
/** Create a PDF stream. A Length entry is automatically added to the
* stream dictionary.
- * @param data The data part of the stream. Will be ref()ed.
+ * @param data The data part of the stream. Will not take ownership.
*/
- explicit SkPDFStream(SkData* data);
+ explicit SkPDFStream(SkData* data) { this->setData(data); }
/** Create a PDF stream. A Length entry is automatically added to the
* stream dictionary.
- * @param stream The data part of the stream. Will be duplicate()d.
+ * @param stream The data part of the stream. Will not take ownership.
*/
- explicit SkPDFStream(SkStream* stream);
+ explicit SkPDFStream(SkStream* stream) { this->setData(stream); }
virtual ~SkPDFStream();
@@ -45,32 +45,20 @@ public:
const SkPDFSubstituteMap& substitutes) override;
protected:
- enum State {
- kUnused_State, //!< The stream hasn't been requested yet.
- kNoCompression_State, //!< The stream's been requested in an
- // uncompressed form.
- kCompressed_State, //!< The stream's already been compressed.
tomhudson 2015/08/19 19:27:51 Presumably we're always keeping the stream compres
- };
-
/* Create a PDF stream with no data. The setData method must be called to
* set the data.
*/
- SkPDFStream();
+ SkPDFStream() {}
- void setData(SkData* data);
+ /** Only call this function once. */
void setData(SkStream* stream);
-
- size_t dataSize() const;
-
- void setState(State state) {
- fState = state;
+ void setData(SkData* data) {
+ SkMemoryStream memoryStream(data);
+ this->setData(&memoryStream);
}
private:
- // Indicates what form (or if) the stream has been requested.
- State fState;
-
- SkAutoTDelete<SkStreamRewindable> fDataStream;
+ SkAutoTDelete<SkStreamRewindable> fCompressedData;
typedef SkPDFDict INHERITED;
};

Powered by Google App Engine
This is Rietveld 408576698