OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/test_shared_bitmap_manager.h" | 5 #include "cc/test/test_shared_bitmap_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
| 9 #include "base/memory/ptr_util.h" |
9 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
10 | 11 |
11 namespace cc { | 12 namespace cc { |
12 | 13 |
13 namespace { | 14 namespace { |
14 class OwnedSharedBitmap : public SharedBitmap { | 15 class OwnedSharedBitmap : public SharedBitmap { |
15 public: | 16 public: |
16 OwnedSharedBitmap(scoped_ptr<base::SharedMemory> shared_memory, | 17 OwnedSharedBitmap(std::unique_ptr<base::SharedMemory> shared_memory, |
17 const SharedBitmapId& id) | 18 const SharedBitmapId& id) |
18 : SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()), id), | 19 : SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()), id), |
19 shared_memory_(std::move(shared_memory)) {} | 20 shared_memory_(std::move(shared_memory)) {} |
20 | 21 |
21 ~OwnedSharedBitmap() override {} | 22 ~OwnedSharedBitmap() override {} |
22 | 23 |
23 private: | 24 private: |
24 scoped_ptr<base::SharedMemory> shared_memory_; | 25 std::unique_ptr<base::SharedMemory> shared_memory_; |
25 }; | 26 }; |
26 | 27 |
27 } // namespace | 28 } // namespace |
28 | 29 |
29 TestSharedBitmapManager::TestSharedBitmapManager() {} | 30 TestSharedBitmapManager::TestSharedBitmapManager() {} |
30 | 31 |
31 TestSharedBitmapManager::~TestSharedBitmapManager() {} | 32 TestSharedBitmapManager::~TestSharedBitmapManager() {} |
32 | 33 |
33 scoped_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap( | 34 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap( |
34 const gfx::Size& size) { | 35 const gfx::Size& size) { |
35 base::AutoLock lock(lock_); | 36 base::AutoLock lock(lock_); |
36 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory); | 37 std::unique_ptr<base::SharedMemory> memory(new base::SharedMemory); |
37 memory->CreateAndMapAnonymous(size.GetArea() * 4); | 38 memory->CreateAndMapAnonymous(size.GetArea() * 4); |
38 SharedBitmapId id = SharedBitmap::GenerateId(); | 39 SharedBitmapId id = SharedBitmap::GenerateId(); |
39 bitmap_map_[id] = memory.get(); | 40 bitmap_map_[id] = memory.get(); |
40 return make_scoped_ptr(new OwnedSharedBitmap(std::move(memory), id)); | 41 return base::WrapUnique(new OwnedSharedBitmap(std::move(memory), id)); |
41 } | 42 } |
42 | 43 |
43 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( | 44 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( |
44 const gfx::Size&, | 45 const gfx::Size&, |
45 const SharedBitmapId& id) { | 46 const SharedBitmapId& id) { |
46 base::AutoLock lock(lock_); | 47 base::AutoLock lock(lock_); |
47 if (bitmap_map_.find(id) == bitmap_map_.end()) | 48 if (bitmap_map_.find(id) == bitmap_map_.end()) |
48 return nullptr; | 49 return nullptr; |
49 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory()); | 50 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory()); |
50 return make_scoped_ptr(new SharedBitmap(pixels, id)); | 51 return base::WrapUnique(new SharedBitmap(pixels, id)); |
51 } | 52 } |
52 | 53 |
53 } // namespace cc | 54 } // namespace cc |
OLD | NEW |