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

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 2524143003: Print Preview: Add option to rasterize PDFs and add JPEG compression. (Closed)
Patch Set: Change to match new Pdfium API Created 4 years 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 "content/renderer/pepper/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bit_cast.h" 10 #include "base/bit_cast.h"
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 1760
1761 void PepperPluginInstanceImpl::ReportGeometry() { 1761 void PepperPluginInstanceImpl::ReportGeometry() {
1762 // If this call was delayed, we may have transitioned back to fullscreen in 1762 // If this call was delayed, we may have transitioned back to fullscreen in
1763 // the mean time, so only report the geometry if we are actually in normal 1763 // the mean time, so only report the geometry if we are actually in normal
1764 // mode. 1764 // mode.
1765 if (container_ && !fullscreen_container_ && !flash_fullscreen_) 1765 if (container_ && !fullscreen_container_ && !flash_fullscreen_)
1766 container_->reportGeometry(); 1766 container_->reportGeometry();
1767 } 1767 }
1768 1768
1769 bool PepperPluginInstanceImpl::GetPreferredPrintOutputFormat( 1769 bool PepperPluginInstanceImpl::GetPreferredPrintOutputFormat(
1770 PP_PrintOutputFormat_Dev* format) { 1770 PP_PrintOutputFormat_Dev* format, const WebPrintParams& print_params) {
1771 // Keep a reference on the stack. See NOTE above. 1771 // Keep a reference on the stack. See NOTE above.
1772 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1772 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1773 if (!LoadPrintInterface()) 1773 if (!LoadPrintInterface())
1774 return false; 1774 return false;
1775 uint32_t supported_formats = 1775 uint32_t supported_formats =
1776 plugin_print_interface_->QuerySupportedFormats(pp_instance()); 1776 plugin_print_interface_->QuerySupportedFormats(pp_instance());
1777 if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF) { 1777 if ((supported_formats & PP_PRINTOUTPUTFORMAT_PDF) &&
1778 !print_params.rasterizePDF) {
1778 *format = PP_PRINTOUTPUTFORMAT_PDF; 1779 *format = PP_PRINTOUTPUTFORMAT_PDF;
1779 return true; 1780 return true;
1780 } 1781 }
1782 if (supported_formats & PP_PRINTOUTPUTFORMAT_RASTER) {
1783 *format = PP_PRINTOUTPUTFORMAT_RASTER;
1784 return true;
1785 }
1781 return false; 1786 return false;
1782 } 1787 }
1783 1788
1784 bool PepperPluginInstanceImpl::SupportsPrintInterface() { 1789 bool PepperPluginInstanceImpl::SupportsPrintInterface() {
1785 PP_PrintOutputFormat_Dev format; 1790 PP_PrintOutputFormat_Dev format;
1786 return GetPreferredPrintOutputFormat(&format); 1791 WebPrintParams params;
1792 params.rasterizePDF = false;
1793 return GetPreferredPrintOutputFormat(&format, params);
1787 } 1794 }
1788 1795
1789 bool PepperPluginInstanceImpl::IsPrintScalingDisabled() { 1796 bool PepperPluginInstanceImpl::IsPrintScalingDisabled() {
1790 DCHECK(plugin_print_interface_); 1797 DCHECK(plugin_print_interface_);
1791 if (!plugin_print_interface_) 1798 if (!plugin_print_interface_)
1792 return false; 1799 return false;
1793 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; 1800 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE;
1794 } 1801 }
1795 1802
1796 int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) { 1803 int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) {
1797 // Keep a reference on the stack. See NOTE above. 1804 // Keep a reference on the stack. See NOTE above.
1798 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1805 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1799 PP_PrintOutputFormat_Dev format; 1806 PP_PrintOutputFormat_Dev format;
1800 if (!GetPreferredPrintOutputFormat(&format)) { 1807 if (!GetPreferredPrintOutputFormat(&format, print_params)) {
1801 // PrintBegin should not have been called since SupportsPrintInterface 1808 // PrintBegin should not have been called since SupportsPrintInterface
1802 // would have returned false; 1809 // would have returned false;
1803 NOTREACHED(); 1810 NOTREACHED();
1804 return 0; 1811 return 0;
1805 } 1812 }
1806 int num_pages = 0; 1813 int num_pages = 0;
1807 PP_PrintSettings_Dev print_settings; 1814 PP_PrintSettings_Dev print_settings;
1808 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); 1815 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea);
1809 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); 1816 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea);
1810 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); 1817 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 // Keep a reference on the stack. See NOTE above. 1859 // Keep a reference on the stack. See NOTE above.
1853 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1860 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1854 DCHECK(plugin_print_interface_); 1861 DCHECK(plugin_print_interface_);
1855 if (!plugin_print_interface_) 1862 if (!plugin_print_interface_)
1856 return; 1863 return;
1857 PP_Resource print_output = plugin_print_interface_->PrintPages( 1864 PP_Resource print_output = plugin_print_interface_->PrintPages(
1858 pp_instance(), page_ranges, num_ranges); 1865 pp_instance(), page_ranges, num_ranges);
1859 if (!print_output) 1866 if (!print_output)
1860 return; 1867 return;
1861 1868
1862 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) 1869 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF ||
1870 current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER)
1863 PrintPDFOutput(print_output, metafile); 1871 PrintPDFOutput(print_output, metafile);
1864 1872
1865 // Now we need to release the print output resource. 1873 // Now we need to release the print output resource.
1866 PluginModule::GetCore()->ReleaseResource(print_output); 1874 PluginModule::GetCore()->ReleaseResource(print_output);
1867 } 1875 }
1868 1876
1869 void PepperPluginInstanceImpl::PrintEnd() { 1877 void PepperPluginInstanceImpl::PrintEnd() {
1870 // Keep a reference on the stack. See NOTE above. 1878 // Keep a reference on the stack. See NOTE above.
1871 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1879 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1872 if (!ranges_.empty()) 1880 if (!ranges_.empty())
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
3456 const cc::TextureMailbox& mailbox) const { 3464 const cc::TextureMailbox& mailbox) const {
3457 auto it = 3465 auto it =
3458 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), 3466 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(),
3459 [&mailbox](const TextureMailboxRefCount& ref_count) { 3467 [&mailbox](const TextureMailboxRefCount& ref_count) {
3460 return ref_count.first.mailbox() == mailbox.mailbox(); 3468 return ref_count.first.mailbox() == mailbox.mailbox();
3461 }); 3469 });
3462 return it != texture_ref_counts_.end(); 3470 return it != texture_ref_counts_.end();
3463 } 3471 }
3464 3472
3465 } // namespace content 3473 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698