diff options
author | 2013-08-20 17:06:22 +0000 | |
---|---|---|
committer | 2013-08-20 17:06:22 +0000 | |
commit | 54c538e9a55d7d3ef291587db819df3a3dad5de6 (patch) | |
tree | 3e1165c57c879ffd9e68d486c43d79444e9666ac /src | |
parent | ba0ca99b83d3e084811fd1764d227d850fab4d43 (diff) |
Revert "The CL adds libpoppler to DEPS and adds a libpoppler-cpp gyp target for Linux, Windows, and Mac. This does not currently change the GM tool to use poppler - that will be a refactor job in a separate CL."
This reverts commit r10823
TBR=richardlin@chromium.org
Review URL: https://codereview.chromium.org/23190020
git-svn-id: http://skia.googlecode.com/svn/trunk@10828 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/SkPDFRasterizer.cpp | 73 | ||||
-rw-r--r-- | src/utils/SkPDFRasterizer.h | 15 |
2 files changed, 0 insertions, 88 deletions
diff --git a/src/utils/SkPDFRasterizer.cpp b/src/utils/SkPDFRasterizer.cpp deleted file mode 100644 index 3fd2728a16..0000000000 --- a/src/utils/SkPDFRasterizer.cpp +++ /dev/null @@ -1,73 +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 <poppler-document.h> -#include <poppler-image.h> -#include <poppler-page.h> -#include <poppler-page-renderer.h> - -#include "SkPDFRasterizer.h" -#include "SkColorPriv.h" - -bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output) { - size_t size = pdf->getLength(); - void* buffer = sk_malloc_throw(size); - pdf->read(buffer, size); - - SkAutoTDelete<poppler::document> doc( - poppler::document::load_from_raw_data((const char*)buffer, 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; - } - - size_t width = image.width(), height = image.height(); - size_t rowSize = image.bytes_per_row(); - char *imgData = image.data(); - - SkBitmap bitmap; - bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); - if (!bitmap.allocPixels()) { - return false; - } - bitmap.eraseColor(SK_ColorWHITE); - SkPMColor* bitmapPixels = (SkPMColor*)bitmap.getPixels(); - - // do pixel-by-pixel copy to deal with RGBA ordering conversions - for (size_t y = 0; y < height; y++) { - char *rowData = imgData; - for (size_t 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; -} diff --git a/src/utils/SkPDFRasterizer.h b/src/utils/SkPDFRasterizer.h deleted file mode 100644 index 4a4083cc21..0000000000 --- a/src/utils/SkPDFRasterizer.h +++ /dev/null @@ -1,15 +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" - -bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output); - -#endif |