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 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1460 |
1461 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1461 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
1462 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1462 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
1463 int gpu_host_id) { | 1463 int gpu_host_id) { |
1464 BufferPresentedCallback ack_callback = base::Bind( | 1464 BufferPresentedCallback ack_callback = base::Bind( |
1465 &AcknowledgeBufferForGpu, | 1465 &AcknowledgeBufferForGpu, |
1466 params_in_pixel.route_id, | 1466 params_in_pixel.route_id, |
1467 gpu_host_id, | 1467 gpu_host_id, |
1468 params_in_pixel.mailbox_name); | 1468 params_in_pixel.mailbox_name); |
1469 BuffersSwapped(params_in_pixel.size, | 1469 BuffersSwapped(params_in_pixel.size, |
| 1470 gfx::Rect(params_in_pixel.size), |
1470 params_in_pixel.scale_factor, | 1471 params_in_pixel.scale_factor, |
1471 params_in_pixel.mailbox_name, | 1472 params_in_pixel.mailbox_name, |
1472 params_in_pixel.latency_info, | 1473 params_in_pixel.latency_info, |
1473 ack_callback); | 1474 ack_callback); |
1474 } | 1475 } |
1475 | 1476 |
1476 void RenderWidgetHostViewAura::SwapDelegatedFrame( | 1477 void RenderWidgetHostViewAura::SwapDelegatedFrame( |
1477 scoped_ptr<cc::DelegatedFrameData> frame_data, | 1478 scoped_ptr<cc::DelegatedFrameData> frame_data, |
1478 float frame_device_scale_factor, | 1479 float frame_device_scale_factor, |
1479 const ui::LatencyInfo& latency_info) { | 1480 const ui::LatencyInfo& latency_info) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 return; | 1611 return; |
1611 } | 1612 } |
1612 | 1613 |
1613 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1614 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1614 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); | 1615 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); |
1615 | 1616 |
1616 std::string mailbox_name( | 1617 std::string mailbox_name( |
1617 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), | 1618 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), |
1618 sizeof(frame->gl_frame_data->mailbox.name)); | 1619 sizeof(frame->gl_frame_data->mailbox.name)); |
1619 BuffersSwapped(frame->gl_frame_data->size, | 1620 BuffersSwapped(frame->gl_frame_data->size, |
| 1621 frame->gl_frame_data->damage_rect, |
1620 frame->metadata.device_scale_factor, | 1622 frame->metadata.device_scale_factor, |
1621 mailbox_name, | 1623 mailbox_name, |
1622 frame->metadata.latency_info, | 1624 frame->metadata.latency_info, |
1623 ack_callback); | 1625 ack_callback); |
1624 } | 1626 } |
1625 | 1627 |
1626 #if defined(OS_WIN) | 1628 #if defined(OS_WIN) |
1627 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1629 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
1628 gfx::NativeViewAccessible accessible_parent) { | 1630 gfx::NativeViewAccessible accessible_parent) { |
1629 if (GetBrowserAccessibilityManager()) { | 1631 if (GetBrowserAccessibilityManager()) { |
1630 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() | 1632 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
1631 ->set_parent_iaccessible(accessible_parent); | 1633 ->set_parent_iaccessible(accessible_parent); |
1632 } | 1634 } |
1633 } | 1635 } |
1634 #endif | 1636 #endif |
1635 | 1637 |
1636 void RenderWidgetHostViewAura::BuffersSwapped( | 1638 void RenderWidgetHostViewAura::BuffersSwapped( |
1637 const gfx::Size& size, | 1639 const gfx::Size& surface_size, |
| 1640 const gfx::Rect& damage_rect, |
1638 float surface_scale_factor, | 1641 float surface_scale_factor, |
1639 const std::string& mailbox_name, | 1642 const std::string& mailbox_name, |
1640 const ui::LatencyInfo& latency_info, | 1643 const ui::LatencyInfo& latency_info, |
1641 const BufferPresentedCallback& ack_callback) { | 1644 const BufferPresentedCallback& ack_callback) { |
1642 scoped_refptr<ui::Texture> texture_to_return(current_surface_); | 1645 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
1643 const gfx::Rect surface_rect = gfx::Rect(size); | 1646 const gfx::Rect surface_rect = gfx::Rect(surface_size); |
1644 if (!SwapBuffersPrepare(surface_rect, surface_scale_factor, surface_rect, | 1647 |
1645 mailbox_name, ack_callback)) { | 1648 if (!SwapBuffersPrepare(surface_rect, |
| 1649 surface_scale_factor, |
| 1650 damage_rect, |
| 1651 mailbox_name, |
| 1652 ack_callback)) { |
1646 return; | 1653 return; |
1647 } | 1654 } |
1648 | 1655 |
1649 previous_damage_.setRect(RectToSkIRect(surface_rect)); | |
1650 skipped_damage_.setEmpty(); | |
1651 | |
1652 ui::Compositor* compositor = GetCompositor(); | |
1653 if (compositor) { | |
1654 gfx::Size surface_size = ConvertSizeToDIP(surface_scale_factor, size); | |
1655 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | |
1656 compositor->SetLatencyInfo(latency_info); | |
1657 } | |
1658 | |
1659 if (paint_observer_) | |
1660 paint_observer_->OnUpdateCompositorContent(); | |
1661 | |
1662 SwapBuffersCompleted(ack_callback, texture_to_return); | |
1663 } | |
1664 | |
1665 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | |
1666 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | |
1667 int gpu_host_id) { | |
1668 scoped_refptr<ui::Texture> previous_texture(current_surface_); | |
1669 const gfx::Rect surface_rect = | |
1670 gfx::Rect(params_in_pixel.surface_size); | |
1671 gfx::Rect damage_rect(params_in_pixel.x, | |
1672 params_in_pixel.y, | |
1673 params_in_pixel.width, | |
1674 params_in_pixel.height); | |
1675 BufferPresentedCallback ack_callback = base::Bind( | |
1676 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id, | |
1677 params_in_pixel.mailbox_name); | |
1678 | |
1679 if (!SwapBuffersPrepare( | |
1680 surface_rect, params_in_pixel.surface_scale_factor, damage_rect, | |
1681 params_in_pixel.mailbox_name, ack_callback)) { | |
1682 return; | |
1683 } | |
1684 | |
1685 SkRegion damage(RectToSkIRect(damage_rect)); | 1656 SkRegion damage(RectToSkIRect(damage_rect)); |
1686 if (!skipped_damage_.isEmpty()) { | 1657 if (!skipped_damage_.isEmpty()) { |
1687 damage.op(skipped_damage_, SkRegion::kUnion_Op); | 1658 damage.op(skipped_damage_, SkRegion::kUnion_Op); |
1688 skipped_damage_.setEmpty(); | 1659 skipped_damage_.setEmpty(); |
1689 } | 1660 } |
1690 | 1661 |
1691 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); | 1662 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); |
1692 ui::Texture* current_texture = current_surface_.get(); | 1663 ui::Texture* current_texture = current_surface_.get(); |
1693 | 1664 |
1694 const gfx::Size surface_size_in_pixel = params_in_pixel.surface_size; | 1665 const gfx::Size surface_size_in_pixel = surface_size; |
1695 DLOG_IF(ERROR, previous_texture && | 1666 DLOG_IF(ERROR, previous_texture && |
1696 previous_texture->size() != current_texture->size() && | 1667 previous_texture->size() != current_texture->size() && |
1697 SkIRectToRect(damage.getBounds()) != surface_rect) << | 1668 SkIRectToRect(damage.getBounds()) != surface_rect) << |
1698 "Expected full damage rect after size change"; | 1669 "Expected full damage rect after size change"; |
1699 if (previous_texture && !previous_damage_.isEmpty() && | 1670 if (previous_texture && !previous_damage_.isEmpty() && |
1700 previous_texture->size() == current_texture->size()) { | 1671 previous_texture->size() == current_texture->size()) { |
1701 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1672 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1702 GLHelper* gl_helper = factory->GetGLHelper(); | 1673 GLHelper* gl_helper = factory->GetGLHelper(); |
1703 gl_helper->CopySubBufferDamage( | 1674 gl_helper->CopySubBufferDamage( |
1704 current_texture->PrepareTexture(), | 1675 current_texture->PrepareTexture(), |
1705 previous_texture->PrepareTexture(), | 1676 previous_texture->PrepareTexture(), |
1706 damage, | 1677 damage, |
1707 previous_damage_); | 1678 previous_damage_); |
1708 } | 1679 } |
1709 previous_damage_ = damage; | 1680 previous_damage_ = damage; |
1710 | 1681 |
1711 ui::Compositor* compositor = GetCompositor(); | 1682 ui::Compositor* compositor = GetCompositor(); |
1712 if (compositor) { | 1683 if (compositor) { |
1713 // Co-ordinates come in OpenGL co-ordinate space. | 1684 // Co-ordinates come in OpenGL co-ordinate space. |
1714 // We need to convert to layer space. | 1685 // We need to convert to layer space. |
1715 gfx::Rect rect_to_paint = ConvertRectToDIP( | 1686 gfx::Rect rect_to_paint = |
1716 params_in_pixel.surface_scale_factor, | 1687 ConvertRectToDIP(surface_scale_factor, |
1717 gfx::Rect(params_in_pixel.x, | 1688 gfx::Rect(damage_rect.x(), |
1718 surface_size_in_pixel.height() - params_in_pixel.y - | 1689 surface_size_in_pixel.height() - |
1719 params_in_pixel.height, | 1690 damage_rect.y() - damage_rect.height(), |
1720 params_in_pixel.width, | 1691 damage_rect.width(), |
1721 params_in_pixel.height)); | 1692 damage_rect.height())); |
1722 | 1693 |
1723 // Damage may not have been DIP aligned, so inflate damage to compensate | 1694 // Damage may not have been DIP aligned, so inflate damage to compensate |
1724 // for any round-off error. | 1695 // for any round-off error. |
1725 rect_to_paint.Inset(-1, -1); | 1696 rect_to_paint.Inset(-1, -1); |
1726 rect_to_paint.Intersect(window_->bounds()); | 1697 rect_to_paint.Intersect(window_->bounds()); |
1727 | 1698 |
1728 if (paint_observer_) | 1699 if (paint_observer_) |
1729 paint_observer_->OnUpdateCompositorContent(); | 1700 paint_observer_->OnUpdateCompositorContent(); |
1730 window_->SchedulePaintInRect(rect_to_paint); | 1701 window_->SchedulePaintInRect(rect_to_paint); |
1731 compositor->SetLatencyInfo(params_in_pixel.latency_info); | 1702 compositor->SetLatencyInfo(latency_info); |
1732 } | 1703 } |
1733 | 1704 |
1734 SwapBuffersCompleted(ack_callback, previous_texture); | 1705 SwapBuffersCompleted(ack_callback, previous_texture); |
1735 } | 1706 } |
1736 | 1707 |
| 1708 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
| 1709 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
| 1710 int gpu_host_id) { |
| 1711 gfx::Rect damage_rect(params_in_pixel.x, |
| 1712 params_in_pixel.y, |
| 1713 params_in_pixel.width, |
| 1714 params_in_pixel.height); |
| 1715 BufferPresentedCallback ack_callback = |
| 1716 base::Bind(&AcknowledgeBufferForGpu, |
| 1717 params_in_pixel.route_id, |
| 1718 gpu_host_id, |
| 1719 params_in_pixel.mailbox_name); |
| 1720 BuffersSwapped(params_in_pixel.surface_size, |
| 1721 damage_rect, |
| 1722 params_in_pixel.surface_scale_factor, |
| 1723 params_in_pixel.mailbox_name, |
| 1724 params_in_pixel.latency_info, |
| 1725 ack_callback); |
| 1726 } |
| 1727 |
1737 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1728 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
1738 } | 1729 } |
1739 | 1730 |
1740 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1731 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
1741 // This really tells us to release the frontbuffer. | 1732 // This really tells us to release the frontbuffer. |
1742 if (current_surface_) { | 1733 if (current_surface_) { |
1743 ui::Compositor* compositor = GetCompositor(); | 1734 ui::Compositor* compositor = GetCompositor(); |
1744 if (compositor) { | 1735 if (compositor) { |
1745 // We need to wait for a commit to clear to guarantee that all we | 1736 // We need to wait for a commit to clear to guarantee that all we |
1746 // will not issue any more GL referencing the previous surface. | 1737 // will not issue any more GL referencing the previous surface. |
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3029 RenderWidgetHost* widget) { | 3020 RenderWidgetHost* widget) { |
3030 return new RenderWidgetHostViewAura(widget); | 3021 return new RenderWidgetHostViewAura(widget); |
3031 } | 3022 } |
3032 | 3023 |
3033 // static | 3024 // static |
3034 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3025 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3035 GetScreenInfoForWindow(results, NULL); | 3026 GetScreenInfoForWindow(results, NULL); |
3036 } | 3027 } |
3037 | 3028 |
3038 } // namespace content | 3029 } // namespace content |
OLD | NEW |