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 "base/command_line.h" | |
11 #include "content/public/common/content_switches.h" | |
12 #include <android/native_window_jni.h> | |
13 #endif | |
14 | |
9 GpuSurfaceTracker::GpuSurfaceTracker() | 15 GpuSurfaceTracker::GpuSurfaceTracker() |
10 : next_surface_id_(1) { | 16 : next_surface_id_(1) { |
11 } | 17 } |
12 | 18 |
13 GpuSurfaceTracker::~GpuSurfaceTracker() { | 19 GpuSurfaceTracker::~GpuSurfaceTracker() { |
20 #if defined(OS_ANDROID) | |
21 // Handles should have been inserted with an extra ref, so release those now. | |
22 for (SurfaceMap::iterator it = surface_map_.begin(); it != surface_map_.end(); | |
23 ++it) { | |
24 const SurfaceInfo& info = it->second; | |
25 if (info.native_widget) | |
26 ANativeWindow_release(info.native_widget); | |
27 } | |
28 #endif | |
14 } | 29 } |
15 | 30 |
16 GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() { | 31 GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() { |
17 return Singleton<GpuSurfaceTracker>::get(); | 32 return Singleton<GpuSurfaceTracker>::get(); |
18 } | 33 } |
19 | 34 |
20 int GpuSurfaceTracker::AddSurfaceForRenderer(int renderer_id, | 35 int GpuSurfaceTracker::AddSurfaceForRenderer(int renderer_id, |
21 int render_widget_id) { | 36 int render_widget_id) { |
22 base::AutoLock lock(lock_); | 37 base::AutoLock lock(lock_); |
23 SurfaceInfo info = { | 38 SurfaceInfo info = { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 } | 102 } |
88 | 103 |
89 gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceWindowHandle( | 104 gfx::PluginWindowHandle GpuSurfaceTracker::GetSurfaceWindowHandle( |
90 int surface_id) { | 105 int surface_id) { |
91 base::AutoLock lock(lock_); | 106 base::AutoLock lock(lock_); |
92 SurfaceMap::iterator it = surface_map_.find(surface_id); | 107 SurfaceMap::iterator it = surface_map_.find(surface_id); |
93 if (it == surface_map_.end()) | 108 if (it == surface_map_.end()) |
94 return gfx::kNullPluginWindow; | 109 return gfx::kNullPluginWindow; |
95 return it->second.handle.handle; | 110 return it->second.handle.handle; |
96 } | 111 } |
112 | |
113 gfx::AcceleratedWidget GpuSurfaceTracker::GetNativeWidget(int surface_id) { | |
114 GpuSurfaceTracker* tracker = GpuSurfaceTracker::GetInstance(); | |
apatrick_chromium
2012/07/24 18:34:16
This member function is not static. Why is it gett
no sievers
2012/07/26 21:21:17
Done.
| |
115 base::AutoLock lock(tracker->lock_); | |
116 DCHECK(tracker->surface_map_.find(surface_id) != tracker->surface_map_.end()); | |
117 return tracker->surface_map_[surface_id].native_widget; | |
apatrick_chromium
2012/07/24 18:34:16
How exactly does this differ from the handle retur
no sievers
2012/07/26 21:21:17
The native AcceleratedWidget on Android is a point
| |
118 } | |
119 | |
120 #if defined(OS_ANDROID) | |
121 gfx::AcceleratedWidget GetNativeWidgetAndroid(int surface_id) { | |
122 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)); | |
123 GpuSurfaceTracker* tracker = GpuSurfaceTracker::GetInstance(); | |
124 return tracker->GetNativeWidget(surface_id); | |
125 } | |
126 #endif | |
OLD | NEW |