Index: printing/pdf_metafile_skia.cc |
diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc |
index 54c1cf3568a074c0266841b46afa8ac18e219407..dd9149483fad62f8ab47a18d59c8b46c9ec9ac8f 100644 |
--- a/printing/pdf_metafile_skia.cc |
+++ b/printing/pdf_metafile_skia.cc |
@@ -24,6 +24,14 @@ |
#include "ui/gfx/geometry/safe_integer_conversions.h" |
#include "ui/gfx/skia_util.h" |
+#if defined(OS_MACOSX) |
+#include "printing/pdf_metafile_cg_mac.h" |
+#endif |
+ |
+#if defined(OS_POSIX) |
+#include "base/file_descriptor_posix.h" |
+#endif |
+ |
namespace { |
bool WriteAssetToBuffer(const SkStreamAsset* asset, |
@@ -96,6 +104,10 @@ |
float scale_factor_; |
SkSize size_; |
SkiaDocumentType type_; |
+ |
+#if defined(OS_MACOSX) |
+ PdfMetafileCg pdf_cg_; |
+#endif |
}; |
PdfMetafileSkia::~PdfMetafileSkia() {} |
@@ -242,6 +254,30 @@ |
bool PdfMetafileSkia::SafePlayback(skia::NativeDrawingContext hdc) const { |
NOTREACHED(); |
return false; |
+} |
+ |
+#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, |
+ const MacRenderPageParams& params) const { |
+ DCHECK_GT(GetDataSize(), 0U); |
+ if (data_->pdf_cg_.GetDataSize() == 0) { |
+ if (GetDataSize() == 0) |
+ return false; |
+ size_t length = data_->pdf_data_->getLength(); |
+ std::vector<uint8_t> buffer(length); |
+ (void)WriteAssetToBuffer(data_->pdf_data_.get(), &buffer[0], length); |
+ data_->pdf_cg_.InitFromData(&buffer[0], length); |
+ } |
+ return data_->pdf_cg_.RenderPage(page_number, context, rect, params); |
} |
#endif |