Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1741 print_settings.dpi = print_params.printerDPI; | 1741 print_settings.dpi = print_params.printerDPI; |
| 1742 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; | 1742 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; |
| 1743 print_settings.grayscale = PP_FALSE; | 1743 print_settings.grayscale = PP_FALSE; |
| 1744 print_settings.print_scaling_option = | 1744 print_settings.print_scaling_option = |
| 1745 static_cast<PP_PrintScalingOption_Dev>(print_params.printScalingOption); | 1745 static_cast<PP_PrintScalingOption_Dev>(print_params.printScalingOption); |
| 1746 print_settings.format = format; | 1746 print_settings.format = format; |
| 1747 num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); | 1747 num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); |
| 1748 if (!num_pages) | 1748 if (!num_pages) |
| 1749 return 0; | 1749 return 0; |
| 1750 current_print_settings_ = print_settings; | 1750 current_print_settings_ = print_settings; |
| 1751 canvas_.clear(); | 1751 canvas_.reset(); |
| 1752 ranges_.clear(); | 1752 ranges_.clear(); |
| 1753 return num_pages; | 1753 return num_pages; |
| 1754 } | 1754 } |
| 1755 | 1755 |
| 1756 void PepperPluginInstanceImpl::PrintPage(int page_number, | 1756 void PepperPluginInstanceImpl::PrintPage(int page_number, |
| 1757 blink::WebCanvas* canvas) { | 1757 blink::WebCanvas* canvas) { |
| 1758 #if defined(ENABLE_PRINTING) | 1758 #if defined(ENABLE_PRINTING) |
| 1759 DCHECK(plugin_print_interface_); | 1759 DCHECK(plugin_print_interface_); |
| 1760 PP_PrintPageNumberRange_Dev page_range; | 1760 PP_PrintPageNumberRange_Dev page_range; |
| 1761 page_range.first_page_number = page_range.last_page_number = page_number; | 1761 page_range.first_page_number = page_range.last_page_number = page_number; |
| 1762 // The canvas only has a metafile on it for print preview. | 1762 // The canvas only has a metafile on it for print preview. |
| 1763 bool save_for_later = | 1763 bool save_for_later = |
| 1764 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); | 1764 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); |
| 1765 #if defined(OS_MACOSX) | 1765 #if defined(OS_MACOSX) |
| 1766 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); | 1766 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); |
| 1767 #endif // defined(OS_MACOSX) | 1767 #endif // defined(OS_MACOSX) |
| 1768 if (save_for_later) { | 1768 if (save_for_later) { |
| 1769 ranges_.push_back(page_range); | 1769 ranges_.push_back(page_range); |
| 1770 canvas_ = skia::SharePtr(canvas); | 1770 canvas_ = sk_sp<SkCanvas>(canvas); |
|
piman
2016/04/06 18:23:29
Shouldn't this be sk_ref_sp?
f(malita)
2016/04/06 18:37:21
+1
tomhudson
2016/04/06 19:00:23
Done.
| |
| 1771 } else { | 1771 } else { |
| 1772 PrintPageHelper(&page_range, 1, canvas); | 1772 PrintPageHelper(&page_range, 1, canvas); |
| 1773 } | 1773 } |
| 1774 #endif | 1774 #endif |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 void PepperPluginInstanceImpl::PrintPageHelper( | 1777 void PepperPluginInstanceImpl::PrintPageHelper( |
| 1778 PP_PrintPageNumberRange_Dev* page_ranges, | 1778 PP_PrintPageNumberRange_Dev* page_ranges, |
| 1779 int num_ranges, | 1779 int num_ranges, |
| 1780 blink::WebCanvas* canvas) { | 1780 blink::WebCanvas* canvas) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1793 | 1793 |
| 1794 // Now we need to release the print output resource. | 1794 // Now we need to release the print output resource. |
| 1795 PluginModule::GetCore()->ReleaseResource(print_output); | 1795 PluginModule::GetCore()->ReleaseResource(print_output); |
| 1796 } | 1796 } |
| 1797 | 1797 |
| 1798 void PepperPluginInstanceImpl::PrintEnd() { | 1798 void PepperPluginInstanceImpl::PrintEnd() { |
| 1799 // Keep a reference on the stack. See NOTE above. | 1799 // Keep a reference on the stack. See NOTE above. |
| 1800 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1800 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1801 if (!ranges_.empty()) | 1801 if (!ranges_.empty()) |
| 1802 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); | 1802 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); |
| 1803 canvas_.clear(); | 1803 canvas_.reset(); |
| 1804 ranges_.clear(); | 1804 ranges_.clear(); |
| 1805 | 1805 |
| 1806 DCHECK(plugin_print_interface_); | 1806 DCHECK(plugin_print_interface_); |
| 1807 if (plugin_print_interface_) | 1807 if (plugin_print_interface_) |
| 1808 plugin_print_interface_->End(pp_instance()); | 1808 plugin_print_interface_->End(pp_instance()); |
| 1809 | 1809 |
| 1810 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); | 1810 memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); |
| 1811 #if defined(OS_MACOSX) | 1811 #if defined(OS_MACOSX) |
| 1812 last_printed_page_ = NULL; | 1812 last_printed_page_ = NULL; |
| 1813 #endif // defined(OS_MACOSX) | 1813 #endif // defined(OS_MACOSX) |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3322 } | 3322 } |
| 3323 | 3323 |
| 3324 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const { | 3324 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const { |
| 3325 rect->set_x(rect->x() / viewport_to_dip_scale_); | 3325 rect->set_x(rect->x() / viewport_to_dip_scale_); |
| 3326 rect->set_y(rect->y() / viewport_to_dip_scale_); | 3326 rect->set_y(rect->y() / viewport_to_dip_scale_); |
| 3327 rect->set_width(rect->width() / viewport_to_dip_scale_); | 3327 rect->set_width(rect->width() / viewport_to_dip_scale_); |
| 3328 rect->set_height(rect->height() / viewport_to_dip_scale_); | 3328 rect->set_height(rect->height() / viewport_to_dip_scale_); |
| 3329 } | 3329 } |
| 3330 | 3330 |
| 3331 } // namespace content | 3331 } // namespace content |
| OLD | NEW |