diff options
author | mtklein <mtklein@chromium.org> | 2015-03-11 11:55:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-11 11:55:14 -0700 |
commit | 22712569a5f37cd5a23573367cce96801e04b172 (patch) | |
tree | 860ef7756f6084f235b81c0f473e0c5fdee34e14 /src/utils | |
parent | cb251f1d0a8aa7f3e6f685b45046173fc05f4b92 (diff) |
Clean up poppler code.
We're not actually using it.
BUG=skia:3362
DOCS_PREVIEW= https://skia.org/?cl=1002493002
Review URL: https://codereview.chromium.org/1002493002
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/SkPDFRasterizer.cpp | 88 | ||||
-rw-r--r-- | src/utils/SkPDFRasterizer.h | 23 |
2 files changed, 0 insertions, 111 deletions
diff --git a/src/utils/SkPDFRasterizer.cpp b/src/utils/SkPDFRasterizer.cpp deleted file mode 100644 index d44dfa30b9..0000000000 --- a/src/utils/SkPDFRasterizer.cpp +++ /dev/null @@ -1,88 +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. - */ - -#ifdef SK_BUILD_FOR_WIN32 -#pragma warning(push) -#pragma warning(disable : 4530) -#endif - -#include "SkPDFRasterizer.h" -#include "SkColorPriv.h" - -#ifdef SK_BUILD_NATIVE_PDF_RENDERER -#include "SkPdfRenderer.h" -#endif // SK_BUILD_NATIVE_PDF_RENDERER - -#ifdef SK_BUILD_POPPLER -#include <poppler-document.h> -#include <poppler-image.h> -#include <poppler-page.h> -#include <poppler-page-renderer.h> -#endif // SK_BUILD_POPPLER - -#ifdef SK_BUILD_POPPLER -bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output) { - SkAutoTDelete<SkStream> streamDeleter(pdf); - size_t size = pdf->getLength(); - SkAutoFree buffer(sk_malloc_throw(size)); - pdf->read(buffer.get(), size); - - SkAutoTDelete<poppler::document> doc( - poppler::document::load_from_raw_data((const char*)buffer.get(), size)); - if (!doc.get() || doc->is_locked()) { - return false; - } - - SkAutoTDelete<poppler::page> page(doc->create_page(0)); - poppler::page_renderer renderer; - poppler::image image = renderer.render_page(page.get()); - - if (!image.is_valid() || image.format() != poppler::image::format_argb32) { - return false; - } - - int width = image.width(), height = image.height(); - size_t rowSize = image.bytes_per_row(); - char *imgData = image.data(); - - SkBitmap bitmap; - if (!bitmap.tryAllocN32Pixels(width, height)) { - return false; - } - bitmap.eraseColor(SK_ColorWHITE); - SkPMColor* bitmapPixels = (SkPMColor*)bitmap.getPixels(); - - // do pixel-by-pixel copy to deal with RGBA ordering conversions - for (int y = 0; y < height; y++) { - char *rowData = imgData; - for (int x = 0; x < width; x++) { - uint8_t a = rowData[3]; - uint8_t r = rowData[2]; - uint8_t g = rowData[1]; - uint8_t b = rowData[0]; - - *bitmapPixels = SkPreMultiplyARGB(a, r, g, b); - - bitmapPixels++; - rowData += 4; - } - imgData += rowSize; - } - - output->swap(bitmap); - - return true; -} -#endif // SK_BUILD_POPPLER - -#ifdef SK_BUILD_NATIVE_PDF_RENDERER -bool SkNativeRasterizePDF(SkStream* pdf, SkBitmap* output) { - SkAutoTDelete<SkStream> streamDeleter(pdf); - return SkPDFNativeRenderToBitmap(pdf, output); -} -#endif // SK_BUILD_NATIVE_PDF_RENDERER diff --git a/src/utils/SkPDFRasterizer.h b/src/utils/SkPDFRasterizer.h deleted file mode 100644 index 36bd086c74..0000000000 --- a/src/utils/SkPDFRasterizer.h +++ /dev/null @@ -1,23 +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. - */ -#ifndef SkPDFRasterizer_DEFINED -#define SkPDFRasterizer_DEFINED - -#include "SkBitmap.h" -#include "SkStream.h" - -#ifdef SK_BUILD_POPPLER -// Deletes pdf when finished. -bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output); -#endif // SK_BUILD_POPPLER - -#ifdef SK_BUILD_NATIVE_PDF_RENDERER -// Deletes pdf when finished. -bool SkNativeRasterizePDF(SkStream* pdf, SkBitmap* output); -#endif // SK_BUILD_NATIVE_PDF_RENDERER - -#endif |