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

Unified Diff: src/pdf/SkPDFStream.cpp

Issue 2190883003: SkPDF: PDFStream has-a not is-a PDFDict (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-07-29 (Friday) 12:30:20 EDT Created 4 years, 5 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/pdf/SkPDFTypes.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
deleted file mode 100644
index a661456c5d913773f931343b7d5343038d6fa222..0000000000000000000000000000000000000000
--- a/src/pdf/SkPDFStream.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#include "SkData.h"
-#include "SkDeflate.h"
-#include "SkPDFStream.h"
-#include "SkStreamPriv.h"
-
-SkPDFStream::~SkPDFStream() {}
-
-void SkPDFStream::drop() {
- fCompressedData.reset(nullptr);
- this->SkPDFDict::drop();
-}
-
-void SkPDFStream::emitObject(SkWStream* stream,
- const SkPDFObjNumMap& objNumMap,
- const SkPDFSubstituteMap& substitutes) const {
- SkASSERT(fCompressedData);
- this->INHERITED::emitObject(stream, objNumMap, substitutes);
- // duplicate (a cheap operation) preserves const on fCompressedData.
- std::unique_ptr<SkStreamAsset> dup(fCompressedData->duplicate());
- SkASSERT(dup);
- SkASSERT(dup->hasLength());
- stream->writeText(" stream\n");
- stream->writeStream(dup.get(), dup->getLength());
- stream->writeText("\nendstream");
-}
-
-void SkPDFStream::setData(std::unique_ptr<SkStreamAsset> stream) {
- SkASSERT(!fCompressedData); // Only call this function once.
- SkASSERT(stream);
- // Code assumes that the stream starts at the beginning.
-
- #ifdef SK_PDF_LESS_COMPRESSION
- fCompressedData = std::move(stream);
- SkASSERT(fCompressedData && fCompressedData->hasLength());
- this->insertInt("Length", fCompressedData->getLength());
- #else
-
- SkASSERT(stream->hasLength());
- SkDynamicMemoryWStream compressedData;
- SkDeflateWStream deflateWStream(&compressedData);
- SkStreamCopy(&deflateWStream, stream.get());
- deflateWStream.finalize();
- size_t compressedLength = compressedData.bytesWritten();
- size_t originalLength = stream->getLength();
-
- if (originalLength <= compressedLength + strlen("/Filter_/FlateDecode_")) {
- SkAssertResult(stream->rewind());
- fCompressedData = std::move(stream);
- this->insertInt("Length", originalLength);
- return;
- }
- fCompressedData.reset(compressedData.detachAsStream());
- this->insertName("Filter", "FlateDecode");
- this->insertInt("Length", compressedLength);
- #endif
-}
« no previous file with comments | « src/pdf/SkPDFStream.h ('k') | src/pdf/SkPDFTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698