Chromium Code Reviews| 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 | 8 |
| 9 #if defined(OS_ANDROID) | |
| 10 #include <android/native_window_jni.h> | |
| 11 #endif // defined(OS_ANDROID) | |
|
no sievers
2013/01/28 23:05:03
I *think* this might belong above including loggin
boliu
2013/01/28 23:42:13
Done.
| |
| 12 | |
| 9 namespace content { | 13 namespace content { |
| 10 | 14 |
| 11 GpuSurfaceTracker::GpuSurfaceTracker() | 15 GpuSurfaceTracker::GpuSurfaceTracker() |
| 12 : next_surface_id_(1) { | 16 : next_surface_id_(1) { |
| 13 GpuSurfaceLookup::InitInstance(this); | 17 GpuSurfaceLookup::InitInstance(this); |
| 14 } | 18 } |
| 15 | 19 |
| 16 GpuSurfaceTracker::~GpuSurfaceTracker() { | 20 GpuSurfaceTracker::~GpuSurfaceTracker() { |
| 17 GpuSurfaceLookup::InitInstance(NULL); | 21 GpuSurfaceLookup::InitInstance(NULL); |
| 18 } | 22 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 96 |
| 93 gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceWindowHandle( | 97 gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceWindowHandle( |
| 94 int surface_id) { | 98 int surface_id) { |
| 95 base::AutoLock lock(lock_); | 99 base::AutoLock lock(lock_); |
| 96 SurfaceMap::iterator it = surface_map_.find(surface_id); | 100 SurfaceMap::iterator it = surface_map_.find(surface_id); |
| 97 if (it == surface_map_.end()) | 101 if (it == surface_map_.end()) |
| 98 return gfx::kNullPluginWindow; | 102 return gfx::kNullPluginWindow; |
| 99 return it->second.handle.handle; | 103 return it->second.handle.handle; |
| 100 } | 104 } |
| 101 | 105 |
| 102 gfx::AcceleratedWidget GpuSurfaceTracker::GetNativeWidget(int surface_id) { | 106 gfx::AcceleratedWidget GpuSurfaceTracker::GetNativeWidget(int surface_id) { |
|
no sievers
2013/01/28 23:05:03
Could you rename this to AcquireNativeWidget() so
| |
| 103 base::AutoLock lock(lock_); | 107 base::AutoLock lock(lock_); |
| 104 SurfaceMap::iterator it = surface_map_.find(surface_id); | 108 SurfaceMap::iterator it = surface_map_.find(surface_id); |
| 105 if (it == surface_map_.end()) | 109 if (it == surface_map_.end()) |
| 106 return gfx::kNullAcceleratedWidget; | 110 return gfx::kNullAcceleratedWidget; |
| 111 | |
| 112 #if defined(OS_ANDROID) | |
| 113 if (it->second.native_widget != gfx::kNullAcceleratedWidget) | |
| 114 ANativeWindow_acquire(it->second.native_widget); | |
| 115 #endif // defined(OS_ANDROID) | |
| 116 | |
| 107 return it->second.native_widget; | 117 return it->second.native_widget; |
| 108 } | 118 } |
| 109 | 119 |
| 110 void GpuSurfaceTracker::SetNativeWidget( | 120 void GpuSurfaceTracker::SetNativeWidget( |
| 111 int surface_id, gfx::AcceleratedWidget widget) { | 121 int surface_id, gfx::AcceleratedWidget widget) { |
| 112 base::AutoLock lock(lock_); | 122 base::AutoLock lock(lock_); |
| 113 SurfaceMap::iterator it = surface_map_.find(surface_id); | 123 SurfaceMap::iterator it = surface_map_.find(surface_id); |
| 114 DCHECK(it != surface_map_.end()); | 124 DCHECK(it != surface_map_.end()); |
| 115 it->second.native_widget = widget; | 125 it->second.native_widget = widget; |
| 116 } | 126 } |
| 117 | 127 |
| 118 std::size_t GpuSurfaceTracker::GetSurfaceCount() { | 128 std::size_t GpuSurfaceTracker::GetSurfaceCount() { |
| 119 base::AutoLock lock(lock_); | 129 base::AutoLock lock(lock_); |
| 120 return surface_map_.size(); | 130 return surface_map_.size(); |
| 121 } | 131 } |
| 122 | 132 |
| 123 } // namespace content | 133 } // namespace content |
| OLD | NEW |