OLD | NEW |
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/service/cloud_print/print_system.h" | 5 #include "chrome/service/cloud_print/print_system.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 if (ret) | 314 if (ret) |
315 delegate_ = delegate; | 315 delegate_ = delegate; |
316 return ret; | 316 return ret; |
317 } else { | 317 } else { |
318 NOTREACHED(); | 318 NOTREACHED(); |
319 return false; | 319 return false; |
320 } | 320 } |
321 return true; | 321 return true; |
322 } | 322 } |
323 | 323 |
324 void PreparePageDCForPrinting(HDC, double scale_factor) { | 324 void PreparePageDCForPrinting(HDC, float scale_factor) { |
325 SetGraphicsMode(printer_dc_.Get(), GM_ADVANCED); | 325 SetGraphicsMode(printer_dc_.Get(), GM_ADVANCED); |
326 // Setup the matrix to translate and scale to the right place. Take in | 326 // Setup the matrix to translate and scale to the right place. Take in |
327 // account the scale factor. | 327 // account the scale factor. |
328 // Note that the printing output is relative to printable area of | 328 // Note that the printing output is relative to printable area of |
329 // the page. That is 0,0 is offset by PHYSICALOFFSETX/Y from the page. | 329 // the page. That is 0,0 is offset by PHYSICALOFFSETX/Y from the page. |
330 int offset_x = ::GetDeviceCaps(printer_dc_.Get(), PHYSICALOFFSETX); | 330 int offset_x = ::GetDeviceCaps(printer_dc_.Get(), PHYSICALOFFSETX); |
331 int offset_y = ::GetDeviceCaps(printer_dc_.Get(), PHYSICALOFFSETY); | 331 int offset_y = ::GetDeviceCaps(printer_dc_.Get(), PHYSICALOFFSETY); |
332 XFORM xform = {0}; | 332 XFORM xform = {0}; |
333 xform.eDx = static_cast<float>(-offset_x); | 333 xform.eDx = static_cast<float>(-offset_x); |
334 xform.eDy = static_cast<float>(-offset_y); | 334 xform.eDy = static_cast<float>(-offset_y); |
335 xform.eM11 = xform.eM22 = 1.0 / scale_factor; | 335 xform.eM11 = xform.eM22 = 1.0f / scale_factor; |
336 SetWorldTransform(printer_dc_.Get(), &xform); | 336 SetWorldTransform(printer_dc_.Get(), &xform); |
337 } | 337 } |
338 | 338 |
339 // ServiceUtilityProcessHost::Client implementation. | 339 // ServiceUtilityProcessHost::Client implementation. |
340 virtual void OnRenderPDFPagesToMetafilePageDone( | 340 virtual void OnRenderPDFPagesToMetafilePageDone( |
341 double scale_factor, | 341 float scale_factor, |
342 const printing::MetafilePlayer& emf) override { | 342 const printing::MetafilePlayer& emf) override { |
343 PreparePageDCForPrinting(printer_dc_.Get(), scale_factor); | 343 PreparePageDCForPrinting(printer_dc_.Get(), scale_factor); |
344 ::StartPage(printer_dc_.Get()); | 344 ::StartPage(printer_dc_.Get()); |
345 emf.SafePlayback(printer_dc_.Get()); | 345 emf.SafePlayback(printer_dc_.Get()); |
346 ::EndPage(printer_dc_.Get()); | 346 ::EndPage(printer_dc_.Get()); |
347 } | 347 } |
348 | 348 |
349 // ServiceUtilityProcessHost::Client implementation. | 349 // ServiceUtilityProcessHost::Client implementation. |
350 virtual void OnRenderPDFPagesToMetafileDone(bool success) override { | 350 virtual void OnRenderPDFPagesToMetafileDone(bool success) override { |
351 PrintJobDone(success); | 351 PrintJobDone(success); |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 } | 830 } |
831 | 831 |
832 } // namespace | 832 } // namespace |
833 | 833 |
834 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( | 834 scoped_refptr<PrintSystem> PrintSystem::CreateInstance( |
835 const base::DictionaryValue* print_system_settings) { | 835 const base::DictionaryValue* print_system_settings) { |
836 return new PrintSystemWin; | 836 return new PrintSystemWin; |
837 } | 837 } |
838 | 838 |
839 } // namespace cloud_print | 839 } // namespace cloud_print |
OLD | NEW |