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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 2895953003: Use SkJpegEncoder in gfx jpeg_codec (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 // page. 1424 // page.
1425 FPDF_PAGEOBJECT temp_img = FPDFPageObj_NewImageObj(temp_doc); 1425 FPDF_PAGEOBJECT temp_img = FPDFPageObj_NewImageObj(temp_doc);
1426 1426
1427 std::vector<uint8_t> compressed_bitmap_data; 1427 std::vector<uint8_t> compressed_bitmap_data;
1428 // Use quality = 40 as this does not significantly degrade the printed 1428 // Use quality = 40 as this does not significantly degrade the printed
1429 // document relative to a normal bitmap and provides better compression than 1429 // document relative to a normal bitmap and provides better compression than
1430 // a higher quality setting. 1430 // a higher quality setting.
1431 const int quality = 40; 1431 const int quality = 40;
1432 if (!(print_settings.format & PP_PRINTOUTPUTFORMAT_PDF) && 1432 if (!(print_settings.format & PP_PRINTOUTPUTFORMAT_PDF) &&
1433 (gfx::JPEGCodec::Encode( 1433 (gfx::JPEGCodec::Encode(
1434 bitmap_data, gfx::JPEGCodec::FORMAT_BGRA, FPDFBitmap_GetWidth(bitmap), 1434 bitmap_data, kBGRA_8888_SkColorType, FPDFBitmap_GetWidth(bitmap),
1435 FPDFBitmap_GetHeight(bitmap), FPDFBitmap_GetStride(bitmap), quality, 1435 FPDFBitmap_GetHeight(bitmap), FPDFBitmap_GetStride(bitmap), quality,
1436 &compressed_bitmap_data))) { 1436 &compressed_bitmap_data))) {
1437 FPDF_FILEACCESS file_access = {}; 1437 FPDF_FILEACCESS file_access = {};
1438 file_access.m_FileLen = 1438 file_access.m_FileLen =
1439 static_cast<unsigned long>(compressed_bitmap_data.size()); 1439 static_cast<unsigned long>(compressed_bitmap_data.size());
1440 file_access.m_GetBlock = &GetBlockForJpeg; 1440 file_access.m_GetBlock = &GetBlockForJpeg;
1441 file_access.m_Param = &compressed_bitmap_data; 1441 file_access.m_Param = &compressed_bitmap_data;
1442 1442
1443 FPDFImageObj_LoadJpegFileInline(&temp_page, 1, temp_img, &file_access); 1443 FPDFImageObj_LoadJpegFileInline(&temp_page, 1, temp_img, &file_access);
1444 } else { 1444 } else {
(...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 FPDF_DOCUMENT doc = 4142 FPDF_DOCUMENT doc =
4143 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 4143 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
4144 if (!doc) 4144 if (!doc)
4145 return false; 4145 return false;
4146 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4146 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4147 FPDF_CloseDocument(doc); 4147 FPDF_CloseDocument(doc);
4148 return success; 4148 return success;
4149 } 4149 }
4150 4150
4151 } // namespace chrome_pdf 4151 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698