| 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 <stddef.h> |
| 9 #include <stdint.h> |
| 8 #include <windows.graphics.display.h> | 10 #include <windows.graphics.display.h> |
| 9 | 11 |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
| 12 | 14 |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 class D2DFactoryAutoLock { | 18 class D2DFactoryAutoLock { |
| 17 public: | 19 public: |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 break; | 206 break; |
| 205 } | 207 } |
| 206 | 208 |
| 207 HRESULT close_hr = print_control->Close(); | 209 HRESULT close_hr = print_control->Close(); |
| 208 if (FAILED(close_hr) && SUCCEEDED(hr)) | 210 if (FAILED(close_hr) && SUCCEEDED(hr)) |
| 209 return close_hr; | 211 return close_hr; |
| 210 else | 212 else |
| 211 return hr; | 213 return hr; |
| 212 } | 214 } |
| 213 | 215 |
| 214 STDMETHODIMP PrintDocumentSource::Paginate(uint32 page, | 216 STDMETHODIMP PrintDocumentSource::Paginate(uint32_t page, |
| 215 IInspectable* options) { | 217 IInspectable* options) { |
| 216 DVLOG(1) << __FUNCTION__ << ", page = " << page; | 218 DVLOG(1) << __FUNCTION__ << ", page = " << page; |
| 217 DCHECK(options != NULL); | 219 DCHECK(options != NULL); |
| 218 // GetPreviewPageCollection must have been successfuly called. | 220 // GetPreviewPageCollection must have been successfuly called. |
| 219 DCHECK(dxgi_preview_target_.Get() != NULL); | 221 DCHECK(dxgi_preview_target_.Get() != NULL); |
| 220 | 222 |
| 221 // Get print settings from PrintTaskOptions for preview, such as page | 223 // Get print settings from PrintTaskOptions for preview, such as page |
| 222 // description, which contains page size, imageable area, DPI. | 224 // description, which contains page size, imageable area, DPI. |
| 223 // TODO(mad): obtain other print settings in the same way, such as ColorMode, | 225 // TODO(mad): obtain other print settings in the same way, such as ColorMode, |
| 224 // NumberOfCopies, etc... | 226 // NumberOfCopies, etc... |
| (...skipping 29 matching lines...) Expand all Loading... |
| 254 hr = dxgi_preview_target_->SetJobPageCount( | 256 hr = dxgi_preview_target_->SetJobPageCount( |
| 255 PageCountType::FinalPageCount, | 257 PageCountType::FinalPageCount, |
| 256 base::checked_cast<UINT32>(page_count)); | 258 base::checked_cast<UINT32>(page_count)); |
| 257 if (FAILED(hr)) { | 259 if (FAILED(hr)) { |
| 258 LOG(ERROR) << "Failed to SetJobPageCount " << std::hex << hr; | 260 LOG(ERROR) << "Failed to SetJobPageCount " << std::hex << hr; |
| 259 return hr; | 261 return hr; |
| 260 } | 262 } |
| 261 return hr; | 263 return hr; |
| 262 } | 264 } |
| 263 | 265 |
| 264 STDMETHODIMP PrintDocumentSource::MakePage(uint32 job_page, | 266 STDMETHODIMP PrintDocumentSource::MakePage(uint32_t job_page, |
| 265 float width, | 267 float width, |
| 266 float height) { | 268 float height) { |
| 267 DVLOG(1) << __FUNCTION__ << ", width: " << width << ", height: " << height | 269 DVLOG(1) << __FUNCTION__ << ", width: " << width << ", height: " << height |
| 268 << ", job_page: " << job_page; | 270 << ", job_page: " << job_page; |
| 269 DCHECK(width > 0 && height > 0); | 271 DCHECK(width > 0 && height > 0); |
| 270 // Paginate must have been called before this. | 272 // Paginate must have been called before this. |
| 271 if (width_ <= 0.0 || height_ <= 0.0) | 273 if (width_ <= 0.0 || height_ <= 0.0) |
| 272 return S_FALSE; | 274 return S_FALSE; |
| 273 | 275 |
| 274 // When job_page is JOB_PAGE_APPLICATION_DEFINED, it means a new preview | 276 // When job_page is JOB_PAGE_APPLICATION_DEFINED, it means a new preview |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 520 |
| 519 hr = factory1->CreateGdiMetafile(pages_[page_number].Get(), gdi_metafile); | 521 hr = factory1->CreateGdiMetafile(pages_[page_number].Get(), gdi_metafile); |
| 520 if (FAILED(hr)) { | 522 if (FAILED(hr)) { |
| 521 LOG(ERROR) << "Failed to CreateGdiMetafile " << std::hex << hr; | 523 LOG(ERROR) << "Failed to CreateGdiMetafile " << std::hex << hr; |
| 522 return hr; | 524 return hr; |
| 523 } | 525 } |
| 524 return hr; | 526 return hr; |
| 525 } | 527 } |
| 526 | 528 |
| 527 } // namespace metro_driver | 529 } // namespace metro_driver |
| OLD | NEW |