| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/render_widget_host_view_views.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 // (created by the GPU process), which is later displayed by the browser. | 1112 // (created by the GPU process), which is later displayed by the browser. |
| 1113 // As the GPU process creates this surface, we can return any non-zero value. | 1113 // As the GPU process creates this surface, we can return any non-zero value. |
| 1114 return 1; | 1114 return 1; |
| 1115 } | 1115 } |
| 1116 | 1116 |
| 1117 void RenderWidgetHostViewViews::AcceleratedSurfaceNew( | 1117 void RenderWidgetHostViewViews::AcceleratedSurfaceNew( |
| 1118 int32 width, | 1118 int32 width, |
| 1119 int32 height, | 1119 int32 height, |
| 1120 uint64* surface_id, | 1120 uint64* surface_id, |
| 1121 TransportDIB::Handle* surface_handle) { | 1121 TransportDIB::Handle* surface_handle) { |
| 1122 scoped_ptr<AcceleratedSurfaceContainerLinux> surface( | 1122 scoped_refptr<AcceleratedSurfaceContainerLinux> surface( |
| 1123 AcceleratedSurfaceContainerLinux::CreateAcceleratedSurfaceContainer( | 1123 AcceleratedSurfaceContainerLinux::Create(gfx::Size(width, height))); |
| 1124 gfx::Size(width, height))); | |
| 1125 if (!surface->Initialize(surface_id)) { | 1124 if (!surface->Initialize(surface_id)) { |
| 1126 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; | 1125 LOG(ERROR) << "Failed to create AcceleratedSurfaceContainer"; |
| 1127 return; | 1126 return; |
| 1128 } | 1127 } |
| 1129 *surface_handle = surface->Handle(); | 1128 *surface_handle = surface->Handle(); |
| 1130 | 1129 |
| 1131 accelerated_surface_containers_[*surface_id] = surface.release(); | 1130 accelerated_surface_containers_[*surface_id] = surface.release(); |
| 1132 } | 1131 } |
| 1133 | 1132 |
| 1134 void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) { | 1133 void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) { |
| 1135 accelerated_surface_containers_.erase(surface_id); | 1134 accelerated_surface_containers_.erase(surface_id); |
| 1136 } | 1135 } |
| 1137 | 1136 |
| 1138 void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped( | 1137 void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped( |
| 1139 uint64 surface_id, | 1138 uint64 surface_id, |
| 1140 int32 route_id, | 1139 int32 route_id, |
| 1141 int gpu_host_id) { | 1140 int gpu_host_id) { |
| 1142 SetExternalTexture(accelerated_surface_containers_[surface_id].get()); | 1141 SetExternalTexture(accelerated_surface_containers_[surface_id]->GetTexture()); |
| 1143 glFlush(); | 1142 glFlush(); |
| 1144 | 1143 |
| 1145 if (!GetWidget() || !GetWidget()->GetCompositor()) { | 1144 if (!GetWidget() || !GetWidget()->GetCompositor()) { |
| 1146 // We have no compositor, so we have no way to display the surface | 1145 // We have no compositor, so we have no way to display the surface |
| 1147 AcknowledgeSwapBuffers(route_id, gpu_host_id); // Must still send the ACK | 1146 AcknowledgeSwapBuffers(route_id, gpu_host_id); // Must still send the ACK |
| 1148 } else { | 1147 } else { |
| 1149 // Add sending an ACK to the list of things to do OnCompositingEnded | 1148 // Add sending an ACK to the list of things to do OnCompositingEnded |
| 1150 on_compositing_ended_callbacks_.push_back( | 1149 on_compositing_ended_callbacks_.push_back( |
| 1151 base::Bind(AcknowledgeSwapBuffers, route_id, gpu_host_id)); | 1150 base::Bind(AcknowledgeSwapBuffers, route_id, gpu_host_id)); |
| 1152 ui::Compositor *compositor = GetWidget()->GetCompositor(); | 1151 ui::Compositor *compositor = GetWidget()->GetCompositor(); |
| 1153 if (!compositor->HasObserver(this)) | 1152 if (!compositor->HasObserver(this)) |
| 1154 compositor->AddObserver(this); | 1153 compositor->AddObserver(this); |
| 1155 } | 1154 } |
| 1156 } | 1155 } |
| 1157 | 1156 |
| 1158 void RenderWidgetHostViewViews::OnCompositingEnded(ui::Compositor* compositor) { | 1157 void RenderWidgetHostViewViews::OnCompositingEnded(ui::Compositor* compositor) { |
| 1159 for (std::vector< base::Callback<void(void)> >::const_iterator | 1158 for (std::vector< base::Callback<void(void)> >::const_iterator |
| 1160 it = on_compositing_ended_callbacks_.begin(); | 1159 it = on_compositing_ended_callbacks_.begin(); |
| 1161 it != on_compositing_ended_callbacks_.end(); ++it) { | 1160 it != on_compositing_ended_callbacks_.end(); ++it) { |
| 1162 it->Run(); | 1161 it->Run(); |
| 1163 } | 1162 } |
| 1164 on_compositing_ended_callbacks_.clear(); | 1163 on_compositing_ended_callbacks_.clear(); |
| 1165 compositor->RemoveObserver(this); | 1164 compositor->RemoveObserver(this); |
| 1166 } | 1165 } |
| 1167 | 1166 |
| 1168 #endif | 1167 #endif |
| OLD | NEW |