| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/gpu/gpu_surface_tracker.h" | 5 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_ANDROID) | 10 #if defined(OS_ANDROID) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 int GpuSurfaceTracker::AddSurfaceForNativeWidget( | 31 int GpuSurfaceTracker::AddSurfaceForNativeWidget( |
| 32 gfx::AcceleratedWidget widget) { | 32 gfx::AcceleratedWidget widget) { |
| 33 base::AutoLock lock(lock_); | 33 base::AutoLock lock(lock_); |
| 34 gpu::SurfaceHandle surface_handle = next_surface_handle_++; | 34 gpu::SurfaceHandle surface_handle = next_surface_handle_++; |
| 35 surface_map_[surface_handle] = widget; | 35 surface_map_[surface_handle] = widget; |
| 36 return surface_handle; | 36 return surface_handle; |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool GpuSurfaceTracker::IsValidSurfaceHandle( |
| 40 gpu::SurfaceHandle surface_handle) const { |
| 41 return surface_map_.find(surface_handle) != surface_map_.end(); |
| 42 } |
| 43 |
| 39 void GpuSurfaceTracker::RemoveSurface(gpu::SurfaceHandle surface_handle) { | 44 void GpuSurfaceTracker::RemoveSurface(gpu::SurfaceHandle surface_handle) { |
| 40 base::AutoLock lock(lock_); | 45 base::AutoLock lock(lock_); |
| 41 DCHECK(surface_map_.find(surface_handle) != surface_map_.end()); | 46 DCHECK(surface_map_.find(surface_handle) != surface_map_.end()); |
| 42 surface_map_.erase(surface_handle); | 47 surface_map_.erase(surface_handle); |
| 43 } | 48 } |
| 44 | 49 |
| 45 gfx::AcceleratedWidget GpuSurfaceTracker::AcquireNativeWidget( | 50 gfx::AcceleratedWidget GpuSurfaceTracker::AcquireNativeWidget( |
| 46 gpu::SurfaceHandle surface_handle) { | 51 gpu::SurfaceHandle surface_handle) { |
| 47 base::AutoLock lock(lock_); | 52 base::AutoLock lock(lock_); |
| 48 SurfaceMap::iterator it = surface_map_.find(surface_handle); | 53 SurfaceMap::iterator it = surface_map_.find(surface_handle); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 62 return GetViewSurface(surface_id); | 67 return GetViewSurface(surface_id); |
| 63 } | 68 } |
| 64 #endif | 69 #endif |
| 65 | 70 |
| 66 std::size_t GpuSurfaceTracker::GetSurfaceCount() { | 71 std::size_t GpuSurfaceTracker::GetSurfaceCount() { |
| 67 base::AutoLock lock(lock_); | 72 base::AutoLock lock(lock_); |
| 68 return surface_map_.size(); | 73 return surface_map_.size(); |
| 69 } | 74 } |
| 70 | 75 |
| 71 } // namespace content | 76 } // namespace content |
| OLD | NEW |