| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/in_process_io_surface_manager_mac.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace content { | |
| 10 | |
| 11 // static | |
| 12 InProcessIOSurfaceManager* InProcessIOSurfaceManager::GetInstance() { | |
| 13 return base::Singleton< | |
| 14 InProcessIOSurfaceManager, | |
| 15 base::LeakySingletonTraits<InProcessIOSurfaceManager>>::get(); | |
| 16 } | |
| 17 | |
| 18 bool InProcessIOSurfaceManager::RegisterIOSurface( | |
| 19 gfx::IOSurfaceId io_surface_id, | |
| 20 int client_id, | |
| 21 IOSurfaceRef io_surface) { | |
| 22 base::AutoLock lock(lock_); | |
| 23 | |
| 24 DCHECK(io_surfaces_.find(io_surface_id) == io_surfaces_.end()); | |
| 25 io_surfaces_.add(io_surface_id, | |
| 26 make_scoped_ptr(new base::mac::ScopedMachSendRight( | |
| 27 IOSurfaceCreateMachPort(io_surface)))); | |
| 28 return true; | |
| 29 } | |
| 30 | |
| 31 void InProcessIOSurfaceManager::UnregisterIOSurface( | |
| 32 gfx::IOSurfaceId io_surface_id, | |
| 33 int client_id) { | |
| 34 base::AutoLock lock(lock_); | |
| 35 | |
| 36 DCHECK(io_surfaces_.find(io_surface_id) != io_surfaces_.end()); | |
| 37 io_surfaces_.erase(io_surface_id); | |
| 38 } | |
| 39 | |
| 40 IOSurfaceRef InProcessIOSurfaceManager::AcquireIOSurface( | |
| 41 gfx::IOSurfaceId io_surface_id) { | |
| 42 base::AutoLock lock(lock_); | |
| 43 | |
| 44 DCHECK(io_surfaces_.find(io_surface_id) != io_surfaces_.end()); | |
| 45 return IOSurfaceLookupFromMachPort(io_surfaces_.get(io_surface_id)->get()); | |
| 46 } | |
| 47 | |
| 48 InProcessIOSurfaceManager::InProcessIOSurfaceManager() { | |
| 49 } | |
| 50 | |
| 51 InProcessIOSurfaceManager::~InProcessIOSurfaceManager() { | |
| 52 } | |
| 53 | |
| 54 } // namespace content | |
| OLD | NEW |