Chromium Code Reviews| 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 1a5733521ac7dc79097c280024f61ccdd71483dc..eedf5cd6c3e2225dd089d67c5ce0f1b5c6ee2961 100644 |
| --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| @@ -94,9 +94,7 @@ |
| #include "ppapi/thunk/ppb_buffer_api.h" |
| #include "printing/metafile_skia_wrapper.h" |
| #include "printing/pdf_metafile_skia.h" |
| -#include "printing/units.h" |
| #include "skia/ext/platform_canvas.h" |
| -#include "skia/ext/platform_device.h" |
| #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| #include "third_party/WebKit/public/platform/WebGamepads.h" |
| #include "third_party/WebKit/public/platform/WebRect.h" |
| @@ -120,13 +118,9 @@ |
| #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| #include "third_party/WebKit/public/web/WebView.h" |
| #include "third_party/khronos/GLES2/gl2.h" |
| -#include "third_party/skia/include/core/SkCanvas.h" |
| -#include "third_party/skia/include/core/SkRect.h" |
| #include "ui/gfx/image/image_skia.h" |
| #include "ui/gfx/image/image_skia_rep.h" |
| #include "ui/gfx/range/range.h" |
| -#include "ui/gfx/rect_conversions.h" |
| -#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| #include "v8/include/v8.h" |
| #if defined(OS_CHROMEOS) |
| @@ -137,8 +131,6 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/win/windows_version.h" |
| #include "skia/ext/platform_canvas.h" |
| -#include "ui/gfx/codec/jpeg_codec.h" |
| -#include "ui/gfx/gdi_util.h" |
| #endif |
| using base::StringPrintf; |
| @@ -186,35 +178,6 @@ using blink::WebView; |
| namespace content { |
| -#if defined(OS_WIN) |
| -// Exported by pdf.dll |
| -typedef bool (*RenderPDFPageToDCProc)(const unsigned char* pdf_buffer, |
| - int buffer_size, |
| - int page_number, |
| - HDC dc, |
| - int dpi_x, |
| - int dpi_y, |
| - int bounds_origin_x, |
| - int bounds_origin_y, |
| - int bounds_width, |
| - int bounds_height, |
| - bool fit_to_bounds, |
| - bool stretch_to_bounds, |
| - bool keep_aspect_ratio, |
| - bool center_in_bounds, |
| - bool autorotate); |
| - |
| -void DrawEmptyRectangle(HDC dc) { |
| - // TODO(sanjeevr): This is a temporary hack. If we output a JPEG |
| - // to the EMF, the EnumEnhMetaFile call fails in the browser |
| - // process. The failure also happens if we output nothing here. |
| - // We need to investigate the reason for this failure and fix it. |
| - // In the meantime this temporary hack of drawing an empty |
| - // rectangle in the DC gets us by. |
| - Rectangle(dc, 0, 0, 0, 0); |
| -} |
| -#endif // defined(OS_WIN) |
| - |
| namespace { |
| // Check PP_TextInput_Type and ui::TextInputType are kept in sync. |
| @@ -1782,7 +1745,9 @@ int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) { |
| bool PepperPluginInstanceImpl::PrintPage(int page_number, |
| blink::WebCanvas* canvas) { |
| -#if defined(ENABLE_FULL_PRINTING) |
| +#if defined(ENABLE_PRINTING) && !defined(OS_ANDROID) |
|
Lei Zhang
2014/09/26 04:46:09
pepper_plugin_instance_impl.cc isn't even compiled
Vitaly Buka (NO REVIEWS)
2014/09/26 05:29:03
Oh, I didn't check then.
ENABLE_PRINTING was switc
|
| + // The only known users of ENABLE_PRINTING without ENABLE_FULL_PRINTING are |
| + // CEF (crbug.com/417967) and Android. |
|
raymes
2014/09/26 04:47:29
nit: might as well duplicate the comment below exa
Vitaly Buka (NO REVIEWS)
2014/09/26 05:29:03
Done.
|
| DCHECK(plugin_print_interface_); |
| PP_PrintPageNumberRange_Dev page_range; |
| page_range.first_page_number = page_range.last_page_number = page_number; |
| @@ -1799,7 +1764,7 @@ bool PepperPluginInstanceImpl::PrintPage(int page_number, |
| } else { |
| return PrintPageHelper(&page_range, 1, canvas); |
| } |
| -#else // defined(ENABLED_PRINTING) |
| +#else // ENABLE_PRINTING && !OS_ANDROID |
| return false; |
| #endif |
| } |
| @@ -1966,7 +1931,9 @@ bool PepperPluginInstanceImpl::IsViewAccelerated() { |
| bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output, |
| blink::WebCanvas* canvas) { |
| -#if defined(ENABLE_FULL_PRINTING) |
| +#if defined(ENABLE_PRINTING) && !defined(OS_ANDROID) |
| + // The only known users of ENABLE_PRINTING without ENABLE_FULL_PRINTING are |
| + // CEF (crbug.com/417967) and Android. Android does not call this code. |
|
raymes
2014/09/26 04:47:29
nit: Could you elaborate on why CEF needs to use t
Vitaly Buka (NO REVIEWS)
2014/09/26 05:29:03
After Lei's notice about Android we don't need any
|
| ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true); |
| if (enter.failed()) |
| return false; |
| @@ -1976,91 +1943,15 @@ bool PepperPluginInstanceImpl::PrintPDFOutput(PP_Resource print_output, |
| NOTREACHED(); |
| return false; |
| } |
| -#if defined(OS_WIN) |
| - // For Windows, we need the PDF DLL to render the output PDF to a DC. |
| - HMODULE pdf_module = GetModuleHandle(L"pdf.dll"); |
| - if (!pdf_module) |
| - return false; |
| - RenderPDFPageToDCProc render_proc = reinterpret_cast<RenderPDFPageToDCProc>( |
| - GetProcAddress(pdf_module, "RenderPDFPageToDC")); |
| - if (!render_proc) |
| - return false; |
| -#endif // defined(OS_WIN) |
| - bool ret = false; |
| -#if defined(OS_POSIX) && !defined(OS_ANDROID) |
| printing::PdfMetafileSkia* metafile = |
| printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); |
| - DCHECK(metafile != NULL); |
| if (metafile) |
| - ret = metafile->InitFromData(mapper.data(), mapper.size()); |
| -#elif defined(OS_WIN) |
| - printing::PdfMetafileSkia* metafile = |
| - printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); |
| - if (metafile) { |
| - // We only have a metafile when doing print preview, so we just want to |
| - // pass the PDF off to preview. |
| - ret = metafile->InitFromData(mapper.data(), mapper.size()); |
| - } else { |
| - // On Windows, we now need to render the PDF to the DC that backs the |
| - // supplied canvas. |
| - HDC dc = skia::BeginPlatformPaint(canvas); |
| - DrawEmptyRectangle(dc); |
| - gfx::Size size_in_pixels; |
| - size_in_pixels.set_width( |
| - printing::ConvertUnit(current_print_settings_.printable_area.size.width, |
| - static_cast<int>(printing::kPointsPerInch), |
| - current_print_settings_.dpi)); |
| - size_in_pixels.set_height(printing::ConvertUnit( |
| - current_print_settings_.printable_area.size.height, |
| - static_cast<int>(printing::kPointsPerInch), |
| - current_print_settings_.dpi)); |
| - // We need to scale down DC to fit an entire page into DC available area. |
| - // First, we'll try to use default scaling based on the 72dpi that is |
| - // used in webkit for printing. |
| - // If default scaling is not enough to fit the entire PDF without |
| - // Current metafile is based on screen DC and have current screen size. |
| - // Writing outside of those boundaries will result in the cut-off output. |
| - // On metafiles (this is the case here), scaling down will still record |
| - // original coordinates and we'll be able to print in full resolution. |
| - // Before playback we'll need to counter the scaling up that will happen |
| - // in the browser (printed_document_win.cc). |
| - double dynamic_scale = gfx::CalculatePageScale( |
| - dc, size_in_pixels.width(), size_in_pixels.height()); |
| - double page_scale = static_cast<double>(printing::kPointsPerInch) / |
| - static_cast<double>(current_print_settings_.dpi); |
| - |
| - if (dynamic_scale < page_scale) { |
| - page_scale = dynamic_scale; |
| - printing::MetafileSkiaWrapper::SetCustomScaleOnCanvas(*canvas, |
| - page_scale); |
| - } |
| - |
| - gfx::ScaleDC(dc, page_scale); |
| - |
| - ret = render_proc(static_cast<unsigned char*>(mapper.data()), |
| - mapper.size(), |
| - 0, |
| - dc, |
| - current_print_settings_.dpi, |
| - current_print_settings_.dpi, |
| - 0, |
| - 0, |
| - size_in_pixels.width(), |
| - size_in_pixels.height(), |
| - true, |
| - false, |
| - true, |
| - true, |
| - true); |
| - skia::EndPlatformPaint(canvas); |
| - } |
| -#endif // defined(OS_WIN) |
| + return metafile->InitFromData(mapper.data(), mapper.size()); |
| - return ret; |
| -#else // defined(ENABLE_FULL_PRINTING) |
| + NOTREACHED(); |
| +#endif // ENABLE_PRINTING && !OS_ANDROID |
| return false; |
| -#endif |
| } |
| void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) { |