| OLD | NEW |
| 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 "components/viz/display_compositor/host_shared_bitmap_manager.h" | 5 #include "components/viz/display_compositor/host_shared_bitmap_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 HostSharedBitmapManager* manager) | 44 HostSharedBitmapManager* manager) |
| 45 : SharedBitmap(pixels, id), | 45 : SharedBitmap(pixels, id), |
| 46 bitmap_data_(bitmap_data), | 46 bitmap_data_(bitmap_data), |
| 47 manager_(manager) {} | 47 manager_(manager) {} |
| 48 | 48 |
| 49 ~HostSharedBitmap() override { | 49 ~HostSharedBitmap() override { |
| 50 if (manager_) | 50 if (manager_) |
| 51 manager_->FreeSharedMemoryFromMap(id()); | 51 manager_->FreeSharedMemoryFromMap(id()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // cc::SharedBitmap: |
| 55 base::SharedMemoryHandle GetSharedMemoryHandle() const override { |
| 56 if (!bitmap_data_->memory) |
| 57 return base::SharedMemoryHandle(); |
| 58 return bitmap_data_->memory->handle(); |
| 59 } |
| 60 |
| 54 private: | 61 private: |
| 55 scoped_refptr<BitmapData> bitmap_data_; | 62 scoped_refptr<BitmapData> bitmap_data_; |
| 56 HostSharedBitmapManager* manager_; | 63 HostSharedBitmapManager* manager_; |
| 57 }; | 64 }; |
| 58 | 65 |
| 59 } // namespace | 66 } // namespace |
| 60 | 67 |
| 61 base::LazyInstance<HostSharedBitmapManager>::DestructorAtExit | 68 base::LazyInstance<HostSharedBitmapManager>::DestructorAtExit |
| 62 g_shared_memory_manager = LAZY_INSTANCE_INITIALIZER; | 69 g_shared_memory_manager = LAZY_INSTANCE_INITIALIZER; |
| 63 | 70 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return handle_map_.size(); | 220 return handle_map_.size(); |
| 214 } | 221 } |
| 215 | 222 |
| 216 void HostSharedBitmapManager::FreeSharedMemoryFromMap( | 223 void HostSharedBitmapManager::FreeSharedMemoryFromMap( |
| 217 const cc::SharedBitmapId& id) { | 224 const cc::SharedBitmapId& id) { |
| 218 base::AutoLock lock(lock_); | 225 base::AutoLock lock(lock_); |
| 219 handle_map_.erase(id); | 226 handle_map_.erase(id); |
| 220 } | 227 } |
| 221 | 228 |
| 222 } // namespace viz | 229 } // namespace viz |
| OLD | NEW |