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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 int32 route_id, | 282 int32 route_id, |
283 int renderer_host_id, | 283 int renderer_host_id, |
284 const gpu::Mailbox& received_mailbox, | 284 const gpu::Mailbox& received_mailbox, |
285 const gfx::Size& received_size, | 285 const gfx::Size& received_size, |
286 bool skip_frame, | 286 bool skip_frame, |
287 const scoped_refptr<ui::Texture>& texture_to_produce) { | 287 const scoped_refptr<ui::Texture>& texture_to_produce) { |
288 cc::CompositorFrameAck ack; | 288 cc::CompositorFrameAck ack; |
289 ack.gl_frame_data.reset(new cc::GLFrameData()); | 289 ack.gl_frame_data.reset(new cc::GLFrameData()); |
290 DCHECK(!texture_to_produce || !skip_frame); | 290 DCHECK(!texture_to_produce || !skip_frame); |
291 if (texture_to_produce) { | 291 if (texture_to_produce) { |
292 ack.gl_frame_data->mailbox = texture_to_produce->Produce(); | 292 std::string mailbox_name = texture_to_produce->Produce(); |
| 293 std::copy(mailbox_name.data(), |
| 294 mailbox_name.data() + mailbox_name.length(), |
| 295 reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name)); |
293 ack.gl_frame_data->size = texture_to_produce->size(); | 296 ack.gl_frame_data->size = texture_to_produce->size(); |
294 ack.gl_frame_data->sync_point = | 297 ack.gl_frame_data->sync_point = |
295 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); | 298 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); |
296 } else if (skip_frame) { | 299 } else if (skip_frame) { |
297 // Skip the frame, i.e. tell the producer to reuse the same buffer that | 300 // Skip the frame, i.e. tell the producer to reuse the same buffer that |
298 // we just received. | 301 // we just received. |
299 ack.gl_frame_data->size = received_size; | 302 ack.gl_frame_data->size = received_size; |
300 ack.gl_frame_data->mailbox = received_mailbox; | 303 ack.gl_frame_data->mailbox = received_mailbox; |
301 } | 304 } |
302 | 305 |
303 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | 306 RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
304 route_id, renderer_host_id, ack); | 307 route_id, renderer_host_id, ack); |
305 } | 308 } |
306 | 309 |
307 void AcknowledgeBufferForGpu( | 310 void AcknowledgeBufferForGpu( |
308 int32 route_id, | 311 int32 route_id, |
309 int gpu_host_id, | 312 int gpu_host_id, |
310 const gpu::Mailbox& received_mailbox, | 313 const std::string& received_mailbox, |
311 bool skip_frame, | 314 bool skip_frame, |
312 const scoped_refptr<ui::Texture>& texture_to_produce) { | 315 const scoped_refptr<ui::Texture>& texture_to_produce) { |
313 AcceleratedSurfaceMsg_BufferPresented_Params ack; | 316 AcceleratedSurfaceMsg_BufferPresented_Params ack; |
314 uint32 sync_point = 0; | 317 uint32 sync_point = 0; |
315 DCHECK(!texture_to_produce || !skip_frame); | 318 DCHECK(!texture_to_produce || !skip_frame); |
316 if (texture_to_produce) { | 319 if (texture_to_produce) { |
317 ack.mailbox_name = texture_to_produce->Produce(); | 320 ack.mailbox_name = texture_to_produce->Produce(); |
318 sync_point = | 321 sync_point = |
319 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); | 322 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); |
320 } else if (skip_frame) { | 323 } else if (skip_frame) { |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 CheckResizeLocks(container_size); | 1157 CheckResizeLocks(container_size); |
1155 } else { | 1158 } else { |
1156 window_->SetExternalTexture(NULL); | 1159 window_->SetExternalTexture(NULL); |
1157 resize_locks_.clear(); | 1160 resize_locks_.clear(); |
1158 } | 1161 } |
1159 } | 1162 } |
1160 | 1163 |
1161 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | 1164 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
1162 const gfx::Rect& surface_rect, | 1165 const gfx::Rect& surface_rect, |
1163 const gfx::Rect& damage_rect, | 1166 const gfx::Rect& damage_rect, |
1164 const gpu::Mailbox& mailbox_name, | 1167 const std::string& mailbox_name, |
1165 const BufferPresentedCallback& ack_callback) { | 1168 const BufferPresentedCallback& ack_callback) { |
1166 if (last_swapped_surface_size_ != surface_rect.size()) { | 1169 if (last_swapped_surface_size_ != surface_rect.size()) { |
1167 // The surface could have shrunk since we skipped an update, in which | 1170 // The surface could have shrunk since we skipped an update, in which |
1168 // case we can expect a full update. | 1171 // case we can expect a full update. |
1169 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; | 1172 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; |
1170 skipped_damage_.setEmpty(); | 1173 skipped_damage_.setEmpty(); |
1171 last_swapped_surface_size_ = surface_rect.size(); | 1174 last_swapped_surface_size_ = surface_rect.size(); |
1172 } | 1175 } |
1173 | 1176 |
1174 if (ShouldSkipFrame(ConvertSizeToDIP(this, surface_rect.size())) || | 1177 if (ShouldSkipFrame(ConvertSizeToDIP(this, surface_rect.size())) || |
1175 mailbox_name.IsZero()) { | 1178 mailbox_name.empty()) { |
1176 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); | 1179 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); |
1177 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1180 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
1178 return false; | 1181 return false; |
1179 } | 1182 } |
1180 | 1183 |
1181 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1184 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1182 current_surface_ = factory->CreateTransportClient(device_scale_factor_); | 1185 current_surface_ = factory->CreateTransportClient(device_scale_factor_); |
1183 if (!current_surface_) { | 1186 if (!current_surface_) { |
1184 LOG(ERROR) << "Failed to create ImageTransport texture"; | 1187 LOG(ERROR) << "Failed to create ImageTransport texture"; |
1185 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1188 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 | 1310 |
1308 if (!frame->gl_frame_data->sync_point) { | 1311 if (!frame->gl_frame_data->sync_point) { |
1309 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; | 1312 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; |
1310 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1313 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
1311 return; | 1314 return; |
1312 } | 1315 } |
1313 | 1316 |
1314 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1317 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1315 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); | 1318 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); |
1316 | 1319 |
| 1320 std::string mailbox_name( |
| 1321 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), |
| 1322 sizeof(frame->gl_frame_data->mailbox.name)); |
1317 BuffersSwapped( | 1323 BuffersSwapped( |
1318 frame->gl_frame_data->size, frame->gl_frame_data->mailbox, ack_callback); | 1324 frame->gl_frame_data->size, mailbox_name, ack_callback); |
1319 } | 1325 } |
1320 | 1326 |
1321 void RenderWidgetHostViewAura::BuffersSwapped( | 1327 void RenderWidgetHostViewAura::BuffersSwapped( |
1322 const gfx::Size& size, | 1328 const gfx::Size& size, |
1323 const gpu::Mailbox& mailbox_name, | 1329 const std::string& mailbox_name, |
1324 const BufferPresentedCallback& ack_callback) { | 1330 const BufferPresentedCallback& ack_callback) { |
1325 scoped_refptr<ui::Texture> texture_to_return(current_surface_); | 1331 scoped_refptr<ui::Texture> texture_to_return(current_surface_); |
1326 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); | 1332 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); |
1327 if (!SwapBuffersPrepare( | 1333 if (!SwapBuffersPrepare( |
1328 surface_rect, surface_rect, mailbox_name, ack_callback)) { | 1334 surface_rect, surface_rect, mailbox_name, ack_callback)) { |
1329 return; | 1335 return; |
1330 } | 1336 } |
1331 | 1337 |
1332 previous_damage_.setRect(RectToSkIRect(surface_rect)); | 1338 previous_damage_.setRect(RectToSkIRect(surface_rect)); |
1333 skipped_damage_.setEmpty(); | 1339 skipped_damage_.setEmpty(); |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2479 RenderWidgetHost* widget) { | 2485 RenderWidgetHost* widget) { |
2480 return new RenderWidgetHostViewAura(widget); | 2486 return new RenderWidgetHostViewAura(widget); |
2481 } | 2487 } |
2482 | 2488 |
2483 // static | 2489 // static |
2484 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 2490 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
2485 GetScreenInfoForWindow(results, NULL); | 2491 GetScreenInfoForWindow(results, NULL); |
2486 } | 2492 } |
2487 | 2493 |
2488 } // namespace content | 2494 } // namespace content |
OLD | NEW |