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 "gpu/ipc/common/gpu_surface_tracker.h" | 5 #include "gpu/ipc/common/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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 void GpuSurfaceTracker::RegisterViewSurface( | 66 void GpuSurfaceTracker::RegisterViewSurface( |
67 int surface_id, jobject j_surface) { | 67 int surface_id, jobject j_surface) { |
68 base::AutoLock lock(surface_view_map_lock_); | 68 base::AutoLock lock(surface_view_map_lock_); |
69 DCHECK(surface_view_map_.find(surface_id) == surface_view_map_.end()); | 69 DCHECK(surface_view_map_.find(surface_id) == surface_view_map_.end()); |
70 | 70 |
71 surface_view_map_[surface_id] = | 71 surface_view_map_[surface_id] = |
72 gl::ScopedJavaSurface::AcquireExternalSurface(j_surface); | 72 gl::ScopedJavaSurface::AcquireExternalSurface(j_surface); |
73 CHECK(surface_view_map_[surface_id].IsValid()); | 73 CHECK(surface_view_map_[surface_id].IsValid()); |
74 } | 74 } |
75 | 75 |
| 76 int GpuSurfaceTracker::RegisterViewSurface(jobject j_surface) { |
| 77 int surface_id = 0; |
| 78 { |
| 79 base::AutoLock lock(surface_view_map_lock_); |
| 80 surface_id = next_surface_handle_++; |
| 81 } |
| 82 |
| 83 RegisterViewSurface(surface_id, j_surface); |
| 84 |
| 85 return surface_id; |
| 86 } |
| 87 |
76 void GpuSurfaceTracker::UnregisterViewSurface(int surface_id) | 88 void GpuSurfaceTracker::UnregisterViewSurface(int surface_id) |
77 { | 89 { |
78 base::AutoLock lock(surface_view_map_lock_); | 90 base::AutoLock lock(surface_view_map_lock_); |
79 DCHECK(surface_view_map_.find(surface_id) != surface_view_map_.end()); | 91 DCHECK(surface_view_map_.find(surface_id) != surface_view_map_.end()); |
80 surface_view_map_.erase(surface_id); | 92 surface_view_map_.erase(surface_id); |
81 } | 93 } |
82 | 94 |
83 gl::ScopedJavaSurface GpuSurfaceTracker::AcquireJavaSurface(int surface_id) { | 95 gl::ScopedJavaSurface GpuSurfaceTracker::AcquireJavaSurface(int surface_id) { |
84 base::AutoLock lock(surface_view_map_lock_); | 96 base::AutoLock lock(surface_view_map_lock_); |
85 SurfaceViewMap::const_iterator iter = surface_view_map_.find(surface_id); | 97 SurfaceViewMap::const_iterator iter = surface_view_map_.find(surface_id); |
86 if (iter == surface_view_map_.end()) | 98 if (iter == surface_view_map_.end()) |
87 return gl::ScopedJavaSurface(); | 99 return gl::ScopedJavaSurface(); |
88 | 100 |
89 const gl::ScopedJavaSurface& j_surface = iter->second; | 101 const gl::ScopedJavaSurface& j_surface = iter->second; |
90 DCHECK(j_surface.IsValid()); | 102 DCHECK(j_surface.IsValid()); |
91 return gl::ScopedJavaSurface::AcquireExternalSurface( | 103 return gl::ScopedJavaSurface::AcquireExternalSurface( |
92 j_surface.j_surface().obj()); | 104 j_surface.j_surface().obj()); |
93 } | 105 } |
94 #endif | 106 #endif |
95 | 107 |
96 std::size_t GpuSurfaceTracker::GetSurfaceCount() { | 108 std::size_t GpuSurfaceTracker::GetSurfaceCount() { |
97 base::AutoLock lock(surface_map_lock_); | 109 base::AutoLock lock(surface_map_lock_); |
98 return surface_map_.size(); | 110 return surface_map_.size(); |
99 } | 111 } |
100 | 112 |
101 } // namespace gpu | 113 } // namespace gpu |
OLD | NEW |