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

Unified Diff: src/pdf/SkPDFImageStream.cpp

Issue 22889020: Refactor SkPDFImage (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some nits Created 7 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/SkPDFImageStream.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFImageStream.cpp
diff --git a/src/pdf/SkPDFImageStream.cpp b/src/pdf/SkPDFImageStream.cpp
deleted file mode 100644
index 7130f2b7cab3cbcebfb2ea620cd1b010b5dce78b..0000000000000000000000000000000000000000
--- a/src/pdf/SkPDFImageStream.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2013 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 "SkFlate.h"
-#include "SkPDFCatalog.h"
-#include "SkPDFImageStream.h"
-#include "SkStream.h"
-
-#define kNoColorTransform 0
-
-static bool skip_compression(SkPDFCatalog* catalog) {
- return SkToBool(catalog->getDocumentFlags() &
- SkPDFDocument::kFavorSpeedOverSize_Flags);
-}
-
-// TODO(edisonn): Use SkData (after removing deprecated constructor in SkPDFStream).
-SkPDFImageStream::SkPDFImageStream(SkStream* stream,
- const SkBitmap& bitmap,
- const SkIRect& srcRect,
- EncodeToDCTStream encoder)
- : SkPDFStream(stream),
- fBitmap(bitmap),
- fSrcRect(srcRect),
- fEncoder(encoder) {
-}
-
-SkPDFImageStream::SkPDFImageStream(const SkPDFImageStream& pdfStream)
- : SkPDFStream(pdfStream),
- fBitmap(pdfStream.fBitmap),
- fSrcRect(pdfStream.fSrcRect),
- fEncoder(pdfStream.fEncoder) {
-}
-
-SkPDFImageStream::~SkPDFImageStream() {}
-
-bool SkPDFImageStream::populate(SkPDFCatalog* catalog) {
- if (getState() == kUnused_State) {
- if (!skip_compression(catalog)) {
- SkDynamicMemoryWStream dctCompressedWStream;
- if (!fEncoder || !fEncoder(&dctCompressedWStream, fBitmap, fSrcRect)) {
- return INHERITED::populate(catalog);
- }
-
- if (dctCompressedWStream.getOffset() < getData()->getLength()) {
- SkData* data = dctCompressedWStream.copyToData();
- SkMemoryStream* stream = SkNEW_ARGS(SkMemoryStream, (data));
- setData(stream);
- stream->unref();
- if (data) {
- // copyToData and new SkMemoryStream both call ref(), supress one.
- data->unref();
- }
-
- insertName("Filter", "DCTDecode");
- insertInt("ColorTransform", kNoColorTransform);
- setState(kCompressed_State);
- }
- }
- setState(kNoCompression_State);
- insertInt("Length", getData()->getLength());
- } else if (getState() == kNoCompression_State && !skip_compression(catalog) &&
- (SkFlate::HaveFlate() || fEncoder)) {
- // Compression has not been requested when the stream was first created.
- // But a new Catalog would want it compressed.
- if (!getSubstitute()) {
- SkPDFImageStream* substitute = SkNEW_ARGS(SkPDFImageStream, (*this));
- setSubstitute(substitute);
- catalog->setSubstitute(this, substitute);
- }
- return false;
- }
- return true;
-}
« no previous file with comments | « src/pdf/SkPDFImageStream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698