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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 2947533002: Potentially do less work in PDFiumEngine::CreateSinglePageRasterPdf(). (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index afc8b71633bcd2bbab24880da6b033316bfe63a9..28e80d07ef888662aa6eff8681f948d0b3282407 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -1416,17 +1416,20 @@ FPDF_DOCUMENT PDFiumEngine::CreateSinglePageRasterPdf(
// page.
FPDF_PAGEOBJECT temp_img = FPDFPageObj_NewImageObj(temp_doc);
+ bool encoded = false;
std::vector<uint8_t> compressed_bitmap_data;
- // Use quality = 40 as this does not significantly degrade the printed
- // document relative to a normal bitmap and provides better compression than
- // a higher quality setting.
- const int quality = 40;
- SkImageInfo info = SkImageInfo::Make(
- FPDFBitmap_GetWidth(bitmap), FPDFBitmap_GetHeight(bitmap),
- kBGRA_8888_SkColorType, kOpaque_SkAlphaType);
- SkPixmap src(info, bitmap_data, FPDFBitmap_GetStride(bitmap));
- if (!(print_settings.format & PP_PRINTOUTPUTFORMAT_PDF) &&
- (gfx::JPEGCodec::Encode(src, quality, &compressed_bitmap_data))) {
+ if (!(print_settings.format & PP_PRINTOUTPUTFORMAT_PDF)) {
+ // Use quality = 40 as this does not significantly degrade the printed
+ // document relative to a normal bitmap and provides better compression than
+ // a higher quality setting.
+ const int kQuality = 40;
+ SkImageInfo info = SkImageInfo::Make(
+ FPDFBitmap_GetWidth(bitmap), FPDFBitmap_GetHeight(bitmap),
+ kBGRA_8888_SkColorType, kOpaque_SkAlphaType);
+ SkPixmap src(info, bitmap_data, FPDFBitmap_GetStride(bitmap));
+ encoded = gfx::JPEGCodec::Encode(src, kQuality, &compressed_bitmap_data);
+ }
+ if (encoded) {
FPDF_FILEACCESS file_access = {};
file_access.m_FileLen =
static_cast<unsigned long>(compressed_bitmap_data.size());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698