diff options
Diffstat (limited to 'printing')
-rw-r--r-- | printing/metafile_impl.h | 9 | ||||
-rw-r--r-- | printing/pdf_metafile_skia.cc | 32 | ||||
-rw-r--r-- | printing/pdf_metafile_skia.h | 10 |
3 files changed, 48 insertions, 3 deletions
diff --git a/printing/metafile_impl.h b/printing/metafile_impl.h index d25481d..a40e9b1 100644 --- a/printing/metafile_impl.h +++ b/printing/metafile_impl.h @@ -7,11 +7,13 @@ #if defined(OS_WIN) #include "printing/emf_win.h" -#include "printing/pdf_metafile_skia.h" #elif defined(OS_MACOSX) #include "printing/pdf_metafile_cg_mac.h" #elif defined(OS_POSIX) #include "printing/pdf_metafile_cairo_linux.h" +#endif + +#if !defined(OS_MACOSX) || defined(USE_SKIA) #include "printing/pdf_metafile_skia.h" #endif @@ -21,8 +23,13 @@ namespace printing { typedef Emf NativeMetafile; typedef PdfMetafileSkia PreviewMetafile; #elif defined(OS_MACOSX) +#if defined(USE_SKIA) +typedef PdfMetafileSkia NativeMetafile; +typedef PdfMetafileSkia PreviewMetafile; +#else typedef PdfMetafileCg NativeMetafile; typedef PdfMetafileCg PreviewMetafile; +#endif #elif defined(OS_POSIX) typedef PdfMetafileCairo NativeMetafile; typedef PdfMetafileSkia PreviewMetafile; diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc index bcb5af93..d335545 100644 --- a/printing/pdf_metafile_skia.cc +++ b/printing/pdf_metafile_skia.cc @@ -22,12 +22,19 @@ #include "ui/gfx/rect.h" #include "ui/gfx/size.h" +#if defined(OS_MACOSX) +#include "printing/pdf_metafile_cg_mac.h" +#endif + namespace printing { struct PdfMetafileSkiaData { SkRefPtr<SkPDFDevice> current_page_; SkPDFDocument pdf_doc_; SkDynamicMemoryWStream pdf_stream_; +#if defined(OS_MACOSX) + PdfMetafileCg pdf_cg_; +#endif }; PdfMetafileSkia::~PdfMetafileSkia() {} @@ -166,7 +173,30 @@ HENHMETAFILE PdfMetafileSkia::emf() const { NOTREACHED(); return NULL; } -#endif // if defined(OS_WIN) +#elif defined(OS_MACOSX) +/* TODO(caryclark): The set up of PluginInstance::PrintPDFOutput may result in + rasterized output. Even if that flow uses PdfMetafileCg::RenderPage, + the drawing of the PDF into the canvas may result in a rasterized output. + PDFMetafileSkia::RenderPage should be not implemented as shown and instead + should do something like the following CL in PluginInstance::PrintPDFOutput: +http://codereview.chromium.org/7200040/diff/1/webkit/plugins/ppapi/ppapi_plugin_instance.cc +*/ +bool PdfMetafileSkia::RenderPage(unsigned int page_number, + CGContextRef context, + const CGRect rect, + bool shrink_to_fit, + bool stretch_to_fit, + bool center_horizontally, + bool center_vertically) const { + DCHECK_GT(data_->pdf_stream_.getOffset(), 0U); + if (data_->pdf_cg_.GetDataSize() == 0) + data_->pdf_cg_.InitFromData(data_->pdf_stream_.getStream(), + data_->pdf_stream_.getOffset()); + return data_->pdf_cg_.RenderPage(page_number, context, rect, shrink_to_fit, + stretch_to_fit, center_horizontally, + center_vertically); +} +#endif #if defined(OS_CHROMEOS) bool PdfMetafileSkia::SaveToFD(const base::FileDescriptor& fd) const { diff --git a/printing/pdf_metafile_skia.h b/printing/pdf_metafile_skia.h index 3d1c7bd..2b8c7c1 100644 --- a/printing/pdf_metafile_skia.h +++ b/printing/pdf_metafile_skia.h @@ -54,7 +54,15 @@ class PdfMetafileSkia : public Metafile { virtual bool Playback(gfx::NativeDrawingContext hdc, const RECT* rect) const; virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const; virtual HENHMETAFILE emf() const; -#endif // if defined(OS_WIN) +#elif defined(OS_MACOSX) + virtual bool RenderPage(unsigned int page_number, + CGContextRef context, + const CGRect rect, + bool shrink_to_fit, + bool stretch_to_fit, + bool center_horizontally, + bool center_vertically) const; +#endif #if defined(OS_CHROMEOS) virtual bool SaveToFD(const base::FileDescriptor& fd) const; |