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 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1609 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | 1609 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
1610 return; | 1610 return; |
1611 } | 1611 } |
1612 | 1612 |
1613 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1613 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1614 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); | 1614 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); |
1615 | 1615 |
1616 std::string mailbox_name( | 1616 std::string mailbox_name( |
1617 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), | 1617 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), |
1618 sizeof(frame->gl_frame_data->mailbox.name)); | 1618 sizeof(frame->gl_frame_data->mailbox.name)); |
1619 BuffersSwapped(frame->gl_frame_data->size, | 1619 SubBufferPosted(frame->gl_frame_data->size, |
1620 frame->metadata.device_scale_factor, | 1620 frame->metadata.device_scale_factor, |
1621 mailbox_name, | 1621 mailbox_name, |
1622 frame->metadata.latency_info, | 1622 frame->metadata.latency_info, |
1623 ack_callback); | 1623 frame->gl_frame_data->damage_rect, |
1624 ack_callback); | |
1624 } | 1625 } |
1625 | 1626 |
1626 #if defined(OS_WIN) | 1627 #if defined(OS_WIN) |
1627 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1628 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
1628 gfx::NativeViewAccessible accessible_parent) { | 1629 gfx::NativeViewAccessible accessible_parent) { |
1629 if (GetBrowserAccessibilityManager()) { | 1630 if (GetBrowserAccessibilityManager()) { |
1630 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() | 1631 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
1631 ->set_parent_iaccessible(accessible_parent); | 1632 ->set_parent_iaccessible(accessible_parent); |
1632 } | 1633 } |
1633 } | 1634 } |
1634 #endif | 1635 #endif |
1635 | 1636 |
1636 void RenderWidgetHostViewAura::BuffersSwapped( | 1637 void RenderWidgetHostViewAura::BuffersSwapped( |
no sievers
2013/06/10 18:28:59
Should we get rid of this then and make the textur
jonathan.backer
2013/06/10 19:11:13
Great suggestion. Done.
There's very little overh
| |
1637 const gfx::Size& size, | 1638 const gfx::Size& size, |
1638 float surface_scale_factor, | 1639 float surface_scale_factor, |
1639 const std::string& mailbox_name, | 1640 const std::string& mailbox_name, |
1640 const ui::LatencyInfo& latency_info, | 1641 const ui::LatencyInfo& latency_info, |
1641 const BufferPresentedCallback& ack_callback) { | 1642 const BufferPresentedCallback& ack_callback) { |
1642 scoped_refptr<ui::Texture> texture_to_return(current_surface_); | 1643 scoped_refptr<ui::Texture> texture_to_return(current_surface_); |
1643 const gfx::Rect surface_rect = gfx::Rect(size); | 1644 const gfx::Rect surface_rect = gfx::Rect(size); |
1644 if (!SwapBuffersPrepare(surface_rect, surface_scale_factor, surface_rect, | 1645 if (!SwapBuffersPrepare(surface_rect, surface_scale_factor, surface_rect, |
1645 mailbox_name, ack_callback)) { | 1646 mailbox_name, ack_callback)) { |
1646 return; | 1647 return; |
1647 } | 1648 } |
1648 | 1649 |
1649 previous_damage_.setRect(RectToSkIRect(surface_rect)); | 1650 previous_damage_.setRect(RectToSkIRect(surface_rect)); |
1650 skipped_damage_.setEmpty(); | 1651 skipped_damage_.setEmpty(); |
1651 | 1652 |
1652 ui::Compositor* compositor = GetCompositor(); | 1653 ui::Compositor* compositor = GetCompositor(); |
1653 if (compositor) { | 1654 if (compositor) { |
1654 gfx::Size surface_size = ConvertSizeToDIP(surface_scale_factor, size); | 1655 gfx::Size surface_size = ConvertSizeToDIP(surface_scale_factor, size); |
1655 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 1656 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
1656 compositor->SetLatencyInfo(latency_info); | 1657 compositor->SetLatencyInfo(latency_info); |
1657 } | 1658 } |
1658 | 1659 |
1659 if (paint_observer_) | 1660 if (paint_observer_) |
1660 paint_observer_->OnUpdateCompositorContent(); | 1661 paint_observer_->OnUpdateCompositorContent(); |
1661 | 1662 |
1662 SwapBuffersCompleted(ack_callback, texture_to_return); | 1663 SwapBuffersCompleted(ack_callback, texture_to_return); |
1663 } | 1664 } |
1664 | 1665 |
1665 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 1666 void RenderWidgetHostViewAura::SubBufferPosted( |
1666 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1667 const gfx::Size& size, |
no sievers
2013/06/10 18:28:59
nit: 'size' -> 'surface_size'
jonathan.backer
2013/06/10 19:11:13
Done.
| |
1667 int gpu_host_id) { | 1668 float surface_scale_factor, |
1669 const std::string& mailbox_name, | |
1670 const ui::LatencyInfo& latency_info, | |
1671 const gfx::Rect& damage_rect, | |
1672 const BufferPresentedCallback& ack_callback) { | |
1668 scoped_refptr<ui::Texture> previous_texture(current_surface_); | 1673 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
1669 const gfx::Rect surface_rect = | 1674 const gfx::Rect surface_rect = gfx::Rect(size); |
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 | 1675 |
1679 if (!SwapBuffersPrepare( | 1676 if (!SwapBuffersPrepare(surface_rect, |
1680 surface_rect, params_in_pixel.surface_scale_factor, damage_rect, | 1677 surface_scale_factor, |
1681 params_in_pixel.mailbox_name, ack_callback)) { | 1678 damage_rect, |
1679 mailbox_name, | |
1680 ack_callback)) { | |
1682 return; | 1681 return; |
1683 } | 1682 } |
1684 | 1683 |
1685 SkRegion damage(RectToSkIRect(damage_rect)); | 1684 SkRegion damage(RectToSkIRect(damage_rect)); |
1686 if (!skipped_damage_.isEmpty()) { | 1685 if (!skipped_damage_.isEmpty()) { |
1687 damage.op(skipped_damage_, SkRegion::kUnion_Op); | 1686 damage.op(skipped_damage_, SkRegion::kUnion_Op); |
1688 skipped_damage_.setEmpty(); | 1687 skipped_damage_.setEmpty(); |
1689 } | 1688 } |
1690 | 1689 |
1691 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); | 1690 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); |
1692 ui::Texture* current_texture = current_surface_.get(); | 1691 ui::Texture* current_texture = current_surface_.get(); |
1693 | 1692 |
1694 const gfx::Size surface_size_in_pixel = params_in_pixel.surface_size; | 1693 const gfx::Size surface_size_in_pixel = size; |
1695 DLOG_IF(ERROR, previous_texture && | 1694 DLOG_IF(ERROR, previous_texture && |
1696 previous_texture->size() != current_texture->size() && | 1695 previous_texture->size() != current_texture->size() && |
1697 SkIRectToRect(damage.getBounds()) != surface_rect) << | 1696 SkIRectToRect(damage.getBounds()) != surface_rect) << |
1698 "Expected full damage rect after size change"; | 1697 "Expected full damage rect after size change"; |
1699 if (previous_texture && !previous_damage_.isEmpty() && | 1698 if (previous_texture && !previous_damage_.isEmpty() && |
1700 previous_texture->size() == current_texture->size()) { | 1699 previous_texture->size() == current_texture->size()) { |
1701 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1700 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1702 GLHelper* gl_helper = factory->GetGLHelper(); | 1701 GLHelper* gl_helper = factory->GetGLHelper(); |
1703 gl_helper->CopySubBufferDamage( | 1702 gl_helper->CopySubBufferDamage( |
1704 current_texture->PrepareTexture(), | 1703 current_texture->PrepareTexture(), |
1705 previous_texture->PrepareTexture(), | 1704 previous_texture->PrepareTexture(), |
1706 damage, | 1705 damage, |
1707 previous_damage_); | 1706 previous_damage_); |
1708 } | 1707 } |
1709 previous_damage_ = damage; | 1708 previous_damage_ = damage; |
1710 | 1709 |
1711 ui::Compositor* compositor = GetCompositor(); | 1710 ui::Compositor* compositor = GetCompositor(); |
1712 if (compositor) { | 1711 if (compositor) { |
1713 // Co-ordinates come in OpenGL co-ordinate space. | 1712 // Co-ordinates come in OpenGL co-ordinate space. |
1714 // We need to convert to layer space. | 1713 // We need to convert to layer space. |
1715 gfx::Rect rect_to_paint = ConvertRectToDIP( | 1714 gfx::Rect rect_to_paint = |
1716 params_in_pixel.surface_scale_factor, | 1715 ConvertRectToDIP(surface_scale_factor, |
1717 gfx::Rect(params_in_pixel.x, | 1716 gfx::Rect(damage_rect.x(), |
1718 surface_size_in_pixel.height() - params_in_pixel.y - | 1717 surface_size_in_pixel.height() - |
1719 params_in_pixel.height, | 1718 damage_rect.y() - damage_rect.height(), |
1720 params_in_pixel.width, | 1719 damage_rect.width(), |
1721 params_in_pixel.height)); | 1720 damage_rect.height())); |
1722 | 1721 |
1723 // Damage may not have been DIP aligned, so inflate damage to compensate | 1722 // Damage may not have been DIP aligned, so inflate damage to compensate |
1724 // for any round-off error. | 1723 // for any round-off error. |
1725 rect_to_paint.Inset(-1, -1); | 1724 rect_to_paint.Inset(-1, -1); |
1726 rect_to_paint.Intersect(window_->bounds()); | 1725 rect_to_paint.Intersect(window_->bounds()); |
1727 | 1726 |
1728 if (paint_observer_) | 1727 if (paint_observer_) |
1729 paint_observer_->OnUpdateCompositorContent(); | 1728 paint_observer_->OnUpdateCompositorContent(); |
1730 window_->SchedulePaintInRect(rect_to_paint); | 1729 window_->SchedulePaintInRect(rect_to_paint); |
1731 compositor->SetLatencyInfo(params_in_pixel.latency_info); | 1730 compositor->SetLatencyInfo(latency_info); |
1732 } | 1731 } |
1733 | 1732 |
1734 SwapBuffersCompleted(ack_callback, previous_texture); | 1733 SwapBuffersCompleted(ack_callback, previous_texture); |
1735 } | 1734 } |
1736 | 1735 |
1736 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | |
1737 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | |
1738 int gpu_host_id) { | |
1739 gfx::Rect damage_rect(params_in_pixel.x, | |
1740 params_in_pixel.y, | |
1741 params_in_pixel.width, | |
1742 params_in_pixel.height); | |
1743 BufferPresentedCallback ack_callback = | |
1744 base::Bind(&AcknowledgeBufferForGpu, | |
1745 params_in_pixel.route_id, | |
1746 gpu_host_id, | |
1747 params_in_pixel.mailbox_name); | |
1748 SubBufferPosted(params_in_pixel.surface_size, | |
1749 params_in_pixel.surface_scale_factor, | |
1750 params_in_pixel.mailbox_name, | |
1751 params_in_pixel.latency_info, | |
1752 damage_rect, | |
1753 ack_callback); | |
1754 } | |
1755 | |
1737 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1756 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
1738 } | 1757 } |
1739 | 1758 |
1740 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1759 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
1741 // This really tells us to release the frontbuffer. | 1760 // This really tells us to release the frontbuffer. |
1742 if (current_surface_) { | 1761 if (current_surface_) { |
1743 ui::Compositor* compositor = GetCompositor(); | 1762 ui::Compositor* compositor = GetCompositor(); |
1744 if (compositor) { | 1763 if (compositor) { |
1745 // We need to wait for a commit to clear to guarantee that all we | 1764 // 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. | 1765 // 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) { | 3048 RenderWidgetHost* widget) { |
3030 return new RenderWidgetHostViewAura(widget); | 3049 return new RenderWidgetHostViewAura(widget); |
3031 } | 3050 } |
3032 | 3051 |
3033 // static | 3052 // static |
3034 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3053 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3035 GetScreenInfoForWindow(results, NULL); | 3054 GetScreenInfoForWindow(results, NULL); |
3036 } | 3055 } |
3037 | 3056 |
3038 } // namespace content | 3057 } // namespace content |
OLD | NEW |