| 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 gpu::SurfaceHandle GpuSurfaceTracker::GetSurfaceForNativeWidget( |
| 40 gfx::AcceleratedWidget widget) { |
| 41 for (SurfaceMap::iterator it = surface_map_.begin(); it != surface_map_.end(); |
| 42 ++it) { |
| 43 if (it->second == widget) |
| 44 return it->first; |
| 45 } |
| 46 |
| 47 return gpu::kNullSurfaceHandle; |
| 48 } |
| 49 |
| 39 void GpuSurfaceTracker::RemoveSurface(gpu::SurfaceHandle surface_handle) { | 50 void GpuSurfaceTracker::RemoveSurface(gpu::SurfaceHandle surface_handle) { |
| 40 base::AutoLock lock(lock_); | 51 base::AutoLock lock(lock_); |
| 41 DCHECK(surface_map_.find(surface_handle) != surface_map_.end()); | 52 DCHECK(surface_map_.find(surface_handle) != surface_map_.end()); |
| 42 surface_map_.erase(surface_handle); | 53 surface_map_.erase(surface_handle); |
| 43 } | 54 } |
| 44 | 55 |
| 45 gfx::AcceleratedWidget GpuSurfaceTracker::AcquireNativeWidget( | 56 gfx::AcceleratedWidget GpuSurfaceTracker::AcquireNativeWidget( |
| 46 gpu::SurfaceHandle surface_handle) { | 57 gpu::SurfaceHandle surface_handle) { |
| 47 base::AutoLock lock(lock_); | 58 base::AutoLock lock(lock_); |
| 48 SurfaceMap::iterator it = surface_map_.find(surface_handle); | 59 SurfaceMap::iterator it = surface_map_.find(surface_handle); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 62 return GetViewSurface(surface_id); | 73 return GetViewSurface(surface_id); |
| 63 } | 74 } |
| 64 #endif | 75 #endif |
| 65 | 76 |
| 66 std::size_t GpuSurfaceTracker::GetSurfaceCount() { | 77 std::size_t GpuSurfaceTracker::GetSurfaceCount() { |
| 67 base::AutoLock lock(lock_); | 78 base::AutoLock lock(lock_); |
| 68 return surface_map_.size(); | 79 return surface_map_.size(); |
| 69 } | 80 } |
| 70 | 81 |
| 71 } // namespace content | 82 } // namespace content |
| OLD | NEW |