1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_PDF_METAFILE_SKIA_H_
6 #define PRINTING_PDF_METAFILE_SKIA_H_
8 #include "base/basictypes.h"
9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "build/build_config.h"
12 #include "printing/metafile.h"
20 struct PdfMetafileSkiaData
;
22 // This class uses Skia graphics library to generate a PDF document.
23 class PRINTING_EXPORT PdfMetafileSkia
: public Metafile
{
26 virtual ~PdfMetafileSkia();
29 virtual bool Init() OVERRIDE
;
30 virtual bool InitFromData(const void* src_buffer
,
31 uint32 src_buffer_size
) OVERRIDE
;
33 virtual SkDevice
* StartPageForVectorCanvas(
34 const gfx::Size
& page_size
,
35 const gfx::Rect
& content_area
,
36 const float& scale_factor
) OVERRIDE
;
38 virtual bool StartPage(const gfx::Size
& page_size
,
39 const gfx::Rect
& content_area
,
40 const float& scale_factor
) OVERRIDE
;
41 virtual bool FinishPage() OVERRIDE
;
42 virtual bool FinishDocument() OVERRIDE
;
44 virtual uint32
GetDataSize() const OVERRIDE
;
45 virtual bool GetData(void* dst_buffer
, uint32 dst_buffer_size
) const OVERRIDE
;
47 virtual bool SaveTo(const FilePath
& file_path
) const OVERRIDE
;
49 virtual gfx::Rect
GetPageBounds(unsigned int page_number
) const OVERRIDE
;
50 virtual unsigned int GetPageCount() const OVERRIDE
;
52 virtual gfx::NativeDrawingContext
context() const OVERRIDE
;
55 virtual bool Playback(gfx::NativeDrawingContext hdc
,
56 const RECT
* rect
) const OVERRIDE
;
57 virtual bool SafePlayback(gfx::NativeDrawingContext hdc
) const OVERRIDE
;
58 virtual HENHMETAFILE
emf() const OVERRIDE
;
59 #elif defined(OS_MACOSX)
60 virtual bool RenderPage(unsigned int page_number
,
65 bool center_horizontally
,
66 bool center_vertically
) const OVERRIDE
;
69 #if defined(OS_CHROMEOS)
70 virtual bool SaveToFD(const base::FileDescriptor
& fd
) const OVERRIDE
;
71 #endif // if defined(OS_CHROMEOS)
73 // Return a new metafile containing just the current page in draft mode.
74 PdfMetafileSkia
* GetMetafileForCurrentPage();
77 scoped_ptr
<PdfMetafileSkiaData
> data_
;
79 // True when finish page is outstanding for current page.
80 bool page_outstanding_
;
82 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia
);
85 } // namespace printing
87 #endif // PRINTING_PDF_METAFILE_SKIA_H_