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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 int renderer_host_id, | 320 int renderer_host_id, |
321 const gpu::Mailbox& received_mailbox, | 321 const gpu::Mailbox& received_mailbox, |
322 const gfx::Size& received_size, | 322 const gfx::Size& received_size, |
323 bool skip_frame, | 323 bool skip_frame, |
324 const scoped_refptr<ui::Texture>& texture_to_produce) { | 324 const scoped_refptr<ui::Texture>& texture_to_produce) { |
325 cc::CompositorFrameAck ack; | 325 cc::CompositorFrameAck ack; |
326 ack.gl_frame_data.reset(new cc::GLFrameData()); | 326 ack.gl_frame_data.reset(new cc::GLFrameData()); |
327 DCHECK(!texture_to_produce.get() || !skip_frame); | 327 DCHECK(!texture_to_produce.get() || !skip_frame); |
328 if (texture_to_produce.get()) { | 328 if (texture_to_produce.get()) { |
329 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 329 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
330 ack.gl_frame_data->mailbox = texture_to_produce->Produce(); | 330 std::string mailbox_name = texture_to_produce->Produce(); |
| 331 std::copy(mailbox_name.data(), |
| 332 mailbox_name.data() + mailbox_name.length(), |
| 333 reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name)); |
331 ack.gl_frame_data->size = texture_to_produce->size(); | 334 ack.gl_frame_data->size = texture_to_produce->size(); |
332 ack.gl_frame_data->sync_point = | 335 ack.gl_frame_data->sync_point = |
333 gl_helper ? gl_helper->InsertSyncPoint() : 0; | 336 gl_helper ? gl_helper->InsertSyncPoint() : 0; |
334 } else if (skip_frame) { | 337 } else if (skip_frame) { |
335 // Skip the frame, i.e. tell the producer to reuse the same buffer that | 338 // Skip the frame, i.e. tell the producer to reuse the same buffer that |
336 // we just received. | 339 // we just received. |
337 ack.gl_frame_data->size = received_size; | 340 ack.gl_frame_data->size = received_size; |
338 ack.gl_frame_data->mailbox = received_mailbox; | 341 ack.gl_frame_data->mailbox = received_mailbox; |
339 } | 342 } |
340 | 343 |
341 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | 344 RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
342 route_id, output_surface_id, renderer_host_id, ack); | 345 route_id, output_surface_id, renderer_host_id, ack); |
343 } | 346 } |
344 | 347 |
345 void AcknowledgeBufferForGpu( | 348 void AcknowledgeBufferForGpu( |
346 int32 route_id, | 349 int32 route_id, |
347 int gpu_host_id, | 350 int gpu_host_id, |
348 const gpu::Mailbox& received_mailbox, | 351 const std::string& received_mailbox, |
349 bool skip_frame, | 352 bool skip_frame, |
350 const scoped_refptr<ui::Texture>& texture_to_produce) { | 353 const scoped_refptr<ui::Texture>& texture_to_produce) { |
351 AcceleratedSurfaceMsg_BufferPresented_Params ack; | 354 AcceleratedSurfaceMsg_BufferPresented_Params ack; |
352 uint32 sync_point = 0; | 355 uint32 sync_point = 0; |
353 DCHECK(!texture_to_produce.get() || !skip_frame); | 356 DCHECK(!texture_to_produce.get() || !skip_frame); |
354 if (texture_to_produce.get()) { | 357 if (texture_to_produce.get()) { |
355 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 358 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
356 ack.mailbox = texture_to_produce->Produce(); | 359 ack.mailbox_name = texture_to_produce->Produce(); |
357 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0; | 360 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0; |
358 } else if (skip_frame) { | 361 } else if (skip_frame) { |
359 ack.mailbox = received_mailbox; | 362 ack.mailbox_name = received_mailbox; |
360 ack.sync_point = 0; | 363 ack.sync_point = 0; |
361 } | 364 } |
362 | 365 |
363 ack.sync_point = sync_point; | 366 ack.sync_point = sync_point; |
364 RenderWidgetHostImpl::AcknowledgeBufferPresent( | 367 RenderWidgetHostImpl::AcknowledgeBufferPresent( |
365 route_id, gpu_host_id, ack); | 368 route_id, gpu_host_id, ack); |
366 } | 369 } |
367 | 370 |
368 } // namespace | 371 } // namespace |
369 | 372 |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 resize_lock_.reset(); | 1295 resize_lock_.reset(); |
1293 host_->WasResized(); | 1296 host_->WasResized(); |
1294 software_frame_manager_->DiscardCurrentFrame(); | 1297 software_frame_manager_->DiscardCurrentFrame(); |
1295 } | 1298 } |
1296 } | 1299 } |
1297 | 1300 |
1298 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | 1301 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
1299 const gfx::Rect& surface_rect, | 1302 const gfx::Rect& surface_rect, |
1300 float surface_scale_factor, | 1303 float surface_scale_factor, |
1301 const gfx::Rect& damage_rect, | 1304 const gfx::Rect& damage_rect, |
1302 const gpu::Mailbox& mailbox, | 1305 const std::string& mailbox_name, |
1303 const BufferPresentedCallback& ack_callback) { | 1306 const BufferPresentedCallback& ack_callback) { |
1304 if (last_swapped_surface_size_ != surface_rect.size()) { | 1307 if (last_swapped_surface_size_ != surface_rect.size()) { |
1305 // The surface could have shrunk since we skipped an update, in which | 1308 // The surface could have shrunk since we skipped an update, in which |
1306 // case we can expect a full update. | 1309 // case we can expect a full update. |
1307 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; | 1310 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; |
1308 skipped_damage_.setEmpty(); | 1311 skipped_damage_.setEmpty(); |
1309 last_swapped_surface_size_ = surface_rect.size(); | 1312 last_swapped_surface_size_ = surface_rect.size(); |
1310 last_swapped_surface_scale_factor_ = surface_scale_factor; | 1313 last_swapped_surface_scale_factor_ = surface_scale_factor; |
1311 } | 1314 } |
1312 | 1315 |
1313 if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor, | 1316 if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor, |
1314 surface_rect.size())) || | 1317 surface_rect.size())) || |
1315 mailbox.IsZero()) { | 1318 mailbox_name.empty()) { |
1316 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); | 1319 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); |
1317 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1320 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
1318 return false; | 1321 return false; |
1319 } | 1322 } |
1320 | 1323 |
1321 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1324 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1322 current_surface_ = | 1325 current_surface_ = |
1323 factory->CreateTransportClient(surface_scale_factor); | 1326 factory->CreateTransportClient(surface_scale_factor); |
1324 if (!current_surface_.get()) { | 1327 if (!current_surface_.get()) { |
1325 LOG(ERROR) << "Failed to create ImageTransport texture"; | 1328 LOG(ERROR) << "Failed to create ImageTransport texture"; |
1326 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1329 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
1327 return false; | 1330 return false; |
1328 } | 1331 } |
1329 | 1332 |
1330 current_surface_->Consume(mailbox, surface_rect.size()); | 1333 current_surface_->Consume(mailbox_name, surface_rect.size()); |
1331 released_front_lock_ = NULL; | 1334 released_front_lock_ = NULL; |
1332 UpdateExternalTexture(); | 1335 UpdateExternalTexture(); |
1333 | 1336 |
1334 return true; | 1337 return true; |
1335 } | 1338 } |
1336 | 1339 |
1337 void RenderWidgetHostViewAura::SwapBuffersCompleted( | 1340 void RenderWidgetHostViewAura::SwapBuffersCompleted( |
1338 const BufferPresentedCallback& ack_callback, | 1341 const BufferPresentedCallback& ack_callback, |
1339 const scoped_refptr<ui::Texture>& texture_to_return) { | 1342 const scoped_refptr<ui::Texture>& texture_to_return) { |
1340 ui::Compositor* compositor = GetCompositor(); | 1343 ui::Compositor* compositor = GetCompositor(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 } | 1389 } |
1387 #endif | 1390 #endif |
1388 | 1391 |
1389 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1392 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
1390 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1393 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
1391 int gpu_host_id) { | 1394 int gpu_host_id) { |
1392 BufferPresentedCallback ack_callback = base::Bind( | 1395 BufferPresentedCallback ack_callback = base::Bind( |
1393 &AcknowledgeBufferForGpu, | 1396 &AcknowledgeBufferForGpu, |
1394 params_in_pixel.route_id, | 1397 params_in_pixel.route_id, |
1395 gpu_host_id, | 1398 gpu_host_id, |
1396 params_in_pixel.mailbox); | 1399 params_in_pixel.mailbox_name); |
1397 BuffersSwapped(params_in_pixel.size, | 1400 BuffersSwapped(params_in_pixel.size, |
1398 gfx::Rect(params_in_pixel.size), | 1401 gfx::Rect(params_in_pixel.size), |
1399 params_in_pixel.scale_factor, | 1402 params_in_pixel.scale_factor, |
1400 params_in_pixel.mailbox, | 1403 params_in_pixel.mailbox_name, |
1401 params_in_pixel.latency_info, | 1404 params_in_pixel.latency_info, |
1402 ack_callback); | 1405 ack_callback); |
1403 } | 1406 } |
1404 | 1407 |
1405 void RenderWidgetHostViewAura::SwapDelegatedFrame( | 1408 void RenderWidgetHostViewAura::SwapDelegatedFrame( |
1406 uint32 output_surface_id, | 1409 uint32 output_surface_id, |
1407 scoped_ptr<cc::DelegatedFrameData> frame_data, | 1410 scoped_ptr<cc::DelegatedFrameData> frame_data, |
1408 float frame_device_scale_factor, | 1411 float frame_device_scale_factor, |
1409 const std::vector<ui::LatencyInfo>& latency_info) { | 1412 const std::vector<ui::LatencyInfo>& latency_info) { |
1410 DCHECK_NE(0u, frame_data->render_pass_list.size()); | 1413 DCHECK_NE(0u, frame_data->render_pass_list.size()); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 | 1684 |
1682 if (!frame->gl_frame_data->sync_point) { | 1685 if (!frame->gl_frame_data->sync_point) { |
1683 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; | 1686 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; |
1684 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1687 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
1685 return; | 1688 return; |
1686 } | 1689 } |
1687 | 1690 |
1688 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 1691 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
1689 gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point); | 1692 gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point); |
1690 | 1693 |
| 1694 std::string mailbox_name( |
| 1695 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), |
| 1696 sizeof(frame->gl_frame_data->mailbox.name)); |
1691 BuffersSwapped(frame->gl_frame_data->size, | 1697 BuffersSwapped(frame->gl_frame_data->size, |
1692 frame->gl_frame_data->sub_buffer_rect, | 1698 frame->gl_frame_data->sub_buffer_rect, |
1693 frame->metadata.device_scale_factor, | 1699 frame->metadata.device_scale_factor, |
1694 frame->gl_frame_data->mailbox, | 1700 mailbox_name, |
1695 frame->metadata.latency_info, | 1701 frame->metadata.latency_info, |
1696 ack_callback); | 1702 ack_callback); |
1697 } | 1703 } |
1698 | 1704 |
1699 #if defined(OS_WIN) | 1705 #if defined(OS_WIN) |
1700 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1706 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
1701 gfx::NativeViewAccessible accessible_parent) { | 1707 gfx::NativeViewAccessible accessible_parent) { |
1702 if (GetBrowserAccessibilityManager()) { | 1708 if (GetBrowserAccessibilityManager()) { |
1703 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() | 1709 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
1704 ->set_parent_iaccessible(accessible_parent); | 1710 ->set_parent_iaccessible(accessible_parent); |
1705 } | 1711 } |
1706 } | 1712 } |
1707 | 1713 |
1708 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() | 1714 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
1709 const { | 1715 const { |
1710 if (legacy_render_widget_host_HWND_) { | 1716 if (legacy_render_widget_host_HWND_) { |
1711 return reinterpret_cast<gfx::NativeViewId>( | 1717 return reinterpret_cast<gfx::NativeViewId>( |
1712 legacy_render_widget_host_HWND_->hwnd()); | 1718 legacy_render_widget_host_HWND_->hwnd()); |
1713 } | 1719 } |
1714 return NULL; | 1720 return NULL; |
1715 } | 1721 } |
1716 #endif | 1722 #endif |
1717 | 1723 |
1718 void RenderWidgetHostViewAura::BuffersSwapped( | 1724 void RenderWidgetHostViewAura::BuffersSwapped( |
1719 const gfx::Size& surface_size, | 1725 const gfx::Size& surface_size, |
1720 const gfx::Rect& damage_rect, | 1726 const gfx::Rect& damage_rect, |
1721 float surface_scale_factor, | 1727 float surface_scale_factor, |
1722 const gpu::Mailbox& mailbox, | 1728 const std::string& mailbox_name, |
1723 const std::vector<ui::LatencyInfo>& latency_info, | 1729 const std::vector<ui::LatencyInfo>& latency_info, |
1724 const BufferPresentedCallback& ack_callback) { | 1730 const BufferPresentedCallback& ack_callback) { |
1725 scoped_refptr<ui::Texture> previous_texture(current_surface_); | 1731 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
1726 const gfx::Rect surface_rect = gfx::Rect(surface_size); | 1732 const gfx::Rect surface_rect = gfx::Rect(surface_size); |
1727 software_frame_manager_->DiscardCurrentFrame(); | 1733 software_frame_manager_->DiscardCurrentFrame(); |
1728 | 1734 |
1729 if (!SwapBuffersPrepare(surface_rect, | 1735 if (!SwapBuffersPrepare(surface_rect, |
1730 surface_scale_factor, | 1736 surface_scale_factor, |
1731 damage_rect, | 1737 damage_rect, |
1732 mailbox, | 1738 mailbox_name, |
1733 ack_callback)) { | 1739 ack_callback)) { |
1734 return; | 1740 return; |
1735 } | 1741 } |
1736 | 1742 |
1737 SkRegion damage(RectToSkIRect(damage_rect)); | 1743 SkRegion damage(RectToSkIRect(damage_rect)); |
1738 if (!skipped_damage_.isEmpty()) { | 1744 if (!skipped_damage_.isEmpty()) { |
1739 damage.op(skipped_damage_, SkRegion::kUnion_Op); | 1745 damage.op(skipped_damage_, SkRegion::kUnion_Op); |
1740 skipped_damage_.setEmpty(); | 1746 skipped_damage_.setEmpty(); |
1741 } | 1747 } |
1742 | 1748 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1795 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
1790 int gpu_host_id) { | 1796 int gpu_host_id) { |
1791 gfx::Rect damage_rect(params_in_pixel.x, | 1797 gfx::Rect damage_rect(params_in_pixel.x, |
1792 params_in_pixel.y, | 1798 params_in_pixel.y, |
1793 params_in_pixel.width, | 1799 params_in_pixel.width, |
1794 params_in_pixel.height); | 1800 params_in_pixel.height); |
1795 BufferPresentedCallback ack_callback = | 1801 BufferPresentedCallback ack_callback = |
1796 base::Bind(&AcknowledgeBufferForGpu, | 1802 base::Bind(&AcknowledgeBufferForGpu, |
1797 params_in_pixel.route_id, | 1803 params_in_pixel.route_id, |
1798 gpu_host_id, | 1804 gpu_host_id, |
1799 params_in_pixel.mailbox); | 1805 params_in_pixel.mailbox_name); |
1800 BuffersSwapped(params_in_pixel.surface_size, | 1806 BuffersSwapped(params_in_pixel.surface_size, |
1801 damage_rect, | 1807 damage_rect, |
1802 params_in_pixel.surface_scale_factor, | 1808 params_in_pixel.surface_scale_factor, |
1803 params_in_pixel.mailbox, | 1809 params_in_pixel.mailbox_name, |
1804 params_in_pixel.latency_info, | 1810 params_in_pixel.latency_info, |
1805 ack_callback); | 1811 ack_callback); |
1806 } | 1812 } |
1807 | 1813 |
1808 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1814 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
1809 } | 1815 } |
1810 | 1816 |
1811 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1817 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
1812 // This really tells us to release the frontbuffer. | 1818 // This really tells us to release the frontbuffer. |
1813 if (current_surface_.get()) { | 1819 if (current_surface_.get()) { |
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3602 RenderWidgetHost* widget) { | 3608 RenderWidgetHost* widget) { |
3603 return new RenderWidgetHostViewAura(widget); | 3609 return new RenderWidgetHostViewAura(widget); |
3604 } | 3610 } |
3605 | 3611 |
3606 // static | 3612 // static |
3607 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3613 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3608 GetScreenInfoForWindow(results, NULL); | 3614 GetScreenInfoForWindow(results, NULL); |
3609 } | 3615 } |
3610 | 3616 |
3611 } // namespace content | 3617 } // namespace content |
OLD | NEW |