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

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

Issue 2509983004: Revert "Change call-sites now that SkCanvas is not ref-counted" (Closed)
Patch Set: Created 4 years, 1 month 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 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 print_settings.dpi = print_params.printerDPI; 1791 print_settings.dpi = print_params.printerDPI;
1792 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; 1792 print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
1793 print_settings.grayscale = PP_FALSE; 1793 print_settings.grayscale = PP_FALSE;
1794 print_settings.print_scaling_option = 1794 print_settings.print_scaling_option =
1795 static_cast<PP_PrintScalingOption_Dev>(print_params.printScalingOption); 1795 static_cast<PP_PrintScalingOption_Dev>(print_params.printScalingOption);
1796 print_settings.format = format; 1796 print_settings.format = format;
1797 num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); 1797 num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings);
1798 if (!num_pages) 1798 if (!num_pages)
1799 return 0; 1799 return 0;
1800 current_print_settings_ = print_settings; 1800 current_print_settings_ = print_settings;
1801 canvas_ = nullptr; 1801 canvas_.reset();
1802 ranges_.clear(); 1802 ranges_.clear();
1803 return num_pages; 1803 return num_pages;
1804 } 1804 }
1805 1805
1806 void PepperPluginInstanceImpl::PrintPage(int page_number, 1806 void PepperPluginInstanceImpl::PrintPage(int page_number,
1807 blink::WebCanvas* canvas) { 1807 blink::WebCanvas* canvas) {
1808 #if BUILDFLAG(ENABLE_PRINTING) 1808 #if BUILDFLAG(ENABLE_PRINTING)
1809 DCHECK(plugin_print_interface_); 1809 DCHECK(plugin_print_interface_);
1810 PP_PrintPageNumberRange_Dev page_range; 1810 PP_PrintPageNumberRange_Dev page_range;
1811 page_range.first_page_number = page_range.last_page_number = page_number; 1811 page_range.first_page_number = page_range.last_page_number = page_number;
1812 // The canvas only has a metafile on it for print preview. 1812 // The canvas only has a metafile on it for print preview.
1813 bool save_for_later = 1813 bool save_for_later =
1814 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); 1814 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL);
1815 #if defined(OS_MACOSX) 1815 #if defined(OS_MACOSX)
1816 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); 1816 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas);
1817 #endif // defined(OS_MACOSX) 1817 #endif // defined(OS_MACOSX)
1818 if (save_for_later) { 1818 if (save_for_later) {
1819 ranges_.push_back(page_range); 1819 ranges_.push_back(page_range);
1820 canvas_ = canvas; 1820 canvas_ = sk_ref_sp(canvas);
1821 } else { 1821 } else {
1822 PrintPageHelper(&page_range, 1, canvas); 1822 PrintPageHelper(&page_range, 1, canvas);
1823 } 1823 }
1824 #endif 1824 #endif
1825 } 1825 }
1826 1826
1827 void PepperPluginInstanceImpl::PrintPageHelper( 1827 void PepperPluginInstanceImpl::PrintPageHelper(
1828 PP_PrintPageNumberRange_Dev* page_ranges, 1828 PP_PrintPageNumberRange_Dev* page_ranges,
1829 int num_ranges, 1829 int num_ranges,
1830 blink::WebCanvas* canvas) { 1830 blink::WebCanvas* canvas) {
(...skipping 11 matching lines...) Expand all
1842 PrintPDFOutput(print_output, canvas); 1842 PrintPDFOutput(print_output, canvas);
1843 1843
1844 // Now we need to release the print output resource. 1844 // Now we need to release the print output resource.
1845 PluginModule::GetCore()->ReleaseResource(print_output); 1845 PluginModule::GetCore()->ReleaseResource(print_output);
1846 } 1846 }
1847 1847
1848 void PepperPluginInstanceImpl::PrintEnd() { 1848 void PepperPluginInstanceImpl::PrintEnd() {
1849 // Keep a reference on the stack. See NOTE above. 1849 // Keep a reference on the stack. See NOTE above.
1850 scoped_refptr<PepperPluginInstanceImpl> ref(this); 1850 scoped_refptr<PepperPluginInstanceImpl> ref(this);
1851 if (!ranges_.empty()) 1851 if (!ranges_.empty())
1852 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_); 1852 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get());
1853 canvas_ = nullptr; 1853 canvas_.reset();
1854 ranges_.clear(); 1854 ranges_.clear();
1855 1855
1856 DCHECK(plugin_print_interface_); 1856 DCHECK(plugin_print_interface_);
1857 if (plugin_print_interface_) 1857 if (plugin_print_interface_)
1858 plugin_print_interface_->End(pp_instance()); 1858 plugin_print_interface_->End(pp_instance());
1859 1859
1860 memset(&current_print_settings_, 0, sizeof(current_print_settings_)); 1860 memset(&current_print_settings_, 0, sizeof(current_print_settings_));
1861 #if defined(OS_MACOSX) 1861 #if defined(OS_MACOSX)
1862 last_printed_page_ = NULL; 1862 last_printed_page_ = NULL;
1863 #endif // defined(OS_MACOSX) 1863 #endif // defined(OS_MACOSX)
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 const cc::TextureMailbox& mailbox) const { 3436 const cc::TextureMailbox& mailbox) const {
3437 auto it = 3437 auto it =
3438 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(), 3438 std::find_if(texture_ref_counts_.begin(), texture_ref_counts_.end(),
3439 [&mailbox](const TextureMailboxRefCount& ref_count) { 3439 [&mailbox](const TextureMailboxRefCount& ref_count) {
3440 return ref_count.first.mailbox() == mailbox.mailbox(); 3440 return ref_count.first.mailbox() == mailbox.mailbox();
3441 }); 3441 });
3442 return it != texture_ref_counts_.end(); 3442 return it != texture_ref_counts_.end();
3443 } 3443 }
3444 3444
3445 } // namespace content 3445 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.h ('k') | content/renderer/pepper/ppb_image_data_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698