| 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> |
| 8 |
| 7 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 8 | 10 |
| 9 namespace cc { | 11 namespace cc { |
| 10 | 12 |
| 11 namespace { | 13 namespace { |
| 12 class OwnedSharedBitmap : public SharedBitmap { | 14 class OwnedSharedBitmap : public SharedBitmap { |
| 13 public: | 15 public: |
| 14 OwnedSharedBitmap(scoped_ptr<base::SharedMemory> shared_memory, | 16 OwnedSharedBitmap(scoped_ptr<base::SharedMemory> shared_memory, |
| 15 const SharedBitmapId& id) | 17 const SharedBitmapId& id) |
| 16 : SharedBitmap(static_cast<uint8*>(shared_memory->memory()), id), | 18 : SharedBitmap(static_cast<uint8_t*>(shared_memory->memory()), id), |
| 17 shared_memory_(std::move(shared_memory)) {} | 19 shared_memory_(std::move(shared_memory)) {} |
| 18 | 20 |
| 19 ~OwnedSharedBitmap() override {} | 21 ~OwnedSharedBitmap() override {} |
| 20 | 22 |
| 21 private: | 23 private: |
| 22 scoped_ptr<base::SharedMemory> shared_memory_; | 24 scoped_ptr<base::SharedMemory> shared_memory_; |
| 23 }; | 25 }; |
| 24 | 26 |
| 25 } // namespace | 27 } // namespace |
| 26 | 28 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 37 bitmap_map_[id] = memory.get(); | 39 bitmap_map_[id] = memory.get(); |
| 38 return make_scoped_ptr(new OwnedSharedBitmap(std::move(memory), id)); | 40 return make_scoped_ptr(new OwnedSharedBitmap(std::move(memory), id)); |
| 39 } | 41 } |
| 40 | 42 |
| 41 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( | 43 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( |
| 42 const gfx::Size&, | 44 const gfx::Size&, |
| 43 const SharedBitmapId& id) { | 45 const SharedBitmapId& id) { |
| 44 base::AutoLock lock(lock_); | 46 base::AutoLock lock(lock_); |
| 45 if (bitmap_map_.find(id) == bitmap_map_.end()) | 47 if (bitmap_map_.find(id) == bitmap_map_.end()) |
| 46 return nullptr; | 48 return nullptr; |
| 47 uint8* pixels = static_cast<uint8*>(bitmap_map_[id]->memory()); | 49 uint8_t* pixels = static_cast<uint8_t*>(bitmap_map_[id]->memory()); |
| 48 return make_scoped_ptr(new SharedBitmap(pixels, id)); | 50 return make_scoped_ptr(new SharedBitmap(pixels, id)); |
| 49 } | 51 } |
| 50 | 52 |
| 51 } // namespace cc | 53 } // namespace cc |
| OLD | NEW |