Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: printing/metafile.h

Issue 2839323002: Revert of printing::Metafile: Simplify OS_MACOSX-specific code path (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « printing/image_mac.cc ('k') | printing/pdf_metafile_cg_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PRINTING_METAFILE_H_ 5 #ifndef PRINTING_METAFILE_H_
6 #define PRINTING_METAFILE_H_ 6 #define PRINTING_METAFILE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "printing/native_drawing_context.h" 14 #include "printing/native_drawing_context.h"
15 #include "printing/printing_export.h" 15 #include "printing/printing_export.h"
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 #include <windows.h> 18 #include <windows.h>
19 #elif defined(OS_MACOSX)
20 #include <ApplicationServices/ApplicationServices.h>
21 #include <CoreFoundation/CoreFoundation.h>
22 #include "base/mac/scoped_cftyperef.h"
19 #endif 23 #endif
20 24
21 namespace base { 25 namespace base {
22 class File; 26 class File;
23 } 27 }
24 28
25 namespace gfx { 29 namespace gfx {
26 class Rect; 30 class Rect;
27 class Size; 31 class Size;
28 } 32 }
29 33
30 namespace printing { 34 namespace printing {
31 35
32 // This class plays metafiles from data stream (usually PDF or EMF). 36 // This class plays metafiles from data stream (usually PDF or EMF).
33 class PRINTING_EXPORT MetafilePlayer { 37 class PRINTING_EXPORT MetafilePlayer {
34 public: 38 public:
39 #if defined(OS_MACOSX)
40 // |shrink_to_fit| specifies whether the output should be shrunk to fit a
41 // destination page if the source PDF is bigger than the destination page in
42 // any dimension. If this is false, parts of the source PDF page that lie
43 // outside the bounds will be clipped.
44 // |stretch_to_fit| specifies whether the output should be stretched to fit
45 // the destination page if the source page size is smaller in all dimensions.
46 // |center_horizontally| specifies whether the output (after any scaling is
47 // done) should be centered horizontally within the destination page.
48 // |center_vertically| specifies whether the output (after any scaling is
49 // done) should be centered vertically within the destination page.
50 // Note that all scaling preserves the original aspect ratio of the page.
51 // |autorotate| specifies whether the source PDF should be autorotated to fit
52 // on the destination page.
53 struct MacRenderPageParams {
54 MacRenderPageParams()
55 : shrink_to_fit(false),
56 stretch_to_fit(false),
57 center_horizontally(false),
58 center_vertically(false),
59 autorotate(false) {
60 }
61
62 bool shrink_to_fit;
63 bool stretch_to_fit;
64 bool center_horizontally;
65 bool center_vertically;
66 bool autorotate;
67 };
68 #endif // defined(OS_MACOSX)
35 MetafilePlayer(); 69 MetafilePlayer();
36 virtual ~MetafilePlayer(); 70 virtual ~MetafilePlayer();
37 71
38 #if defined(OS_WIN) 72 #if defined(OS_WIN)
39 // The slow version of Playback(). It enumerates all the records and play them 73 // The slow version of Playback(). It enumerates all the records and play them
40 // back in the HDC. The trick is that it skip over the records known to have 74 // back in the HDC. The trick is that it skip over the records known to have
41 // issue with some printers. See Emf::Record::SafePlayback implementation for 75 // issue with some printers. See Emf::Record::SafePlayback implementation for
42 // details. 76 // details.
43 virtual bool SafePlayback(skia::NativeDrawingContext hdc) const = 0; 77 virtual bool SafePlayback(skia::NativeDrawingContext hdc) const = 0;
78
79 #elif defined(OS_MACOSX)
80 // Renders the given page into |rect| in the given context.
81 // Pages use a 1-based index. The rendering uses the arguments in
82 // |params| to determine scaling, translation, and rotation.
83 virtual bool RenderPage(unsigned int page_number,
84 skia::NativeDrawingContext context,
85 const CGRect rect,
86 const MacRenderPageParams& params) const = 0;
44 #endif // if defined(OS_WIN) 87 #endif // if defined(OS_WIN)
45 88
46 // Populates the buffer with the underlying data. This function should ONLY be 89 // Populates the buffer with the underlying data. This function should ONLY be
47 // called after the metafile is closed. Returns true if writing succeeded. 90 // called after the metafile is closed. Returns true if writing succeeded.
48 virtual bool GetDataAsVector(std::vector<char>* buffer) const = 0; 91 virtual bool GetDataAsVector(std::vector<char>* buffer) const = 0;
49 92
50 // Saves the underlying data to the given file. This function should ONLY be 93 // Saves the underlying data to the given file. This function should ONLY be
51 // called after the metafile is closed. Returns true if writing succeeded. 94 // called after the metafile is closed. Returns true if writing succeeded.
52 virtual bool SaveTo(base::File* file) const = 0; 95 virtual bool SaveTo(base::File* file) const = 0;
53 96
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 bool GetDataAsVector(std::vector<char>* buffer) const override; 163 bool GetDataAsVector(std::vector<char>* buffer) const override;
121 bool SaveTo(base::File* file) const override; 164 bool SaveTo(base::File* file) const override;
122 165
123 private: 166 private:
124 DISALLOW_COPY_AND_ASSIGN(Metafile); 167 DISALLOW_COPY_AND_ASSIGN(Metafile);
125 }; 168 };
126 169
127 } // namespace printing 170 } // namespace printing
128 171
129 #endif // PRINTING_METAFILE_H_ 172 #endif // PRINTING_METAFILE_H_
OLDNEW
« no previous file with comments | « printing/image_mac.cc ('k') | printing/pdf_metafile_cg_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698