OLD | NEW |
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 "printing/printing_context_win.h" | 5 #include "printing/printing_context_win.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include "base/bind.h" | 10 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
9 #include "base/win/scoped_handle.h" | 12 #include "base/win/scoped_handle.h" |
10 #include "base/win/scoped_hdc.h" | 13 #include "base/win/scoped_hdc.h" |
11 #include "printing/backend/printing_info_win.h" | 14 #include "printing/backend/printing_info_win.h" |
12 #include "printing/backend/win_helper.h" | 15 #include "printing/backend/win_helper.h" |
13 #include "printing/print_settings.h" | 16 #include "printing/print_settings.h" |
14 #include "printing/printing_context_system_dialog_win.h" | 17 #include "printing/printing_context_system_dialog_win.h" |
15 #include "printing/printing_test.h" | 18 #include "printing/printing_test.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 sizeof(DEVNAMES) + driver_size + printer_size + port_size; | 111 sizeof(DEVNAMES) + driver_size + printer_size + port_size; |
109 ScopedGlobalAlloc dev_names_mem(GlobalAlloc(GHND, dev_names_size)); | 112 ScopedGlobalAlloc dev_names_mem(GlobalAlloc(GHND, dev_names_size)); |
110 if (!dev_names_mem.Get()) | 113 if (!dev_names_mem.Get()) |
111 return E_FAIL; | 114 return E_FAIL; |
112 void* dev_names_ptr = GlobalLock(dev_names_mem.Get()); | 115 void* dev_names_ptr = GlobalLock(dev_names_mem.Get()); |
113 if (!dev_names_ptr) | 116 if (!dev_names_ptr) |
114 return E_FAIL; | 117 return E_FAIL; |
115 DEVNAMES* dev_names = reinterpret_cast<DEVNAMES*>(dev_names_ptr); | 118 DEVNAMES* dev_names = reinterpret_cast<DEVNAMES*>(dev_names_ptr); |
116 dev_names->wDefault = 1; | 119 dev_names->wDefault = 1; |
117 dev_names->wDriverOffset = sizeof(DEVNAMES) / sizeof(wchar_t); | 120 dev_names->wDriverOffset = sizeof(DEVNAMES) / sizeof(wchar_t); |
118 memcpy(reinterpret_cast<uint8*>(dev_names_ptr) + dev_names->wDriverOffset, | 121 memcpy(reinterpret_cast<uint8_t*>(dev_names_ptr) + dev_names->wDriverOffset, |
119 info_2.get()->pDriverName, | 122 info_2.get()->pDriverName, driver_size); |
120 driver_size); | |
121 dev_names->wDeviceOffset = base::checked_cast<WORD>( | 123 dev_names->wDeviceOffset = base::checked_cast<WORD>( |
122 dev_names->wDriverOffset + driver_size / sizeof(wchar_t)); | 124 dev_names->wDriverOffset + driver_size / sizeof(wchar_t)); |
123 memcpy(reinterpret_cast<uint8*>(dev_names_ptr) + dev_names->wDeviceOffset, | 125 memcpy(reinterpret_cast<uint8_t*>(dev_names_ptr) + dev_names->wDeviceOffset, |
124 info_2.get()->pPrinterName, | 126 info_2.get()->pPrinterName, printer_size); |
125 printer_size); | |
126 dev_names->wOutputOffset = base::checked_cast<WORD>( | 127 dev_names->wOutputOffset = base::checked_cast<WORD>( |
127 dev_names->wDeviceOffset + printer_size / sizeof(wchar_t)); | 128 dev_names->wDeviceOffset + printer_size / sizeof(wchar_t)); |
128 memcpy(reinterpret_cast<uint8*>(dev_names_ptr) + dev_names->wOutputOffset, | 129 memcpy(reinterpret_cast<uint8_t*>(dev_names_ptr) + dev_names->wOutputOffset, |
129 info_2.get()->pPortName, | 130 info_2.get()->pPortName, port_size); |
130 port_size); | |
131 GlobalUnlock(dev_names_mem.Get()); | 131 GlobalUnlock(dev_names_mem.Get()); |
132 dev_names_ptr = NULL; | 132 dev_names_ptr = NULL; |
133 | 133 |
134 lppd->hDC = hdc.Take(); | 134 lppd->hDC = hdc.Take(); |
135 lppd->hDevMode = dev_mode_mem.Take(); | 135 lppd->hDevMode = dev_mode_mem.Take(); |
136 lppd->hDevNames = dev_names_mem.Take(); | 136 lppd->hDevNames = dev_names_mem.Take(); |
137 return S_OK; | 137 return S_OK; |
138 } | 138 } |
139 }; | 139 }; |
140 | 140 |
(...skipping 25 matching lines...) Expand all Loading... |
166 EXPECT_EQ(PrintingContext::OK, context->InitWithSettings(settings)); | 166 EXPECT_EQ(PrintingContext::OK, context->InitWithSettings(settings)); |
167 | 167 |
168 // The print may lie to use and may not support world transformation. | 168 // The print may lie to use and may not support world transformation. |
169 // Verify right now. | 169 // Verify right now. |
170 XFORM random_matrix = { 1, 0.1f, 0, 1.5f, 0, 1 }; | 170 XFORM random_matrix = { 1, 0.1f, 0, 1.5f, 0, 1 }; |
171 EXPECT_TRUE(SetWorldTransform(context->context(), &random_matrix)); | 171 EXPECT_TRUE(SetWorldTransform(context->context(), &random_matrix)); |
172 EXPECT_TRUE(ModifyWorldTransform(context->context(), NULL, MWT_IDENTITY)); | 172 EXPECT_TRUE(ModifyWorldTransform(context->context(), NULL, MWT_IDENTITY)); |
173 } | 173 } |
174 | 174 |
175 } // namespace printing | 175 } // namespace printing |
OLD | NEW |