blob: 3d1c7bd212392d47e3b3d5cde2915062b5d9f604 [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;
57#endif // if defined(OS_WIN)
58
59#if defined(OS_CHROMEOS)
[email protected]7d7489902011-04-11 21:54:0660 virtual bool SaveToFD(const base::FileDescriptor& fd) const;
[email protected]8f879292011-04-08 00:21:2061#endif // if defined(OS_CHROMEOS)
[email protected]c797a192011-06-15 16:25:0962
63 virtual void set_draft(bool draft) const;
64
[email protected]8f879292011-04-08 00:21:2065 private:
[email protected]8f879292011-04-08 00:21:2066 scoped_ptr<PdfMetafileSkiaData> data_;
67
[email protected]c797a192011-06-15 16:25:0968 // True when a draft version of metafile is requested.
69 mutable bool draft_;
70
[email protected]8f879292011-04-08 00:21:2071 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia);
72};
73
74} // namespace printing
75
[email protected]39892b92011-04-30 02:24:4476#endif // PRINTING_PDF_METAFILE_SKIA_H_