| 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/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 int32 route_id, | 281 int32 route_id, |
| 282 int renderer_host_id, | 282 int renderer_host_id, |
| 283 const gpu::Mailbox& received_mailbox, | 283 const gpu::Mailbox& received_mailbox, |
| 284 const gfx::Size& received_size, | 284 const gfx::Size& received_size, |
| 285 bool skip_frame, | 285 bool skip_frame, |
| 286 const scoped_refptr<ui::Texture>& texture_to_produce) { | 286 const scoped_refptr<ui::Texture>& texture_to_produce) { |
| 287 cc::CompositorFrameAck ack; | 287 cc::CompositorFrameAck ack; |
| 288 ack.gl_frame_data.reset(new cc::GLFrameData()); | 288 ack.gl_frame_data.reset(new cc::GLFrameData()); |
| 289 DCHECK(!texture_to_produce || !skip_frame); | 289 DCHECK(!texture_to_produce || !skip_frame); |
| 290 if (texture_to_produce) { | 290 if (texture_to_produce) { |
| 291 std::string mailbox_name = texture_to_produce->Produce(); | 291 ack.gl_frame_data->mailbox = texture_to_produce->Produce(); |
| 292 std::copy(mailbox_name.data(), | |
| 293 mailbox_name.data() + mailbox_name.length(), | |
| 294 reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name)); | |
| 295 ack.gl_frame_data->size = texture_to_produce->size(); | 292 ack.gl_frame_data->size = texture_to_produce->size(); |
| 296 ack.gl_frame_data->sync_point = | 293 ack.gl_frame_data->sync_point = |
| 297 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); | 294 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); |
| 298 } else if (skip_frame) { | 295 } else if (skip_frame) { |
| 299 // Skip the frame, i.e. tell the producer to reuse the same buffer that | 296 // Skip the frame, i.e. tell the producer to reuse the same buffer that |
| 300 // we just received. | 297 // we just received. |
| 301 ack.gl_frame_data->size = received_size; | 298 ack.gl_frame_data->size = received_size; |
| 302 ack.gl_frame_data->mailbox = received_mailbox; | 299 ack.gl_frame_data->mailbox = received_mailbox; |
| 303 } | 300 } |
| 304 | 301 |
| 305 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | 302 RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
| 306 route_id, renderer_host_id, ack); | 303 route_id, renderer_host_id, ack); |
| 307 } | 304 } |
| 308 | 305 |
| 309 void AcknowledgeBufferForGpu( | 306 void AcknowledgeBufferForGpu( |
| 310 int32 route_id, | 307 int32 route_id, |
| 311 int gpu_host_id, | 308 int gpu_host_id, |
| 312 const std::string& received_mailbox, | 309 const gpu::Mailbox& received_mailbox, |
| 313 bool skip_frame, | 310 bool skip_frame, |
| 314 const scoped_refptr<ui::Texture>& texture_to_produce) { | 311 const scoped_refptr<ui::Texture>& texture_to_produce) { |
| 315 AcceleratedSurfaceMsg_BufferPresented_Params ack; | 312 AcceleratedSurfaceMsg_BufferPresented_Params ack; |
| 316 uint32 sync_point = 0; | 313 uint32 sync_point = 0; |
| 317 DCHECK(!texture_to_produce || !skip_frame); | 314 DCHECK(!texture_to_produce || !skip_frame); |
| 318 if (texture_to_produce) { | 315 if (texture_to_produce) { |
| 319 ack.mailbox_name = texture_to_produce->Produce(); | 316 ack.mailbox_name = texture_to_produce->Produce(); |
| 320 sync_point = | 317 sync_point = |
| 321 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); | 318 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); |
| 322 } else if (skip_frame) { | 319 } else if (skip_frame) { |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 } | 1152 } |
| 1156 } else { | 1153 } else { |
| 1157 window_->SetExternalTexture(NULL); | 1154 window_->SetExternalTexture(NULL); |
| 1158 resize_locks_.clear(); | 1155 resize_locks_.clear(); |
| 1159 } | 1156 } |
| 1160 } | 1157 } |
| 1161 | 1158 |
| 1162 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | 1159 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| 1163 const gfx::Rect& surface_rect, | 1160 const gfx::Rect& surface_rect, |
| 1164 const gfx::Rect& damage_rect, | 1161 const gfx::Rect& damage_rect, |
| 1165 const std::string& mailbox_name, | 1162 const gpu::Mailbox& mailbox_name, |
| 1166 const BufferPresentedCallback& ack_callback) { | 1163 const BufferPresentedCallback& ack_callback) { |
| 1167 if (last_swapped_surface_size_ != surface_rect.size()) { | 1164 if (last_swapped_surface_size_ != surface_rect.size()) { |
| 1168 // The surface could have shrunk since we skipped an update, in which | 1165 // The surface could have shrunk since we skipped an update, in which |
| 1169 // case we can expect a full update. | 1166 // case we can expect a full update. |
| 1170 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; | 1167 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; |
| 1171 skipped_damage_.setEmpty(); | 1168 skipped_damage_.setEmpty(); |
| 1172 last_swapped_surface_size_ = surface_rect.size(); | 1169 last_swapped_surface_size_ = surface_rect.size(); |
| 1173 } | 1170 } |
| 1174 | 1171 |
| 1175 if (ShouldSkipFrame(surface_rect.size()) || mailbox_name.empty()) { | 1172 if (ShouldSkipFrame(surface_rect.size()) || mailbox_name.IsZero()) { |
| 1176 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); | 1173 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); |
| 1177 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1174 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| 1178 return false; | 1175 return false; |
| 1179 } | 1176 } |
| 1180 | 1177 |
| 1181 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1178 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1182 current_surface_ = factory->CreateTransportClient(device_scale_factor_); | 1179 current_surface_ = factory->CreateTransportClient(device_scale_factor_); |
| 1183 if (!current_surface_) { | 1180 if (!current_surface_) { |
| 1184 LOG(ERROR) << "Failed to create ImageTransport texture"; | 1181 LOG(ERROR) << "Failed to create ImageTransport texture"; |
| 1185 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1182 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 | 1259 |
| 1263 if (!frame.gl_frame_data->sync_point) { | 1260 if (!frame.gl_frame_data->sync_point) { |
| 1264 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; | 1261 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; |
| 1265 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1262 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| 1266 return; | 1263 return; |
| 1267 } | 1264 } |
| 1268 | 1265 |
| 1269 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1266 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1270 factory->WaitSyncPoint(frame.gl_frame_data->sync_point); | 1267 factory->WaitSyncPoint(frame.gl_frame_data->sync_point); |
| 1271 | 1268 |
| 1272 std::string mailbox_name( | |
| 1273 reinterpret_cast<const char*>(frame.gl_frame_data->mailbox.name), | |
| 1274 sizeof(frame.gl_frame_data->mailbox.name)); | |
| 1275 BuffersSwapped( | 1269 BuffersSwapped( |
| 1276 frame.gl_frame_data->size, mailbox_name, ack_callback); | 1270 frame.gl_frame_data->size, frame.gl_frame_data->mailbox, ack_callback); |
| 1277 } | 1271 } |
| 1278 | 1272 |
| 1279 void RenderWidgetHostViewAura::BuffersSwapped( | 1273 void RenderWidgetHostViewAura::BuffersSwapped( |
| 1280 const gfx::Size& size, | 1274 const gfx::Size& size, |
| 1281 const std::string& mailbox_name, | 1275 const gpu::Mailbox& mailbox_name, |
| 1282 const BufferPresentedCallback& ack_callback) { | 1276 const BufferPresentedCallback& ack_callback) { |
| 1283 scoped_refptr<ui::Texture> texture_to_return(current_surface_); | 1277 scoped_refptr<ui::Texture> texture_to_return(current_surface_); |
| 1284 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); | 1278 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); |
| 1285 if (!SwapBuffersPrepare( | 1279 if (!SwapBuffersPrepare( |
| 1286 surface_rect, surface_rect, mailbox_name, ack_callback)) { | 1280 surface_rect, surface_rect, mailbox_name, ack_callback)) { |
| 1287 return; | 1281 return; |
| 1288 } | 1282 } |
| 1289 | 1283 |
| 1290 previous_damage_.setRect(RectToSkIRect(surface_rect)); | 1284 previous_damage_.setRect(RectToSkIRect(surface_rect)); |
| 1291 skipped_damage_.setEmpty(); | 1285 skipped_damage_.setEmpty(); |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2437 RenderWidgetHost* widget) { | 2431 RenderWidgetHost* widget) { |
| 2438 return new RenderWidgetHostViewAura(widget); | 2432 return new RenderWidgetHostViewAura(widget); |
| 2439 } | 2433 } |
| 2440 | 2434 |
| 2441 // static | 2435 // static |
| 2442 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 2436 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2443 GetScreenInfoForWindow(results, NULL); | 2437 GetScreenInfoForWindow(results, NULL); |
| 2444 } | 2438 } |
| 2445 | 2439 |
| 2446 } // namespace content | 2440 } // namespace content |
| OLD | NEW |