blob: 64aecc01d59bcd352a005db03bc93e70086081c5 [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"
[email protected]7226b33c2011-08-18 08:44:2210#include "base/memory/scoped_ptr.h"
[email protected]8f879292011-04-08 00:21:2011#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]69f5b1e62011-09-01 06:34:0423class PRINTING_EXPORT 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]d85a45c2011-11-16 17:28:5329 virtual bool Init() OVERRIDE;
30 virtual bool InitFromData(const void* src_buffer,
31 uint32 src_buffer_size) OVERRIDE;
[email protected]8f879292011-04-08 00:21:2032
[email protected]62f2e802011-05-26 14:28:3533 virtual SkDevice* StartPageForVectorCanvas(
[email protected]8f879292011-04-08 00:21:2034 const gfx::Size& page_size,
[email protected]39892b92011-04-30 02:24:4435 const gfx::Rect& content_area,
[email protected]d85a45c2011-11-16 17:28:5336 const float& scale_factor) OVERRIDE;
[email protected]62f2e802011-05-26 14:28:3537
[email protected]8f879292011-04-08 00:21:2038 virtual bool StartPage(const gfx::Size& page_size,
[email protected]39892b92011-04-30 02:24:4439 const gfx::Rect& content_area,
[email protected]d85a45c2011-11-16 17:28:5340 const float& scale_factor) OVERRIDE;
41 virtual bool FinishPage() OVERRIDE;
42 virtual bool FinishDocument() OVERRIDE;
[email protected]8f879292011-04-08 00:21:2043
[email protected]d85a45c2011-11-16 17:28:5344 virtual uint32 GetDataSize() const OVERRIDE;
45 virtual bool GetData(void* dst_buffer, uint32 dst_buffer_size) const OVERRIDE;
[email protected]8f879292011-04-08 00:21:2046
[email protected]d85a45c2011-11-16 17:28:5347 virtual bool SaveTo(const FilePath& file_path) const OVERRIDE;
[email protected]8f879292011-04-08 00:21:2048
[email protected]d85a45c2011-11-16 17:28:5349 virtual gfx::Rect GetPageBounds(unsigned int page_number) const OVERRIDE;
50 virtual unsigned int GetPageCount() const OVERRIDE;
[email protected]8f879292011-04-08 00:21:2051
[email protected]d85a45c2011-11-16 17:28:5352 virtual gfx::NativeDrawingContext context() const OVERRIDE;
[email protected]8f879292011-04-08 00:21:2053
54#if defined(OS_WIN)
[email protected]d85a45c2011-11-16 17:28:5355 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;
[email protected]b8d85bc2011-06-22 13:34:5759#elif defined(OS_MACOSX)
60 virtual bool RenderPage(unsigned int page_number,
61 CGContextRef context,
62 const CGRect rect,
63 bool shrink_to_fit,
64 bool stretch_to_fit,
65 bool center_horizontally,
[email protected]d85a45c2011-11-16 17:28:5366 bool center_vertically) const OVERRIDE;
[email protected]b8d85bc2011-06-22 13:34:5767#endif
[email protected]8f879292011-04-08 00:21:2068
69#if defined(OS_CHROMEOS)
[email protected]d85a45c2011-11-16 17:28:5370 virtual bool SaveToFD(const base::FileDescriptor& fd) const OVERRIDE;
[email protected]8f879292011-04-08 00:21:2071#endif // if defined(OS_CHROMEOS)
[email protected]c797a192011-06-15 16:25:0972
[email protected]597516372011-07-01 05:10:4473 // Return a new metafile containing just the current page in draft mode.
74 PdfMetafileSkia* GetMetafileForCurrentPage();
75
[email protected]8f879292011-04-08 00:21:2076 private:
[email protected]8f879292011-04-08 00:21:2077 scoped_ptr<PdfMetafileSkiaData> data_;
78
[email protected]534c4fb2011-08-02 16:44:2079 // True when finish page is outstanding for current page.
80 bool page_outstanding_;
[email protected]597516372011-07-01 05:10:4481
[email protected]8f879292011-04-08 00:21:2082 DISALLOW_COPY_AND_ASSIGN(PdfMetafileSkia);
83};
84
85} // namespace printing
86
[email protected]39892b92011-04-30 02:24:4487#endif // PRINTING_PDF_METAFILE_SKIA_H_