printed_page_win.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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
  3. // found in the LICENSE file.
  4. #ifndef PRINTING_PRINTED_PAGE_WIN_H_
  5. #define PRINTING_PRINTED_PAGE_WIN_H_
  6. #include <memory>
  7. #include "base/memory/ref_counted.h"
  8. #include "printing/metafile.h"
  9. #include "ui/gfx/geometry/rect.h"
  10. #include "ui/gfx/geometry/size.h"
  11. namespace printing {
  12. // Contains the data to reproduce a printed page, either on screen or on
  13. // paper. Once created, this object is immutable. It has no reference to the
  14. // PrintedDocument containing this page.
  15. // Note: May be accessed from many threads at the same time. This is an non
  16. // issue since this object is immutable. The reason is that a page may be
  17. // printed and be displayed at the same time.
  18. class COMPONENT_EXPORT(PRINTING) PrintedPage
  19. : public base::RefCountedThreadSafe<PrintedPage> {
  20. public:
  21. PrintedPage(uint32_t page_number,
  22. std::unique_ptr<MetafilePlayer> metafile,
  23. const gfx::Size& page_size,
  24. const gfx::Rect& page_content_rect);
  25. PrintedPage(const PrintedPage&) = delete;
  26. PrintedPage& operator=(const PrintedPage&) = delete;
  27. // Getters
  28. uint32_t page_number() const { return page_number_; }
  29. const MetafilePlayer* metafile() const;
  30. const gfx::Size& page_size() const { return page_size_; }
  31. const gfx::Rect& page_content_rect() const { return page_content_rect_; }
  32. void set_shrink_factor(float shrink_factor) {
  33. shrink_factor_ = shrink_factor;
  34. }
  35. float shrink_factor() const { return shrink_factor_; }
  36. private:
  37. friend class base::RefCountedThreadSafe<PrintedPage>;
  38. ~PrintedPage();
  39. // Page number inside the printed document.
  40. const uint32_t page_number_;
  41. // Actual paint data.
  42. const std::unique_ptr<MetafilePlayer> metafile_;
  43. // Shrink done in comparison to desired_dpi.
  44. float shrink_factor_;
  45. // The physical page size. To support multiple page formats inside on print
  46. // job.
  47. const gfx::Size page_size_;
  48. // The printable area of the page.
  49. const gfx::Rect page_content_rect_;
  50. };
  51. } // namespace printing
  52. #endif // PRINTING_PRINTED_PAGE_WIN_H_