| 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/ptr_util.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 TestSharedBitmapManager::~TestSharedBitmapManager() {} | 32 TestSharedBitmapManager::~TestSharedBitmapManager() {} |
| 33 | 33 |
| 34 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap( | 34 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap( |
| 35 const gfx::Size& size) { | 35 const gfx::Size& size) { |
| 36 base::AutoLock lock(lock_); | 36 base::AutoLock lock(lock_); |
| 37 std::unique_ptr<base::SharedMemory> memory(new base::SharedMemory); | 37 std::unique_ptr<base::SharedMemory> memory(new base::SharedMemory); |
| 38 memory->CreateAndMapAnonymous(size.GetArea() * 4); | 38 memory->CreateAndMapAnonymous(size.GetArea() * 4); |
| 39 SharedBitmapId id = SharedBitmap::GenerateId(); | 39 SharedBitmapId id = SharedBitmap::GenerateId(); |
| 40 bitmap_map_[id] = memory.get(); | 40 bitmap_map_[id] = memory.get(); |
| 41 return base::WrapUnique(new OwnedSharedBitmap(std::move(memory), id)); | 41 return base::MakeUnique<OwnedSharedBitmap>(std::move(memory), id); |
| 42 } | 42 } |
| 43 | 43 |
| 44 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( | 44 std::unique_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( |
| 45 const gfx::Size&, | 45 const gfx::Size&, |
| 46 const SharedBitmapId& id) { | 46 const SharedBitmapId& id) { |
| 47 base::AutoLock lock(lock_); | 47 base::AutoLock lock(lock_); |
| 48 if (bitmap_map_.find(id) == bitmap_map_.end()) | 48 if (bitmap_map_.find(id) == bitmap_map_.end()) |
| 49 return nullptr; | 49 return nullptr; |
| 50 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory()); | 50 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory()); |
| 51 return base::WrapUnique(new SharedBitmap(pixels, id)); | 51 return base::MakeUnique<SharedBitmap>(pixels, id); |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace cc | 54 } // namespace cc |
| OLD | NEW |