Chromium Code Reviews| 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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1438 #endif | 1438 #endif |
| 1439 | 1439 |
| 1440 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1440 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
| 1441 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1441 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
| 1442 int gpu_host_id) { | 1442 int gpu_host_id) { |
| 1443 BufferPresentedCallback ack_callback = base::Bind( | 1443 BufferPresentedCallback ack_callback = base::Bind( |
| 1444 &AcknowledgeBufferForGpu, | 1444 &AcknowledgeBufferForGpu, |
| 1445 params_in_pixel.route_id, | 1445 params_in_pixel.route_id, |
| 1446 gpu_host_id, | 1446 gpu_host_id, |
| 1447 params_in_pixel.mailbox_name); | 1447 params_in_pixel.mailbox_name); |
| 1448 BuffersSwapped( | 1448 BuffersSwapped(params_in_pixel.size, |
| 1449 params_in_pixel.size, params_in_pixel.scale_factor, | 1449 params_in_pixel.scale_factor, |
| 1450 params_in_pixel.mailbox_name, ack_callback); | 1450 params_in_pixel.mailbox_name, |
| 1451 params_in_pixel.latency_info, | |
| 1452 ack_callback); | |
| 1451 } | 1453 } |
| 1452 | 1454 |
| 1453 void RenderWidgetHostViewAura::SwapDelegatedFrame( | 1455 void RenderWidgetHostViewAura::SwapDelegatedFrame( |
| 1454 scoped_ptr<cc::DelegatedFrameData> frame_data, | 1456 scoped_ptr<cc::DelegatedFrameData> frame_data, |
| 1455 float frame_device_scale_factor) { | 1457 float frame_device_scale_factor) { |
| 1456 gfx::Size frame_size_in_dip; | 1458 gfx::Size frame_size_in_dip; |
| 1457 if (!frame_data->render_pass_list.empty()) { | 1459 if (!frame_data->render_pass_list.empty()) { |
| 1458 frame_size_in_dip = gfx::ToFlooredSize(gfx::ScaleSize( | 1460 frame_size_in_dip = gfx::ToFlooredSize(gfx::ScaleSize( |
| 1459 frame_data->render_pass_list.back()->output_rect.size(), | 1461 frame_data->render_pass_list.back()->output_rect.size(), |
| 1460 1.f/frame_device_scale_factor)); | 1462 1.f/frame_device_scale_factor)); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1550 cc::CompositorFrameAck ack; | 1552 cc::CompositorFrameAck ack; |
| 1551 ack.last_dib_id = id; | 1553 ack.last_dib_id = id; |
| 1552 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | 1554 RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
| 1553 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack); | 1555 host_->GetRoutingID(), host_->GetProcess()->GetID(), ack); |
| 1554 } | 1556 } |
| 1555 | 1557 |
| 1556 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 1558 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
| 1557 scoped_ptr<cc::CompositorFrame> frame) { | 1559 scoped_ptr<cc::CompositorFrame> frame) { |
| 1558 if (frame->delegated_frame_data) { | 1560 if (frame->delegated_frame_data) { |
| 1559 SwapDelegatedFrame(frame->delegated_frame_data.Pass(), | 1561 SwapDelegatedFrame(frame->delegated_frame_data.Pass(), |
| 1560 frame->metadata.device_scale_factor); | 1562 frame->metadata.device_scale_factor); |
|
piman
2013/05/31 04:13:44
Can we also add it here (Übercomp)?
jbauman
2013/05/31 21:51:36
Ok, sure.
| |
| 1561 return; | 1563 return; |
| 1562 } | 1564 } |
| 1563 | 1565 |
| 1564 if (frame->software_frame_data) { | 1566 if (frame->software_frame_data) { |
| 1565 SwapSoftwareFrame(frame->software_frame_data.Pass(), | 1567 SwapSoftwareFrame(frame->software_frame_data.Pass(), |
| 1566 frame->metadata.device_scale_factor); | 1568 frame->metadata.device_scale_factor); |
|
piman
2013/05/31 04:13:44
And here (software mode)?
| |
| 1567 return; | 1569 return; |
| 1568 } | 1570 } |
| 1569 | 1571 |
| 1570 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) | 1572 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) |
| 1571 return; | 1573 return; |
| 1572 | 1574 |
| 1573 BufferPresentedCallback ack_callback = base::Bind( | 1575 BufferPresentedCallback ack_callback = base::Bind( |
| 1574 &SendCompositorFrameAck, | 1576 &SendCompositorFrameAck, |
| 1575 host_->GetRoutingID(), host_->GetProcess()->GetID(), | 1577 host_->GetRoutingID(), host_->GetProcess()->GetID(), |
| 1576 frame->gl_frame_data->mailbox, frame->gl_frame_data->size); | 1578 frame->gl_frame_data->mailbox, frame->gl_frame_data->size); |
| 1577 | 1579 |
| 1578 if (!frame->gl_frame_data->sync_point) { | 1580 if (!frame->gl_frame_data->sync_point) { |
| 1579 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; | 1581 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; |
| 1580 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1582 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| 1581 return; | 1583 return; |
| 1582 } | 1584 } |
| 1583 | 1585 |
| 1584 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1586 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1585 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); | 1587 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); |
| 1586 | 1588 |
| 1587 std::string mailbox_name( | 1589 std::string mailbox_name( |
| 1588 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), | 1590 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), |
| 1589 sizeof(frame->gl_frame_data->mailbox.name)); | 1591 sizeof(frame->gl_frame_data->mailbox.name)); |
| 1590 BuffersSwapped( | 1592 BuffersSwapped(frame->gl_frame_data->size, |
| 1591 frame->gl_frame_data->size, frame->metadata.device_scale_factor, | 1593 frame->metadata.device_scale_factor, |
| 1592 mailbox_name, ack_callback); | 1594 mailbox_name, |
| 1595 frame->metadata.latency_info, | |
| 1596 ack_callback); | |
| 1593 } | 1597 } |
| 1594 | 1598 |
| 1595 #if defined(OS_WIN) | 1599 #if defined(OS_WIN) |
| 1596 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1600 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
| 1597 gfx::NativeViewAccessible accessible_parent) { | 1601 gfx::NativeViewAccessible accessible_parent) { |
| 1598 if (GetBrowserAccessibilityManager()) { | 1602 if (GetBrowserAccessibilityManager()) { |
| 1599 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() | 1603 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
| 1600 ->set_parent_iaccessible(accessible_parent); | 1604 ->set_parent_iaccessible(accessible_parent); |
| 1601 } | 1605 } |
| 1602 } | 1606 } |
| 1603 #endif | 1607 #endif |
| 1604 | 1608 |
| 1605 void RenderWidgetHostViewAura::BuffersSwapped( | 1609 void RenderWidgetHostViewAura::BuffersSwapped( |
| 1606 const gfx::Size& size, | 1610 const gfx::Size& size, |
| 1607 float surface_scale_factor, | 1611 float surface_scale_factor, |
| 1608 const std::string& mailbox_name, | 1612 const std::string& mailbox_name, |
| 1613 const ui::LatencyInfo& latency_info, | |
| 1609 const BufferPresentedCallback& ack_callback) { | 1614 const BufferPresentedCallback& ack_callback) { |
| 1610 scoped_refptr<ui::Texture> texture_to_return(current_surface_); | 1615 scoped_refptr<ui::Texture> texture_to_return(current_surface_); |
| 1611 const gfx::Rect surface_rect = gfx::Rect(size); | 1616 const gfx::Rect surface_rect = gfx::Rect(size); |
| 1612 if (!SwapBuffersPrepare(surface_rect, surface_scale_factor, surface_rect, | 1617 if (!SwapBuffersPrepare(surface_rect, surface_scale_factor, surface_rect, |
| 1613 mailbox_name, ack_callback)) { | 1618 mailbox_name, ack_callback)) { |
| 1614 return; | 1619 return; |
| 1615 } | 1620 } |
| 1616 | 1621 |
| 1617 previous_damage_.setRect(RectToSkIRect(surface_rect)); | 1622 previous_damage_.setRect(RectToSkIRect(surface_rect)); |
| 1618 skipped_damage_.setEmpty(); | 1623 skipped_damage_.setEmpty(); |
| 1619 | 1624 |
| 1620 ui::Compositor* compositor = GetCompositor(); | 1625 ui::Compositor* compositor = GetCompositor(); |
| 1621 if (compositor) { | 1626 if (compositor) { |
| 1622 gfx::Size surface_size = ConvertSizeToDIP(surface_scale_factor, size); | 1627 gfx::Size surface_size = ConvertSizeToDIP(surface_scale_factor, size); |
| 1623 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 1628 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
| 1629 compositor->SetLatencyInfo(latency_info); | |
| 1624 } | 1630 } |
| 1625 | 1631 |
| 1626 if (paint_observer_) | 1632 if (paint_observer_) |
| 1627 paint_observer_->OnUpdateCompositorContent(); | 1633 paint_observer_->OnUpdateCompositorContent(); |
| 1628 | 1634 |
| 1629 SwapBuffersCompleted(ack_callback, texture_to_return); | 1635 SwapBuffersCompleted(ack_callback, texture_to_return); |
| 1630 } | 1636 } |
| 1631 | 1637 |
| 1632 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 1638 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
| 1633 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1639 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1688 params_in_pixel.height)); | 1694 params_in_pixel.height)); |
| 1689 | 1695 |
| 1690 // Damage may not have been DIP aligned, so inflate damage to compensate | 1696 // Damage may not have been DIP aligned, so inflate damage to compensate |
| 1691 // for any round-off error. | 1697 // for any round-off error. |
| 1692 rect_to_paint.Inset(-1, -1); | 1698 rect_to_paint.Inset(-1, -1); |
| 1693 rect_to_paint.Intersect(window_->bounds()); | 1699 rect_to_paint.Intersect(window_->bounds()); |
| 1694 | 1700 |
| 1695 if (paint_observer_) | 1701 if (paint_observer_) |
| 1696 paint_observer_->OnUpdateCompositorContent(); | 1702 paint_observer_->OnUpdateCompositorContent(); |
| 1697 window_->SchedulePaintInRect(rect_to_paint); | 1703 window_->SchedulePaintInRect(rect_to_paint); |
| 1704 compositor->SetLatencyInfo(params_in_pixel.latency_info); | |
| 1698 } | 1705 } |
| 1699 | 1706 |
| 1700 SwapBuffersCompleted(ack_callback, previous_texture); | 1707 SwapBuffersCompleted(ack_callback, previous_texture); |
| 1701 } | 1708 } |
| 1702 | 1709 |
| 1703 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1710 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
| 1704 } | 1711 } |
| 1705 | 1712 |
| 1706 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1713 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
| 1707 // This really tells us to release the frontbuffer. | 1714 // This really tells us to release the frontbuffer. |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2991 RenderWidgetHost* widget) { | 2998 RenderWidgetHost* widget) { |
| 2992 return new RenderWidgetHostViewAura(widget); | 2999 return new RenderWidgetHostViewAura(widget); |
| 2993 } | 3000 } |
| 2994 | 3001 |
| 2995 // static | 3002 // static |
| 2996 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3003 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2997 GetScreenInfoForWindow(results, NULL); | 3004 GetScreenInfoForWindow(results, NULL); |
| 2998 } | 3005 } |
| 2999 | 3006 |
| 3000 } // namespace content | 3007 } // namespace content |
| OLD | NEW |