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 "stdafx.h" | 5 #include "stdafx.h" |
6 #include "win8/metro_driver/print_document_source.h" | 6 #include "win8/metro_driver/print_document_source.h" |
7 | 7 |
8 #include <windows.graphics.display.h> | 8 #include <windows.graphics.display.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/safe_numerics.h" | 11 #include "base/numerics/safe_conversions.h" |
12 | 12 |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class D2DFactoryAutoLock { | 16 class D2DFactoryAutoLock { |
17 public: | 17 public: |
18 explicit D2DFactoryAutoLock(ID2D1Factory* d2d_factory) { | 18 explicit D2DFactoryAutoLock(ID2D1Factory* d2d_factory) { |
19 HRESULT hr = d2d_factory->QueryInterface(IID_PPV_ARGS(&d2d_multithread_)); | 19 HRESULT hr = d2d_factory->QueryInterface(IID_PPV_ARGS(&d2d_multithread_)); |
20 if (d2d_multithread_.Get()) | 20 if (d2d_multithread_.Get()) |
21 d2d_multithread_->Enter(); | 21 d2d_multithread_->Enter(); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 LOG(ERROR) << "Failed to InvalidatePreview " << std::hex << hr; | 246 LOG(ERROR) << "Failed to InvalidatePreview " << std::hex << hr; |
247 return hr; | 247 return hr; |
248 } | 248 } |
249 | 249 |
250 size_t page_count = WaitAndGetPageCount(); | 250 size_t page_count = WaitAndGetPageCount(); |
251 // A page_count of 0 means abort... | 251 // A page_count of 0 means abort... |
252 if (page_count == 0) | 252 if (page_count == 0) |
253 return S_FALSE; | 253 return S_FALSE; |
254 hr = dxgi_preview_target_->SetJobPageCount( | 254 hr = dxgi_preview_target_->SetJobPageCount( |
255 PageCountType::FinalPageCount, | 255 PageCountType::FinalPageCount, |
256 base::checked_numeric_cast<UINT32>(page_count)); | 256 base::checked_cast<UINT32>(page_count)); |
257 if (FAILED(hr)) { | 257 if (FAILED(hr)) { |
258 LOG(ERROR) << "Failed to SetJobPageCount " << std::hex << hr; | 258 LOG(ERROR) << "Failed to SetJobPageCount " << std::hex << hr; |
259 return hr; | 259 return hr; |
260 } | 260 } |
261 return hr; | 261 return hr; |
262 } | 262 } |
263 | 263 |
264 STDMETHODIMP PrintDocumentSource::MakePage(uint32 job_page, | 264 STDMETHODIMP PrintDocumentSource::MakePage(uint32 job_page, |
265 float width, | 265 float width, |
266 float height) { | 266 float height) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 518 |
519 hr = factory1->CreateGdiMetafile(pages_[page_number].Get(), gdi_metafile); | 519 hr = factory1->CreateGdiMetafile(pages_[page_number].Get(), gdi_metafile); |
520 if (FAILED(hr)) { | 520 if (FAILED(hr)) { |
521 LOG(ERROR) << "Failed to CreateGdiMetafile " << std::hex << hr; | 521 LOG(ERROR) << "Failed to CreateGdiMetafile " << std::hex << hr; |
522 return hr; | 522 return hr; |
523 } | 523 } |
524 return hr; | 524 return hr; |
525 } | 525 } |
526 | 526 |
527 } // namespace metro_driver | 527 } // namespace metro_driver |
OLD | NEW |