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

Side by Side Diff: printing/emf_win.cc

Issue 2458513003: Addressing C4267 warnings for printing. (Closed)
Patch Set: Rebase, IsValueInRangeForNumericType for CFIndex Created 4 years, 1 month 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
« no previous file with comments | « printing/emf_win.h ('k') | printing/emf_win_unittest.cc » ('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) 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 "printing/emf_win.h" 5 #include "printing/emf_win.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/numerics/safe_conversions.h"
17 #include "base/win/scoped_gdi_object.h" 18 #include "base/win/scoped_gdi_object.h"
18 #include "base/win/scoped_hdc.h" 19 #include "base/win/scoped_hdc.h"
19 #include "base/win/scoped_select_object.h" 20 #include "base/win/scoped_select_object.h"
20 #include "skia/ext/skia_utils_win.h" 21 #include "skia/ext/skia_utils_win.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 22 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "ui/gfx/codec/jpeg_codec.h" 23 #include "ui/gfx/codec/jpeg_codec.h"
23 #include "ui/gfx/codec/png_codec.h" 24 #include "ui/gfx/codec/png_codec.h"
24 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
25 #include "ui/gfx/geometry/size.h" 26 #include "ui/gfx/geometry/size.h"
26 27
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return !!emf_; 180 return !!emf_;
180 } 181 }
181 182
182 bool Emf::Init() { 183 bool Emf::Init() {
183 DCHECK(!emf_ && !hdc_); 184 DCHECK(!emf_ && !hdc_);
184 hdc_ = CreateEnhMetaFile(nullptr, nullptr, nullptr, nullptr); 185 hdc_ = CreateEnhMetaFile(nullptr, nullptr, nullptr, nullptr);
185 DCHECK(hdc_); 186 DCHECK(hdc_);
186 return !!hdc_; 187 return !!hdc_;
187 } 188 }
188 189
189 bool Emf::InitFromData(const void* src_buffer, uint32_t src_buffer_size) { 190 bool Emf::InitFromData(const void* src_buffer, size_t src_buffer_size) {
190 DCHECK(!emf_ && !hdc_); 191 DCHECK(!emf_ && !hdc_);
191 emf_ = SetEnhMetaFileBits(src_buffer_size, 192 if (!base::IsValueInRangeForNumericType<UINT>(src_buffer_size))
193 return false;
194
195 emf_ = SetEnhMetaFileBits(static_cast<UINT>(src_buffer_size),
192 reinterpret_cast<const BYTE*>(src_buffer)); 196 reinterpret_cast<const BYTE*>(src_buffer));
193 return !!emf_; 197 return !!emf_;
194 } 198 }
195 199
196 bool Emf::FinishDocument() { 200 bool Emf::FinishDocument() {
197 DCHECK(!emf_ && hdc_); 201 DCHECK(!emf_ && hdc_);
198 emf_ = CloseEnhMetaFile(hdc_); 202 emf_ = CloseEnhMetaFile(hdc_);
199 DCHECK(emf_); 203 DCHECK(emf_);
200 hdc_ = nullptr; 204 hdc_ = nullptr;
201 return !!emf_; 205 return !!emf_;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 595
592 HDC bitmap_dc = bitmap.context(); 596 HDC bitmap_dc = bitmap.context();
593 RECT rect = page_bounds.ToRECT(); 597 RECT rect = page_bounds.ToRECT();
594 ::EnumEnhMetaFile(hdc, emf(), &RasterizeAlphaBlendProc, &bitmap_dc, &rect); 598 ::EnumEnhMetaFile(hdc, emf(), &RasterizeAlphaBlendProc, &bitmap_dc, &rect);
595 599
596 result->FinishDocument(); 600 result->FinishDocument();
597 return result; 601 return result;
598 } 602 }
599 603
600 } // namespace printing 604 } // namespace printing
OLDNEW
« no previous file with comments | « printing/emf_win.h ('k') | printing/emf_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698