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

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

Issue 2895953003: Use SkJpegEncoder in gfx jpeg_codec (Closed)
Patch Set: Remove brackets 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 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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 1414
1415 // Add the bitmap to an image object and add the image object to the output 1415 // Add the bitmap to an image object and add the image object to the output
1416 // page. 1416 // page.
1417 FPDF_PAGEOBJECT temp_img = FPDFPageObj_NewImageObj(temp_doc); 1417 FPDF_PAGEOBJECT temp_img = FPDFPageObj_NewImageObj(temp_doc);
1418 1418
1419 std::vector<uint8_t> compressed_bitmap_data; 1419 std::vector<uint8_t> compressed_bitmap_data;
1420 // Use quality = 40 as this does not significantly degrade the printed 1420 // Use quality = 40 as this does not significantly degrade the printed
1421 // document relative to a normal bitmap and provides better compression than 1421 // document relative to a normal bitmap and provides better compression than
1422 // a higher quality setting. 1422 // a higher quality setting.
1423 const int quality = 40; 1423 const int quality = 40;
1424 SkImageInfo info = SkImageInfo::Make(
Lei Zhang 2017/06/16 21:22:37 We are doing a bit more work than before for a bra
1425 FPDFBitmap_GetWidth(bitmap), FPDFBitmap_GetHeight(bitmap),
1426 kBGRA_8888_SkColorType, kOpaque_SkAlphaType);
1427 SkPixmap src(info, bitmap_data, FPDFBitmap_GetStride(bitmap));
1424 if (!(print_settings.format & PP_PRINTOUTPUTFORMAT_PDF) && 1428 if (!(print_settings.format & PP_PRINTOUTPUTFORMAT_PDF) &&
1425 (gfx::JPEGCodec::Encode( 1429 (gfx::JPEGCodec::Encode(src, quality, &compressed_bitmap_data))) {
1426 bitmap_data, gfx::JPEGCodec::FORMAT_BGRA, FPDFBitmap_GetWidth(bitmap),
1427 FPDFBitmap_GetHeight(bitmap), FPDFBitmap_GetStride(bitmap), quality,
1428 &compressed_bitmap_data))) {
1429 FPDF_FILEACCESS file_access = {}; 1430 FPDF_FILEACCESS file_access = {};
1430 file_access.m_FileLen = 1431 file_access.m_FileLen =
1431 static_cast<unsigned long>(compressed_bitmap_data.size()); 1432 static_cast<unsigned long>(compressed_bitmap_data.size());
1432 file_access.m_GetBlock = &GetBlockForJpeg; 1433 file_access.m_GetBlock = &GetBlockForJpeg;
1433 file_access.m_Param = &compressed_bitmap_data; 1434 file_access.m_Param = &compressed_bitmap_data;
1434 1435
1435 FPDFImageObj_LoadJpegFileInline(&temp_page, 1, temp_img, &file_access); 1436 FPDFImageObj_LoadJpegFileInline(&temp_page, 1, temp_img, &file_access);
1436 } else { 1437 } else {
1437 FPDFImageObj_SetBitmap(&temp_page, 1, temp_img, bitmap); 1438 FPDFImageObj_SetBitmap(&temp_page, 1, temp_img, bitmap);
1438 } 1439 }
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after
4134 FPDF_DOCUMENT doc = 4135 FPDF_DOCUMENT doc =
4135 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 4136 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
4136 if (!doc) 4137 if (!doc)
4137 return false; 4138 return false;
4138 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4139 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4139 FPDF_CloseDocument(doc); 4140 FPDF_CloseDocument(doc);
4140 return success; 4141 return success;
4141 } 4142 }
4142 4143
4143 } // namespace chrome_pdf 4144 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « media/gpu/jpeg_decode_accelerator_unittest.cc ('k') | services/data_decoder/image_decoder_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698