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