blob: 73286966f993986daba7c976d96427e62c0cb7ad [file] [log] [blame]
[email protected]b5cf844c2012-06-18 21:49:201// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]b75dca82009-10-13 18:46:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "printing/printed_document.h"
6
7#import <ApplicationServices/ApplicationServices.h>
8#import <CoreFoundation/CoreFoundation.h>
9
10#include "base/logging.h"
[email protected]b75dca82009-10-13 18:46:2111#include "printing/page_number.h"
12#include "printing/printed_page.h"
13
14namespace printing {
15
16void PrintedDocument::RenderPrintedPage(
tfarina876d1e02016-10-11 23:12:5317 const PrintedPage& page,
18 skia::NativeDrawingContext context) const {
[email protected]b75dca82009-10-13 18:46:2119#ifndef NDEBUG
20 {
21 // Make sure the page is from our list.
[email protected]20305ec2011-01-21 04:55:5222 base::AutoLock lock(lock_);
[email protected]b75dca82009-10-13 18:46:2123 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get());
24 }
25#endif
26
[email protected]3b52c982010-09-27 20:40:3627 DCHECK(context);
28
[email protected]d91db112011-10-18 20:58:5129 const PageSetup& page_setup(immutable_.settings_.page_setup_device_units());
[email protected]a12552b02010-07-05 06:45:2130 gfx::Rect content_area;
31 page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area);
[email protected]b75dca82009-10-13 18:46:2132
vitalybuka5d1290582014-09-12 09:19:5933 const MetafilePlayer* metafile = page.metafile();
[email protected]7d7489902011-04-11 21:54:0634 // Each Metafile is a one-page PDF, and pages use 1-based indexing.
[email protected]b75dca82009-10-13 18:46:2135 const int page_number = 1;
[email protected]b5cf844c2012-06-18 21:49:2036 struct Metafile::MacRenderPageParams params;
37 params.autorotate = true;
38 metafile->RenderPage(page_number, context, content_area.ToCGRect(), params);
[email protected]e0598782010-10-07 22:01:5239}
40
[email protected]b75dca82009-10-13 18:46:2141} // namespace printing