blob: 2b8c7c1c3235247163a1f649f8f6132bead08fdd [file] [log] [blame]
[email protected]8f879292011-04-08 00:21:201// 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.
4
5#ifndef PRINTING_PDF_METAFILE_SKIA_H_
6#define PRINTING_PDF_METAFILE_SKIA_H_
7
8#include "base/basictypes.h"
9#include "base/logging.h"
10#include "base/scoped_ptr.h"
11#include "build/build_config.h"
[email protected]7d7489902011-04-11 21:54:0612#include "printing/metafile.h"
[email protected]8f879292011-04-08 00:21:2013
14#if defined(OS_WIN)
15#include <windows.h>
16#endif
17
18namespace printing {
19
20struct PdfMetafileSkiaData;
21
22// This class uses Skia graphics library to generate a PDF document.
[email protected]7d7489902011-04-11 21:54:0623class PdfMetafileSkia : public Metafile {
[email protected]8f879292011-04-08 00:21:2024 public:
[email protected]7d7489902011-04-11 21:54:0625 PdfMetafileSkia();
[email protected]8f879292011-04-08 00:21:2026 virtual ~PdfMetafileSkia();
27
[email protected]7d7489902011-04-11 21:54:0628 // Metafile methods.
[email protected]8f879292011-04-08 00:21:2029 virtual bool Init();
30 virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size);
31
[email protected]62f2e802011-05-26 14:28:3532 virtual SkDevice* StartPageForVectorCanvas(
[email protected]8f879292011-04-08 00:21:2033 const gfx::Size& page_size,
[email protected]39892b92011-04-30 02:24:4434 const gfx::Rect& content_area,
[email protected]8f879292011-04-08 00:21:2035 const float& scale_factor);
[email protected]62f2e802011-05-26 14:28:3536
[email protected]8f879292011-04-08 00:21:2037 virtual bool StartPage(const gfx::Size& page_size,
[email protected]39892b92011-04-30 02:24:4438 const gfx::Rect& content_area,
[email protected]8f879292011-04-08 00:21:2039 const float& scale_factor);
40 virtual bool FinishPage();
41 virtual bool FinishDocument();
42
43 virtual uint32 GetDataSize() const;
44 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const;
45
46 virtual bool SaveTo(const FilePath& file_path) const;
47
48 virtual gfx::Rect GetPageBounds(unsigned int page_number) const;
49 virtual unsigned int GetPageCount() const;
50
51 virtual gfx::NativeDrawingContext context() const;
52
53#if defined(OS_WIN)
54 virtual bool Playback(gfx::NativeDrawingContext hdc, const RECT* rect) const;
55 virtual bool SafePlayback(gfx::NativeDrawingContext hdc) const;
56 virtual HENHMETAFILE emf() const;
[email protected]b8d85bc2011-06-22 13:34:5757#elif defined(OS_MACOSX)
58 virtual bool RenderPage(unsigned int page_number,
59 CGContextRef context,
60 const CGRect rect,
61 bool shrink_to_fit,
62 bool stretch_to_fit,
63 bool center_horizontally,
64 bool center_vertically) const;
65#endif
[email protected]8f879292011-04-08 00:21:2066
67#if defined(OS_CHROMEOS)
[email protected]7d7489902011-04-11 21:54:0668 virtual bool SaveToFD(const base::FileDescriptor& fd) const;
[email protected]8f879292011-04-08 00:21:2069#endif // if defined(OS_CHROMEOS)
[email protected]c797a192011-06-15 16:25:0970
71 virtual void set_draft(bool draft) const;
72
[email protected]8f879292011-04-08 00:21:2073 private:
[email protected]8f879292011-04-08 00:21:2074 scoped_ptr<PdfMetafileSkiaData> data_;
75
[email protected]c797a192011-06-15 16:25:0976 // True when a draft version of metafile is requested.
77 mutable bool draft_;
78
[email protected]8f879292011-04-08 00:21:2079 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia);
80};
81
82} // namespace printing
83
[email protected]39892b92011-04-30 02:24:4484#endif // PRINTING_PDF_METAFILE_SKIA_H_