Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: content/browser/gpu/gpu_surface_tracker.cc

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #if defined(OS_ANDROID) 7 #if defined(OS_ANDROID)
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 #endif // defined(OS_ANDROID) 9 #endif // defined(OS_ANDROID)
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 12
13 #if defined(TOOLKIT_GTK)
14 #include "base/bind.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "ui/gfx/gtk_native_view_id_manager.h"
17 #endif // defined(TOOLKIT_GTK)
18
19 namespace content { 13 namespace content {
20 14
21 namespace {
22 #if defined(TOOLKIT_GTK)
23
24 void ReleasePermanentXIDDispatcher(
25 const gfx::PluginWindowHandle& surface) {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27
28 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
29 manager->ReleasePermanentXID(surface);
30 }
31
32 // Implementation of SurfaceRef that allows GTK to ref and unref the
33 // surface with the GtkNativeViewManager.
34 class SurfaceRefPluginWindow : public GpuSurfaceTracker::SurfaceRef {
35 public:
36 SurfaceRefPluginWindow(const gfx::PluginWindowHandle& surface_ref);
37 private:
38 virtual ~SurfaceRefPluginWindow();
39 gfx::PluginWindowHandle surface_;
40 };
41
42 SurfaceRefPluginWindow::SurfaceRefPluginWindow(
43 const gfx::PluginWindowHandle& surface)
44 : surface_(surface) {
45 if (surface_ != gfx::kNullPluginWindow) {
46 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
47 if (!manager->AddRefPermanentXID(surface_)) {
48 LOG(ERROR) << "Surface " << surface << " cannot be referenced.";
49 }
50 }
51 }
52
53 SurfaceRefPluginWindow::~SurfaceRefPluginWindow() {
54 if (surface_ != gfx::kNullPluginWindow) {
55 BrowserThread::PostTask(BrowserThread::UI,
56 FROM_HERE,
57 base::Bind(&ReleasePermanentXIDDispatcher,
58 surface_));
59 }
60 }
61 #endif // defined(TOOLKIT_GTK)
62 } // anonymous
63
64 GpuSurfaceTracker::GpuSurfaceTracker() 15 GpuSurfaceTracker::GpuSurfaceTracker()
65 : next_surface_id_(1) { 16 : next_surface_id_(1) {
66 GpuSurfaceLookup::InitInstance(this); 17 GpuSurfaceLookup::InitInstance(this);
67 } 18 }
68 19
69 GpuSurfaceTracker::~GpuSurfaceTracker() { 20 GpuSurfaceTracker::~GpuSurfaceTracker() {
70 GpuSurfaceLookup::InitInstance(NULL); 21 GpuSurfaceLookup::InitInstance(NULL);
71 } 22 }
72 23
73 GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() { 24 GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 *render_widget_id = info.render_widget_id; 78 *render_widget_id = info.render_widget_id;
128 return true; 79 return true;
129 } 80 }
130 81
131 void GpuSurfaceTracker::SetSurfaceHandle(int surface_id, 82 void GpuSurfaceTracker::SetSurfaceHandle(int surface_id,
132 const gfx::GLSurfaceHandle& handle) { 83 const gfx::GLSurfaceHandle& handle) {
133 base::AutoLock lock(lock_); 84 base::AutoLock lock(lock_);
134 DCHECK(surface_map_.find(surface_id) != surface_map_.end()); 85 DCHECK(surface_map_.find(surface_id) != surface_map_.end());
135 SurfaceInfo& info = surface_map_[surface_id]; 86 SurfaceInfo& info = surface_map_[surface_id];
136 info.handle = handle; 87 info.handle = handle;
137 #if defined(TOOLKIT_GTK)
138 info.surface_ref = new SurfaceRefPluginWindow(handle.handle);
139 #endif // defined(TOOLKIT_GTK)
140 } 88 }
141 89
142 gfx::GLSurfaceHandle GpuSurfaceTracker::GetSurfaceHandle(int surface_id) { 90 gfx::GLSurfaceHandle GpuSurfaceTracker::GetSurfaceHandle(int surface_id) {
143 base::AutoLock lock(lock_); 91 base::AutoLock lock(lock_);
144 SurfaceMap::iterator it = surface_map_.find(surface_id); 92 SurfaceMap::iterator it = surface_map_.find(surface_id);
145 if (it == surface_map_.end()) 93 if (it == surface_map_.end())
146 return gfx::GLSurfaceHandle(); 94 return gfx::GLSurfaceHandle();
147 return it->second.handle; 95 return it->second.handle;
148 } 96 }
149 97
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 : renderer_id(renderer_id), 139 : renderer_id(renderer_id),
192 render_widget_id(render_widget_id), 140 render_widget_id(render_widget_id),
193 native_widget(native_widget), 141 native_widget(native_widget),
194 handle(handle), 142 handle(handle),
195 surface_ref(surface_ref) { } 143 surface_ref(surface_ref) { }
196 144
197 GpuSurfaceTracker::SurfaceInfo::~SurfaceInfo() { } 145 GpuSurfaceTracker::SurfaceInfo::~SurfaceInfo() { }
198 146
199 147
200 } // namespace content 148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698