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

Side by Side Diff: chrome/renderer/printing/print_web_view_helper_linux.cc

Issue 704813002: PdfMetafileSkia gives out a SkCanvas, not a SkBaseDevice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month 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
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 #include "chrome/renderer/printing/print_web_view_helper.h" 5 #include "chrome/renderer/printing/print_web_view_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/common/print_messages.h" 9 #include "chrome/common/print_messages.h"
10 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params, 154 ComputePageLayoutInPointsForCss(frame, params.page_number, params.params,
155 ignore_css_margins_, &scale_factor, 155 ignore_css_margins_, &scale_factor,
156 &page_layout_in_points); 156 &page_layout_in_points);
157 gfx::Size page_size; 157 gfx::Size page_size;
158 gfx::Rect content_area; 158 gfx::Rect content_area;
159 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size, 159 GetPageSizeAndContentAreaFromPageLayout(page_layout_in_points, &page_size,
160 &content_area); 160 &content_area);
161 gfx::Rect canvas_area = 161 gfx::Rect canvas_area =
162 params.params.display_header_footer ? gfx::Rect(page_size) : content_area; 162 params.params.display_header_footer ? gfx::Rect(page_size) : content_area;
163 163
164 SkBaseDevice* device = metafile->StartPageForVectorCanvas(page_size, 164 skia::VectorCanvas* canvas =
165 canvas_area, 165 metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor);
166 scale_factor); 166 if (!canvas)
167 if (!device)
168 return; 167 return;
169 168
170 // The printPage method take a reference to the canvas we pass down, so it
171 // can't be a stack object.
172 skia::RefPtr<skia::VectorCanvas> canvas =
173 skia::AdoptRef(new skia::VectorCanvas(device));
174 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile); 169 MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
175 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_); 170 skia::SetIsDraftMode(*canvas, is_print_ready_metafile_sent_);
176 171
177 #if defined(ENABLE_PRINT_PREVIEW) 172 #if defined(ENABLE_PRINT_PREVIEW)
178 if (params.params.display_header_footer) { 173 if (params.params.display_header_footer) {
179 // |page_number| is 0-based, so 1 is added. 174 // |page_number| is 0-based, so 1 is added.
180 // TODO(vitalybuka) : why does it work only with 1.25? 175 // TODO(vitalybuka) : why does it work only with 1.25?
181 PrintHeaderAndFooter(canvas.get(), 176 PrintHeaderAndFooter(canvas, params.page_number + 1,
182 params.page_number + 1, 177 print_preview_context_.total_page_count(), *frame,
183 print_preview_context_.total_page_count(), 178 scale_factor / 1.25, page_layout_in_points,
184 *frame,
185 scale_factor / 1.25,
186 page_layout_in_points,
187 params.params); 179 params.params);
188 } 180 }
189 #endif // defined(ENABLE_PRINT_PREVIEW) 181 #endif // defined(ENABLE_PRINT_PREVIEW)
190 182
191 RenderPageContent(frame, params.page_number, canvas_area, content_area, 183 RenderPageContent(frame, params.page_number, canvas_area, content_area,
192 scale_factor, canvas.get()); 184 scale_factor, canvas);
193 185
194 // Done printing. Close the device context to retrieve the compiled metafile. 186 // Done printing. Close the canvas to retrieve the compiled metafile.
195 if (!metafile->FinishPage()) 187 if (!metafile->FinishPage())
196 NOTREACHED() << "metafile failed"; 188 NOTREACHED() << "metafile failed";
197 } 189 }
198 190
199 } // namespace printing 191 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.cc ('k') | chrome/renderer/printing/print_web_view_helper_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698