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

Side by Side Diff: chrome/utility/utility_thread.cc

Issue 6611032: Unifying NativeMetafile class interface (as much as possible) for Linux, Mac, Win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Making virtual methods not virtual (for clang bots) Created 9 years, 9 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
« no previous file with comments | « chrome/renderer/print_web_view_helper_win.cc ('k') | printing/emf_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/utility/utility_thread.h" 5 #include "chrome/utility/utility_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 int total_page_count = 0; 256 int total_page_count = 0;
257 if (!get_info_proc(&buffer.front(), buffer.size(), &total_page_count, NULL)) 257 if (!get_info_proc(&buffer.front(), buffer.size(), &total_page_count, NULL))
258 return false; 258 return false;
259 259
260 scoped_ptr<printing::NativeMetafile> metafile( 260 scoped_ptr<printing::NativeMetafile> metafile(
261 printing::NativeMetafileFactory::CreateMetafile()); 261 printing::NativeMetafileFactory::CreateMetafile());
262 metafile->CreateFileBackedDc(NULL, NULL, metafile_path); 262 metafile->CreateFileBackedDc(NULL, NULL, metafile_path);
263 // Since we created the metafile using the screen DPI (but we actually want 263 // Since we created the metafile using the screen DPI (but we actually want
264 // the PDF DLL to print using the passed in render_dpi, we apply the following 264 // the PDF DLL to print using the passed in render_dpi, we apply the following
265 // transformation. 265 // transformation.
266 SetGraphicsMode(metafile->hdc(), GM_ADVANCED); 266 SetGraphicsMode(metafile->context(), GM_ADVANCED);
267 XFORM xform = {0}; 267 XFORM xform = {0};
268 int screen_dpi = GetDeviceCaps(GetDC(NULL), LOGPIXELSX); 268 int screen_dpi = GetDeviceCaps(GetDC(NULL), LOGPIXELSX);
269 xform.eM11 = xform.eM22 = 269 xform.eM11 = xform.eM22 =
270 static_cast<float>(screen_dpi) / static_cast<float>(render_dpi); 270 static_cast<float>(screen_dpi) / static_cast<float>(render_dpi);
271 ModifyWorldTransform(metafile->hdc(), &xform, MWT_LEFTMULTIPLY); 271 ModifyWorldTransform(metafile->context(), &xform, MWT_LEFTMULTIPLY);
272 272
273 bool ret = false; 273 bool ret = false;
274 std::vector<printing::PageRange>::const_iterator iter; 274 std::vector<printing::PageRange>::const_iterator iter;
275 for (iter = page_ranges.begin(); iter != page_ranges.end(); ++iter) { 275 for (iter = page_ranges.begin(); iter != page_ranges.end(); ++iter) {
276 for (int page_number = iter->from; page_number <= iter->to; ++page_number) { 276 for (int page_number = iter->from; page_number <= iter->to; ++page_number) {
277 if (page_number >= total_page_count) 277 if (page_number >= total_page_count)
278 break; 278 break;
279 metafile->StartPage(); 279 metafile->StartPage();
280 if (render_proc(&buffer.front(), buffer.size(), page_number, 280 if (render_proc(&buffer.front(), buffer.size(), page_number,
281 metafile->hdc(), render_dpi, render_dpi, 281 metafile->context(), render_dpi, render_dpi,
282 render_area.x(), render_area.y(), render_area.width(), 282 render_area.x(), render_area.y(), render_area.width(),
283 render_area.height(), true, false, true, true)) 283 render_area.height(), true, false, true, true))
284 if (*highest_rendered_page_number < page_number) 284 if (*highest_rendered_page_number < page_number)
285 *highest_rendered_page_number = page_number; 285 *highest_rendered_page_number = page_number;
286 ret = true; 286 ret = true;
287 metafile->EndPage(); 287 metafile->FinishPage();
288 } 288 }
289 } 289 }
290 metafile->CloseDc(); 290 metafile->Close();
291 return ret; 291 return ret;
292 } 292 }
293 #endif // defined(OS_WIN) 293 #endif // defined(OS_WIN)
294 294
295 void UtilityThread::OnIDBKeysFromValuesAndKeyPath( 295 void UtilityThread::OnIDBKeysFromValuesAndKeyPath(
296 int id, 296 int id,
297 const std::vector<SerializedScriptValue>& serialized_script_values, 297 const std::vector<SerializedScriptValue>& serialized_script_values,
298 const string16& idb_key_path) { 298 const string16& idb_key_path) {
299 std::vector<WebKit::WebSerializedScriptValue> web_values; 299 std::vector<WebKit::WebSerializedScriptValue> web_values;
300 ConvertVector(serialized_script_values, &web_values); 300 ConvertVector(serialized_script_values, &web_values);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } else { 339 } else {
340 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); 340 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name));
341 } 341 }
342 ReleaseProcessIfNeeded(); 342 ReleaseProcessIfNeeded();
343 } 343 }
344 344
345 void UtilityThread::ReleaseProcessIfNeeded() { 345 void UtilityThread::ReleaseProcessIfNeeded() {
346 if (!batch_mode_) 346 if (!batch_mode_)
347 ChildProcess::current()->ReleaseProcess(); 347 ChildProcess::current()->ReleaseProcess();
348 } 348 }
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper_win.cc ('k') | printing/emf_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698