| 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 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 | 1477 |
| 1478 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1478 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
| 1479 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1479 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
| 1480 int gpu_host_id) { | 1480 int gpu_host_id) { |
| 1481 BufferPresentedCallback ack_callback = base::Bind( | 1481 BufferPresentedCallback ack_callback = base::Bind( |
| 1482 &AcknowledgeBufferForGpu, | 1482 &AcknowledgeBufferForGpu, |
| 1483 params_in_pixel.route_id, | 1483 params_in_pixel.route_id, |
| 1484 gpu_host_id, | 1484 gpu_host_id, |
| 1485 params_in_pixel.mailbox_name); | 1485 params_in_pixel.mailbox_name); |
| 1486 BuffersSwapped(params_in_pixel.size, | 1486 BuffersSwapped(params_in_pixel.size, |
| 1487 gfx::Rect(params_in_pixel.size), |
| 1487 params_in_pixel.scale_factor, | 1488 params_in_pixel.scale_factor, |
| 1488 params_in_pixel.mailbox_name, | 1489 params_in_pixel.mailbox_name, |
| 1489 params_in_pixel.latency_info, | 1490 params_in_pixel.latency_info, |
| 1490 ack_callback); | 1491 ack_callback); |
| 1491 } | 1492 } |
| 1492 | 1493 |
| 1493 void RenderWidgetHostViewAura::SwapDelegatedFrame( | 1494 void RenderWidgetHostViewAura::SwapDelegatedFrame( |
| 1494 scoped_ptr<cc::DelegatedFrameData> frame_data, | 1495 scoped_ptr<cc::DelegatedFrameData> frame_data, |
| 1495 float frame_device_scale_factor, | 1496 float frame_device_scale_factor, |
| 1496 const ui::LatencyInfo& latency_info) { | 1497 const ui::LatencyInfo& latency_info) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 return; | 1635 return; |
| 1635 } | 1636 } |
| 1636 | 1637 |
| 1637 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1638 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1638 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); | 1639 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); |
| 1639 | 1640 |
| 1640 std::string mailbox_name( | 1641 std::string mailbox_name( |
| 1641 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), | 1642 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), |
| 1642 sizeof(frame->gl_frame_data->mailbox.name)); | 1643 sizeof(frame->gl_frame_data->mailbox.name)); |
| 1643 BuffersSwapped(frame->gl_frame_data->size, | 1644 BuffersSwapped(frame->gl_frame_data->size, |
| 1645 frame->gl_frame_data->sub_buffer_rect, |
| 1644 frame->metadata.device_scale_factor, | 1646 frame->metadata.device_scale_factor, |
| 1645 mailbox_name, | 1647 mailbox_name, |
| 1646 frame->metadata.latency_info, | 1648 frame->metadata.latency_info, |
| 1647 ack_callback); | 1649 ack_callback); |
| 1648 } | 1650 } |
| 1649 | 1651 |
| 1650 #if defined(OS_WIN) | 1652 #if defined(OS_WIN) |
| 1651 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1653 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
| 1652 gfx::NativeViewAccessible accessible_parent) { | 1654 gfx::NativeViewAccessible accessible_parent) { |
| 1653 if (GetBrowserAccessibilityManager()) { | 1655 if (GetBrowserAccessibilityManager()) { |
| 1654 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() | 1656 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
| 1655 ->set_parent_iaccessible(accessible_parent); | 1657 ->set_parent_iaccessible(accessible_parent); |
| 1656 } | 1658 } |
| 1657 } | 1659 } |
| 1658 #endif | 1660 #endif |
| 1659 | 1661 |
| 1660 void RenderWidgetHostViewAura::BuffersSwapped( | 1662 void RenderWidgetHostViewAura::BuffersSwapped( |
| 1661 const gfx::Size& size, | 1663 const gfx::Size& surface_size, |
| 1664 const gfx::Rect& damage_rect, |
| 1662 float surface_scale_factor, | 1665 float surface_scale_factor, |
| 1663 const std::string& mailbox_name, | 1666 const std::string& mailbox_name, |
| 1664 const ui::LatencyInfo& latency_info, | 1667 const ui::LatencyInfo& latency_info, |
| 1665 const BufferPresentedCallback& ack_callback) { | 1668 const BufferPresentedCallback& ack_callback) { |
| 1666 scoped_refptr<ui::Texture> texture_to_return(current_surface_); | 1669 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
| 1667 const gfx::Rect surface_rect = gfx::Rect(size); | 1670 const gfx::Rect surface_rect = gfx::Rect(surface_size); |
| 1668 if (!SwapBuffersPrepare(surface_rect, surface_scale_factor, surface_rect, | 1671 |
| 1669 mailbox_name, ack_callback)) { | 1672 if (!SwapBuffersPrepare(surface_rect, |
| 1673 surface_scale_factor, |
| 1674 damage_rect, |
| 1675 mailbox_name, |
| 1676 ack_callback)) { |
| 1670 return; | 1677 return; |
| 1671 } | 1678 } |
| 1672 | 1679 |
| 1673 previous_damage_.setRect(RectToSkIRect(surface_rect)); | |
| 1674 skipped_damage_.setEmpty(); | |
| 1675 | |
| 1676 ui::Compositor* compositor = GetCompositor(); | |
| 1677 if (compositor) { | |
| 1678 gfx::Size surface_size = ConvertSizeToDIP(surface_scale_factor, size); | |
| 1679 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | |
| 1680 compositor->SetLatencyInfo(latency_info); | |
| 1681 } | |
| 1682 | |
| 1683 if (paint_observer_) | |
| 1684 paint_observer_->OnUpdateCompositorContent(); | |
| 1685 | |
| 1686 SwapBuffersCompleted(ack_callback, texture_to_return); | |
| 1687 } | |
| 1688 | |
| 1689 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | |
| 1690 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | |
| 1691 int gpu_host_id) { | |
| 1692 scoped_refptr<ui::Texture> previous_texture(current_surface_); | |
| 1693 const gfx::Rect surface_rect = | |
| 1694 gfx::Rect(params_in_pixel.surface_size); | |
| 1695 gfx::Rect damage_rect(params_in_pixel.x, | |
| 1696 params_in_pixel.y, | |
| 1697 params_in_pixel.width, | |
| 1698 params_in_pixel.height); | |
| 1699 BufferPresentedCallback ack_callback = base::Bind( | |
| 1700 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id, | |
| 1701 params_in_pixel.mailbox_name); | |
| 1702 | |
| 1703 if (!SwapBuffersPrepare( | |
| 1704 surface_rect, params_in_pixel.surface_scale_factor, damage_rect, | |
| 1705 params_in_pixel.mailbox_name, ack_callback)) { | |
| 1706 return; | |
| 1707 } | |
| 1708 | |
| 1709 SkRegion damage(RectToSkIRect(damage_rect)); | 1680 SkRegion damage(RectToSkIRect(damage_rect)); |
| 1710 if (!skipped_damage_.isEmpty()) { | 1681 if (!skipped_damage_.isEmpty()) { |
| 1711 damage.op(skipped_damage_, SkRegion::kUnion_Op); | 1682 damage.op(skipped_damage_, SkRegion::kUnion_Op); |
| 1712 skipped_damage_.setEmpty(); | 1683 skipped_damage_.setEmpty(); |
| 1713 } | 1684 } |
| 1714 | 1685 |
| 1715 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); | 1686 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); |
| 1716 ui::Texture* current_texture = current_surface_.get(); | 1687 ui::Texture* current_texture = current_surface_.get(); |
| 1717 | 1688 |
| 1718 const gfx::Size surface_size_in_pixel = params_in_pixel.surface_size; | 1689 const gfx::Size surface_size_in_pixel = surface_size; |
| 1719 DLOG_IF(ERROR, previous_texture && | 1690 DLOG_IF(ERROR, previous_texture && |
| 1720 previous_texture->size() != current_texture->size() && | 1691 previous_texture->size() != current_texture->size() && |
| 1721 SkIRectToRect(damage.getBounds()) != surface_rect) << | 1692 SkIRectToRect(damage.getBounds()) != surface_rect) << |
| 1722 "Expected full damage rect after size change"; | 1693 "Expected full damage rect after size change"; |
| 1723 if (previous_texture && !previous_damage_.isEmpty() && | 1694 if (previous_texture && !previous_damage_.isEmpty() && |
| 1724 previous_texture->size() == current_texture->size()) { | 1695 previous_texture->size() == current_texture->size()) { |
| 1725 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1696 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1726 GLHelper* gl_helper = factory->GetGLHelper(); | 1697 GLHelper* gl_helper = factory->GetGLHelper(); |
| 1727 gl_helper->CopySubBufferDamage( | 1698 gl_helper->CopySubBufferDamage( |
| 1728 current_texture->PrepareTexture(), | 1699 current_texture->PrepareTexture(), |
| 1729 previous_texture->PrepareTexture(), | 1700 previous_texture->PrepareTexture(), |
| 1730 damage, | 1701 damage, |
| 1731 previous_damage_); | 1702 previous_damage_); |
| 1732 } | 1703 } |
| 1733 previous_damage_ = damage; | 1704 previous_damage_ = damage; |
| 1734 | 1705 |
| 1735 ui::Compositor* compositor = GetCompositor(); | 1706 ui::Compositor* compositor = GetCompositor(); |
| 1736 if (compositor) { | 1707 if (compositor) { |
| 1737 // Co-ordinates come in OpenGL co-ordinate space. | 1708 // Co-ordinates come in OpenGL co-ordinate space. |
| 1738 // We need to convert to layer space. | 1709 // We need to convert to layer space. |
| 1739 gfx::Rect rect_to_paint = ConvertRectToDIP( | 1710 gfx::Rect rect_to_paint = |
| 1740 params_in_pixel.surface_scale_factor, | 1711 ConvertRectToDIP(surface_scale_factor, |
| 1741 gfx::Rect(params_in_pixel.x, | 1712 gfx::Rect(damage_rect.x(), |
| 1742 surface_size_in_pixel.height() - params_in_pixel.y - | 1713 surface_size_in_pixel.height() - |
| 1743 params_in_pixel.height, | 1714 damage_rect.y() - damage_rect.height(), |
| 1744 params_in_pixel.width, | 1715 damage_rect.width(), |
| 1745 params_in_pixel.height)); | 1716 damage_rect.height())); |
| 1746 | 1717 |
| 1747 // Damage may not have been DIP aligned, so inflate damage to compensate | 1718 // Damage may not have been DIP aligned, so inflate damage to compensate |
| 1748 // for any round-off error. | 1719 // for any round-off error. |
| 1749 rect_to_paint.Inset(-1, -1); | 1720 rect_to_paint.Inset(-1, -1); |
| 1750 rect_to_paint.Intersect(window_->bounds()); | 1721 rect_to_paint.Intersect(window_->bounds()); |
| 1751 | 1722 |
| 1752 if (paint_observer_) | 1723 if (paint_observer_) |
| 1753 paint_observer_->OnUpdateCompositorContent(); | 1724 paint_observer_->OnUpdateCompositorContent(); |
| 1754 window_->SchedulePaintInRect(rect_to_paint); | 1725 window_->SchedulePaintInRect(rect_to_paint); |
| 1755 compositor->SetLatencyInfo(params_in_pixel.latency_info); | 1726 compositor->SetLatencyInfo(latency_info); |
| 1756 } | 1727 } |
| 1757 | 1728 |
| 1758 SwapBuffersCompleted(ack_callback, previous_texture); | 1729 SwapBuffersCompleted(ack_callback, previous_texture); |
| 1759 } | 1730 } |
| 1760 | 1731 |
| 1732 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
| 1733 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
| 1734 int gpu_host_id) { |
| 1735 gfx::Rect damage_rect(params_in_pixel.x, |
| 1736 params_in_pixel.y, |
| 1737 params_in_pixel.width, |
| 1738 params_in_pixel.height); |
| 1739 BufferPresentedCallback ack_callback = |
| 1740 base::Bind(&AcknowledgeBufferForGpu, |
| 1741 params_in_pixel.route_id, |
| 1742 gpu_host_id, |
| 1743 params_in_pixel.mailbox_name); |
| 1744 BuffersSwapped(params_in_pixel.surface_size, |
| 1745 damage_rect, |
| 1746 params_in_pixel.surface_scale_factor, |
| 1747 params_in_pixel.mailbox_name, |
| 1748 params_in_pixel.latency_info, |
| 1749 ack_callback); |
| 1750 } |
| 1751 |
| 1761 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1752 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
| 1762 } | 1753 } |
| 1763 | 1754 |
| 1764 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1755 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
| 1765 // This really tells us to release the frontbuffer. | 1756 // This really tells us to release the frontbuffer. |
| 1766 if (current_surface_) { | 1757 if (current_surface_) { |
| 1767 ui::Compositor* compositor = GetCompositor(); | 1758 ui::Compositor* compositor = GetCompositor(); |
| 1768 if (compositor) { | 1759 if (compositor) { |
| 1769 // We need to wait for a commit to clear to guarantee that all we | 1760 // We need to wait for a commit to clear to guarantee that all we |
| 1770 // will not issue any more GL referencing the previous surface. | 1761 // will not issue any more GL referencing the previous surface. |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3038 RenderWidgetHost* widget) { | 3029 RenderWidgetHost* widget) { |
| 3039 return new RenderWidgetHostViewAura(widget); | 3030 return new RenderWidgetHostViewAura(widget); |
| 3040 } | 3031 } |
| 3041 | 3032 |
| 3042 // static | 3033 // static |
| 3043 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3034 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3044 GetScreenInfoForWindow(results, NULL); | 3035 GetScreenInfoForWindow(results, NULL); |
| 3045 } | 3036 } |
| 3046 | 3037 |
| 3047 } // namespace content | 3038 } // namespace content |
| OLD | NEW |