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

Unified Diff: src/pdf/SkPDFStream.h

Issue 1304493002: SkPDF: Simplify PDFStream / emitObject() const (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: formatting 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
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/pdf/SkPDFStream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFStream.h
diff --git a/src/pdf/SkPDFStream.h b/src/pdf/SkPDFStream.h
index d29d9b19badc352071c0866173b282d166af8888..c5961d42b1a6b0d45075d6350070206adbdd182c 100644
--- a/src/pdf/SkPDFStream.h
+++ b/src/pdf/SkPDFStream.h
@@ -27,50 +27,38 @@ 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();
// The SkPDFObject interface.
void emitObject(SkWStream* stream,
const SkPDFObjNumMap& objNumMap,
- const SkPDFSubstituteMap& substitutes) override;
+ const SkPDFSubstituteMap& substitutes) const 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.
- };
-
/* 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;
};
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/pdf/SkPDFStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698