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_WIN) | 9 #if defined(OS_WIN) |
| 10 #include "content/browser/gpu/gpu_surface_reader_win.h" | |
| 10 #include "ui/gfx/surface/accelerated_surface_win.h" | 11 #include "ui/gfx/surface/accelerated_surface_win.h" |
| 11 #endif | 12 #endif |
| 12 | 13 |
| 13 GpuSurfaceTracker::GpuSurfaceTracker() | 14 GpuSurfaceTracker::GpuSurfaceTracker() |
| 14 : next_surface_id_(1) { | 15 : next_surface_id_(1) { |
| 16 #if defined(OS_WIN) | |
| 17 reader_.reset(new GpuSurfaceReader); | |
|
apatrick_chromium
2012/03/07 20:39:37
And if CopySurface was a free function, this would
mazda
2012/03/08 13:14:28
Now I moved the code in CopySurface to RenderWidge
| |
| 18 #endif | |
| 15 } | 19 } |
| 16 | 20 |
| 17 GpuSurfaceTracker::~GpuSurfaceTracker() { | 21 GpuSurfaceTracker::~GpuSurfaceTracker() { |
| 18 } | 22 } |
| 19 | 23 |
| 20 GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() { | 24 GpuSurfaceTracker* GpuSurfaceTracker::GetInstance() { |
| 21 return Singleton<GpuSurfaceTracker>::get(); | 25 return Singleton<GpuSurfaceTracker>::get(); |
| 22 } | 26 } |
| 23 | 27 |
| 24 int GpuSurfaceTracker::AddSurfaceForRenderer(int renderer_id, | 28 int GpuSurfaceTracker::AddSurfaceForRenderer(int renderer_id, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 SurfaceInfo& info = surface_map_[surface_id]; | 87 SurfaceInfo& info = surface_map_[surface_id]; |
| 84 info.handle = handle; | 88 info.handle = handle; |
| 85 } | 89 } |
| 86 | 90 |
| 87 gfx::GLSurfaceHandle GpuSurfaceTracker::GetSurfaceHandle(int surface_id) { | 91 gfx::GLSurfaceHandle GpuSurfaceTracker::GetSurfaceHandle(int surface_id) { |
| 88 base::AutoLock lock(lock_); | 92 base::AutoLock lock(lock_); |
| 89 DCHECK(surface_map_.find(surface_id) != surface_map_.end()); | 93 DCHECK(surface_map_.find(surface_id) != surface_map_.end()); |
| 90 return surface_map_[surface_id].handle; | 94 return surface_map_[surface_id].handle; |
| 91 } | 95 } |
| 92 | 96 |
| 97 bool GpuSurfaceTracker::CopySurface(int surface_id, | |
| 98 const gfx::Size& size, | |
| 99 std::vector<unsigned char>* out) { | |
| 100 base::AutoLock lock(lock_); | |
| 101 #if defined(OS_WIN) | |
|
piman
2012/03/07 21:22:27
&& !defined(USE_AURA)
mazda
2012/03/08 13:14:28
Now I moved the code in CopySurface to RenderWidge
| |
| 102 SurfaceMap::const_iterator itr = surface_map_.find(surface_id); | |
| 103 if (itr == surface_map_.end()) | |
| 104 return false; | |
| 105 return reader_->CopySurface(itr->second, size, out); | |
| 106 #else | |
| 107 // TOOD(mazda): Implement this on other platforms. | |
| 108 NOTIMPLEMENTED(); | |
| 109 return false; | |
| 110 #endif | |
| 111 } | |
| 112 | |
| 93 #if defined(OS_WIN) && !defined(USE_AURA) | 113 #if defined(OS_WIN) && !defined(USE_AURA) |
| 94 | 114 |
| 95 void GpuSurfaceTracker::AsyncPresentAndAcknowledge( | 115 void GpuSurfaceTracker::AsyncPresentAndAcknowledge( |
| 96 int surface_id, | 116 int surface_id, |
| 97 const gfx::Size& size, | 117 const gfx::Size& size, |
| 98 int64 surface_handle, | 118 int64 surface_handle, |
| 99 const base::Closure& completion_task) { | 119 const base::Closure& completion_task) { |
| 100 base::AutoLock lock(lock_); | 120 base::AutoLock lock(lock_); |
| 101 | 121 |
| 102 SurfaceMap::iterator it = surface_map_.find(surface_id); | 122 SurfaceMap::iterator it = surface_map_.find(surface_id); |
| 103 if (it == surface_map_.end() || !it->second.handle.accelerated_surface) { | 123 if (it == surface_map_.end() || !it->second.handle.accelerated_surface) { |
| 104 completion_task.Run(); | 124 completion_task.Run(); |
| 105 return; | 125 return; |
| 106 } | 126 } |
| 107 | 127 |
| 108 it->second.handle.accelerated_surface->AsyncPresentAndAcknowledge( | 128 it->second.handle.accelerated_surface->AsyncPresentAndAcknowledge( |
| 109 it->second.handle.handle, | 129 it->second.handle.handle, |
| 110 size, | 130 size, |
| 111 surface_handle, | 131 surface_handle, |
| 112 completion_task); | 132 completion_task); |
| 113 } | 133 } |
| 114 | 134 |
| 115 #endif // OS_WIN | 135 #endif // OS_WIN |
| 116 | |
| OLD | NEW |