| Index: content/renderer/pepper/pepper_plugin_instance_impl.cc
|
| diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
|
| index bb02dbee9f4bae1328332c385836a1440a336d44..c80fe6bd5639e7f1ad68d5478054d3717d3e748e 100644
|
| --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
|
| +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
|
| @@ -478,8 +478,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
|
| layer_bound_to_fullscreen_(false),
|
| layer_is_hardware_(false),
|
| plugin_url_(plugin_url),
|
| - document_url_(container ? GURL(container->document().url())
|
| - : GURL()),
|
| + document_url_(container ? GURL(container->document().url()) : GURL()),
|
| is_flash_plugin_(module->name() == kFlashPluginName),
|
| has_been_clicked_(false),
|
| javascript_used_(false),
|
| @@ -499,6 +498,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
|
| plugin_textinput_interface_(NULL),
|
| checked_for_plugin_input_event_interface_(false),
|
| checked_for_plugin_pdf_interface_(false),
|
| + metafile_(nullptr),
|
| gamepad_impl_(new GamepadImpl()),
|
| uma_private_impl_(NULL),
|
| plugin_print_interface_(NULL),
|
| @@ -1798,7 +1798,7 @@ int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) {
|
| if (!num_pages)
|
| return 0;
|
| current_print_settings_ = print_settings;
|
| - canvas_.reset();
|
| + metafile_ = nullptr;
|
| ranges_.clear();
|
| return num_pages;
|
| }
|
| @@ -1810,16 +1810,17 @@ void PepperPluginInstanceImpl::PrintPage(int page_number,
|
| PP_PrintPageNumberRange_Dev page_range;
|
| page_range.first_page_number = page_range.last_page_number = page_number;
|
| // The canvas only has a metafile on it for print preview.
|
| - bool save_for_later =
|
| - (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL);
|
| + printing::PdfMetafileSkia* metafile =
|
| + printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas);
|
| + bool save_for_later = (metafile != NULL);
|
| #if defined(OS_MACOSX)
|
| save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas);
|
| #endif // defined(OS_MACOSX)
|
| if (save_for_later) {
|
| ranges_.push_back(page_range);
|
| - canvas_ = sk_ref_sp(canvas);
|
| + metafile_ = metafile;
|
| } else {
|
| - PrintPageHelper(&page_range, 1, canvas);
|
| + PrintPageHelper(&page_range, 1, metafile);
|
| }
|
| #endif
|
| }
|
| @@ -1827,7 +1828,7 @@ void PepperPluginInstanceImpl::PrintPage(int page_number,
|
| void PepperPluginInstanceImpl::PrintPageHelper(
|
| PP_PrintPageNumberRange_Dev* page_ranges,
|
| int num_ranges,
|
| - blink::WebCanvas* canvas) {
|
| + printing::PdfMetafileSkia* metafile) {
|
| // Keep a reference on the stack. See NOTE above.
|
| scoped_refptr<PepperPluginInstanceImpl> ref(this);
|
| DCHECK(plugin_print_interface_);
|
| @@ -1839,7 +1840,7 @@ void PepperPluginInstanceImpl::PrintPageHelper(
|
| return;
|
|
|
| if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF)
|
| - PrintPDFOutput(print_output, canvas);
|
| + PrintPDFOutput(print_output, metafile);
|
|
|
| // Now we need to release the print output resource.
|
| PluginModule::GetCore()->ReleaseResource(print_output);
|
| @@ -1849,8 +1850,8 @@ void PepperPluginInstanceImpl::PrintEnd() {
|
| // Keep a reference on the stack. See NOTE above.
|
| scoped_refptr<PepperPluginInstanceImpl> ref(this);
|
| if (!ranges_.empty())
|
| - PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get());
|
| - canvas_.reset();
|
| + PrintPageHelper(&(ranges_.front()), ranges_.size(), metafile_);
|
| + metafile_ = nullptr;
|
| ranges_.clear();
|
|
|
| DCHECK(plugin_print_interface_);
|
| @@ -2017,8 +2018,9 @@ bool PepperPluginInstanceImpl::IsViewAccelerated() {
|
| return view->isAcceleratedCompositingActive();
|
| }
|
|
|
| -bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output,
|
| - blink::WebCanvas* canvas) {
|
| +bool PepperPluginInstanceImpl::PrintPDFOutput(
|
| + PP_Resource print_output,
|
| + printing::PdfMetafileSkia* metafile) {
|
| #if BUILDFLAG(ENABLE_PRINTING)
|
| ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true);
|
| if (enter.failed())
|
| @@ -2030,8 +2032,6 @@ bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output,
|
| return false;
|
| }
|
|
|
| - printing::PdfMetafileSkia* metafile =
|
| - printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas);
|
| if (metafile)
|
| return metafile->InitFromData(mapper.data(), mapper.size());
|
|
|
|
|