OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_PRINTED_PAGE_H_ | 5 #ifndef PRINTING_PRINTED_PAGE_H_ |
6 #define PRINTING_PRINTED_PAGE_H_ | 6 #define PRINTING_PRINTED_PAGE_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "printing/metafile.h" | 10 #include "printing/metafile.h" |
11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 | 13 |
14 namespace printing { | 14 namespace printing { |
15 | 15 |
16 // Contains the data to reproduce a printed page, either on screen or on | 16 // Contains the data to reproduce a printed page, either on screen or on |
17 // paper. Once created, this object is immutable. It has no reference to the | 17 // paper. Once created, this object is immutable. It has no reference to the |
18 // PrintedDocument containing this page. | 18 // PrintedDocument containing this page. |
19 // Note: May be accessed from many threads at the same time. This is an non | 19 // Note: May be accessed from many threads at the same time. This is an non |
20 // issue since this object is immutable. The reason is that a page may be | 20 // issue since this object is immutable. The reason is that a page may be |
21 // printed and be displayed at the same time. | 21 // printed and be displayed at the same time. |
22 class PRINTING_EXPORT PrintedPage | 22 class PRINTING_EXPORT PrintedPage |
23 : public base::RefCountedThreadSafe<PrintedPage> { | 23 : public base::RefCountedThreadSafe<PrintedPage> { |
24 public: | 24 public: |
25 PrintedPage(int page_number, | 25 PrintedPage(int page_number, |
26 Metafile* metafile, | 26 Metafile* metafile, |
27 const gfx::Size& page_size, | 27 const gfx::Size& page_size, |
28 const gfx::Rect& page_content_rect); | 28 const gfx::Rect& page_content_rect, |
| 29 double shrink_factor); |
29 | 30 |
30 // Getters | 31 // Getters |
31 int page_number() const { return page_number_; } | 32 int page_number() const { return page_number_; } |
32 const Metafile* metafile() const; | 33 const Metafile* metafile() const; |
33 const gfx::Size& page_size() const { return page_size_; } | 34 const gfx::Size& page_size() const { return page_size_; } |
34 const gfx::Rect& page_content_rect() const { return page_content_rect_; } | 35 const gfx::Rect& page_content_rect() const { return page_content_rect_; } |
| 36 double shrink_factor() const { return shrink_factor_; } |
35 | 37 |
36 // Get page content rect adjusted based on | 38 // Get page content rect adjusted based on |
37 // http://dev.w3.org/csswg/css3-page/#positioning-page-box | 39 // http://dev.w3.org/csswg/css3-page/#positioning-page-box |
38 void GetCenteredPageContentRect(const gfx::Size& paper_size, | 40 void GetCenteredPageContentRect(const gfx::Size& paper_size, |
39 gfx::Rect* content_rect) const; | 41 gfx::Rect* content_rect) const; |
40 | 42 |
41 private: | 43 private: |
42 friend class base::RefCountedThreadSafe<PrintedPage>; | 44 friend class base::RefCountedThreadSafe<PrintedPage>; |
43 | 45 |
44 ~PrintedPage(); | 46 ~PrintedPage(); |
45 | 47 |
46 // Page number inside the printed document. | 48 // Page number inside the printed document. |
47 const int page_number_; | 49 const int page_number_; |
48 | 50 |
49 // Actual paint data. | 51 // Actual paint data. |
50 const scoped_ptr<Metafile> metafile_; | 52 const scoped_ptr<Metafile> metafile_; |
51 | 53 |
52 // The physical page size. To support multiple page formats inside on print | 54 // The physical page size. To support multiple page formats inside on print |
53 // job. | 55 // job. |
54 const gfx::Size page_size_; | 56 const gfx::Size page_size_; |
55 | 57 |
56 // The printable area of the page. | 58 // The printable area of the page. |
57 const gfx::Rect page_content_rect_; | 59 const gfx::Rect page_content_rect_; |
58 | 60 |
| 61 // Shrink done in comparison to desired_dpi. |
| 62 double shrink_factor_; |
| 63 |
59 DISALLOW_COPY_AND_ASSIGN(PrintedPage); | 64 DISALLOW_COPY_AND_ASSIGN(PrintedPage); |
60 }; | 65 }; |
61 | 66 |
62 } // namespace printing | 67 } // namespace printing |
63 | 68 |
64 #endif // PRINTING_PRINTED_PAGE_H_ | 69 #endif // PRINTING_PRINTED_PAGE_H_ |
OLD | NEW |