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

Side by Side Diff: printing/metafile_skia_wrapper.cc

Issue 7719014: PrintPreview: Printing preview of a PDF on Mac with Skia only previews the last page of the PDF (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "printing/metafile_skia_wrapper.h" 6 #include "printing/metafile_skia_wrapper.h"
7 #include "third_party/skia/include/core/SkCanvas.h" 7 #include "third_party/skia/include/core/SkCanvas.h"
8 #include "third_party/skia/include/core/SkDevice.h" 8 #include "third_party/skia/include/core/SkDevice.h"
9 #include "third_party/skia/include/core/SkMetaData.h" 9 #include "third_party/skia/include/core/SkMetaData.h"
10 10
11 namespace printing { 11 namespace printing {
12 12
13 namespace { 13 namespace {
14 14
15 const char* kDraftModeKey = "CrDraftMode"; 15 const char* kDraftModeKey = "CrDraftMode";
16 const char* kMetafileKey = "CrMetafile"; 16 const char* kMetafileKey = "CrMetafile";
17 17
18 #if defined(OS_MACOSX) || defined(OS_WIN)
19 const char* kIsPreviewMetafileKey = "CrIsPreviewMetafile";
20 #endif
21
18 SkMetaData& getMetaData(SkCanvas* canvas) { 22 SkMetaData& getMetaData(SkCanvas* canvas) {
19 DCHECK(canvas != NULL); 23 DCHECK(canvas != NULL);
20 24
21 SkDevice* device = canvas->getDevice(); 25 SkDevice* device = canvas->getDevice();
22 DCHECK(device != NULL); 26 DCHECK(device != NULL);
23 return device->getMetaData(); 27 return device->getMetaData();
24 } 28 }
25 29
26 } // namespace 30 } // namespace
27 31
(...skipping 27 matching lines...) Expand all
55 59
56 // static 60 // static
57 bool MetafileSkiaWrapper::GetDraftMode(SkCanvas* canvas) { 61 bool MetafileSkiaWrapper::GetDraftMode(SkCanvas* canvas) {
58 SkMetaData& meta = getMetaData(canvas); 62 SkMetaData& meta = getMetaData(canvas);
59 bool draft_mode; 63 bool draft_mode;
60 if (!meta.findBool(kDraftModeKey, &draft_mode)) 64 if (!meta.findBool(kDraftModeKey, &draft_mode))
61 draft_mode = false; 65 draft_mode = false;
62 return draft_mode; 66 return draft_mode;
63 } 67 }
64 68
69 #if defined(OS_MACOSX) || defined(OS_WIN)
70 // static
71 void MetafileSkiaWrapper::SetIsPreviewMetafile(SkCanvas* canvas,
72 bool is_preview) {
73 SkMetaData& meta = getMetaData(canvas);
74 meta.setBool(kIsPreviewMetafileKey, is_preview);
75 }
76
77 // static
78 bool MetafileSkiaWrapper::IsPreviewMetafile(SkCanvas* canvas) {
79 SkMetaData& meta = getMetaData(canvas);
80 bool is_preview_metafile;
81 if (!meta.findBool(kIsPreviewMetafileKey, &is_preview_metafile))
82 is_preview_metafile = false;
83 return is_preview_metafile;
84 }
85 #endif
86
65 MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile* metafile) 87 MetafileSkiaWrapper::MetafileSkiaWrapper(Metafile* metafile)
66 : metafile_(metafile) { 88 : metafile_(metafile) {
67 } 89 }
68 90
69 } // namespace printing 91 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698