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

Side by Side Diff: cc/resources/shared_bitmap.cc

Issue 638353002: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr in src/… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formating. Created 6 years, 2 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/resources/shared_bitmap.h" 5 #include "cc/resources/shared_bitmap.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/numerics/safe_math.h" 8 #include "base/numerics/safe_math.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 SharedBitmap::SharedBitmap( 13 SharedBitmap::SharedBitmap(
14 base::SharedMemory* memory, 14 base::SharedMemory* memory,
15 const SharedBitmapId& id, 15 const SharedBitmapId& id,
16 const base::Callback<void(SharedBitmap* bitmap)>& free_callback) 16 const base::Callback<void(SharedBitmap* bitmap)>& free_callback)
17 : memory_(memory), 17 : memory_(memory),
18 pixels_(static_cast<uint8*>(memory_->memory())), 18 pixels_(static_cast<uint8*>(memory_->memory())),
19 id_(id), 19 id_(id),
20 free_callback_(free_callback) { 20 free_callback_(free_callback) {
21 } 21 }
22 22
23 SharedBitmap::SharedBitmap( 23 SharedBitmap::SharedBitmap(
24 uint8* pixels, 24 uint8* pixels,
25 const SharedBitmapId& id, 25 const SharedBitmapId& id,
26 const base::Callback<void(SharedBitmap* bitmap)>& free_callback) 26 const base::Callback<void(SharedBitmap* bitmap)>& free_callback)
27 : memory_(NULL), pixels_(pixels), id_(id), free_callback_(free_callback) { 27 : memory_(nullptr),
28 pixels_(pixels),
29 id_(id),
30 free_callback_(free_callback) {
28 } 31 }
29 32
30 SharedBitmap::~SharedBitmap() { free_callback_.Run(this); } 33 SharedBitmap::~SharedBitmap() { free_callback_.Run(this); }
31 34
32 // static 35 // static
33 bool SharedBitmap::SizeInBytes(const gfx::Size& size, size_t* size_in_bytes) { 36 bool SharedBitmap::SizeInBytes(const gfx::Size& size, size_t* size_in_bytes) {
34 if (size.IsEmpty()) 37 if (size.IsEmpty())
35 return false; 38 return false;
36 base::CheckedNumeric<size_t> s = 4; 39 base::CheckedNumeric<size_t> s = 4;
37 s *= size.width(); 40 s *= size.width();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 75
73 // static 76 // static
74 SharedBitmapId SharedBitmap::GenerateId() { 77 SharedBitmapId SharedBitmap::GenerateId() {
75 SharedBitmapId id; 78 SharedBitmapId id;
76 // Needs cryptographically-secure random numbers. 79 // Needs cryptographically-secure random numbers.
77 base::RandBytes(id.name, sizeof(id.name)); 80 base::RandBytes(id.name, sizeof(id.name));
78 return id; 81 return id;
79 } 82 }
80 83
81 } // namespace cc 84 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698