diff options
author | caryclark@chromium.org <caryclark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-22 13:34:57 +0000 |
---|---|---|
committer | caryclark@chromium.org <caryclark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-22 13:34:57 +0000 |
commit | b8d85bcc99bf93261fbd3343864cf799e676de4e (patch) | |
tree | 16c3d95884bfa428068e0f4501522fc6db17773f /printing/pdf_metafile_skia.cc | |
parent | fba70e690af4246bb171380a8573cb2ea71358de (diff) | |
download | chromium_src-b8d85bcc99bf93261fbd3343864cf799e676de4e.zip chromium_src-b8d85bcc99bf93261fbd3343864cf799e676de4e.tar.gz chromium_src-b8d85bcc99bf93261fbd3343864cf799e676de4e.tar.bz2 |
Add support to use Skia printing from Mac.
Reference the CG metafile from the Skia
version, so CG can be used to pass the PDF
data to the OS X pipeline.
If Skia is enabled as the Mac rendering engine,
generate Skia PDF files instead of CG ones.
This change adds a code path that will be enabled
in the future, but does not modify any existing
code, so there is no functional change.
BUG=79463
TEST=none
Review URL: http://codereview.chromium.org/7120006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/pdf_metafile_skia.cc')
-rw-r--r-- | printing/pdf_metafile_skia.cc | 32 |
1 files changed, 31 insertions, 1 deletions
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 { |