PdfMetafileSkia gives out a SkCanvas, not a SkBaseDevice.
Motivation: hide SkPDFDevice and SkPDFDocument behind PdfMetafileSkia class.
pdf_metafile_skia.cc:
Implement GetVectorCanvasForNewPage.
Remove StartPageForVectorCanvas.
Own the SkCanvas pointer (current_page_canvas_).
Replace page_outstanding_ field with a method that checks to see
if current_page_canvas_ is NULL.
Implement SaveTo.
skia::VectorPlatformDeviceSkia
remove class
print_web_view_helper.cc
Remove calls to canvas->getTopDevice()->setDrawingArea(...); (SkDFDevice)
This API is no longer effective.
print_web_view_helper_linux.cc,
print_web_view_helper_mac.mm,
print_web_view_helper_pdf_win.cc:
call GetVectorCanvasForNewPage rather than StartPageForVectorCanvas
BUG=278148
Review URL: https://codereview.chromium.org/704813002
Cr-Commit-Position: refs/heads/master@{#303522}
diff --git a/printing/pdf_metafile_skia.h b/printing/pdf_metafile_skia.h
index bc75abd..58e928b 100644
--- a/printing/pdf_metafile_skia.h
+++ b/printing/pdf_metafile_skia.h
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "printing/metafile.h"
+#include "skia/ext/vector_canvas.h"
#if defined(OS_WIN)
#include <windows.h>
@@ -62,6 +63,8 @@
const MacRenderPageParams& params) const override;
#endif
+ bool SaveTo(base::File* file) const override;
+
#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
// TODO(vitalybuka): replace with SaveTo().
bool SaveToFD(const base::FileDescriptor& fd) const;
@@ -71,17 +74,18 @@
scoped_ptr<PdfMetafileSkia> GetMetafileForCurrentPage();
// This method calls StartPage and then returns an appropriate
- // VectorPlatformDevice implementation bound to the context created by
- // StartPage or NULL on error.
- SkBaseDevice* StartPageForVectorCanvas(const gfx::Size& page_size,
- const gfx::Rect& content_area,
- const float& scale_factor);
+ // VectorCanvas implementation bound to the context created by
+ // StartPage or NULL on error. The skia::VectorCanvas pointer that
+ // is returned is owned by this PdfMetafileSkia object and does not
+ // need to be ref()ed or unref()ed. The canvas will remain valid
+ // until FinishPage() or FinishDocument() is called.
+ skia::VectorCanvas* GetVectorCanvasForNewPage(const gfx::Size& page_size,
+ const gfx::Rect& content_area,
+ const float& scale_factor);
+
private:
scoped_ptr<PdfMetafileSkiaData> data_;
- // True when finish page is outstanding for current page.
- bool page_outstanding_;
-
DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia);
};