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 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 #endif | 1353 #endif |
1354 | 1354 |
1355 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1355 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
1356 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1356 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
1357 int gpu_host_id) { | 1357 int gpu_host_id) { |
1358 BufferPresentedCallback ack_callback = base::Bind( | 1358 BufferPresentedCallback ack_callback = base::Bind( |
1359 &AcknowledgeBufferForGpu, | 1359 &AcknowledgeBufferForGpu, |
1360 params_in_pixel.route_id, | 1360 params_in_pixel.route_id, |
1361 gpu_host_id, | 1361 gpu_host_id, |
1362 params_in_pixel.mailbox_name); | 1362 params_in_pixel.mailbox_name); |
| 1363 // TODO(miletus) : Pass the params_in_pixel.latency_info directly into |
| 1364 // BuffersSwapped() once GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params |
| 1365 // is converted to contain std::vector<ui::LatencyInfo>. |
| 1366 std::vector<ui::LatencyInfo> latency_info; |
| 1367 latency_info.push_back(params_in_pixel.latency_info); |
1363 BuffersSwapped(params_in_pixel.size, | 1368 BuffersSwapped(params_in_pixel.size, |
1364 gfx::Rect(params_in_pixel.size), | 1369 gfx::Rect(params_in_pixel.size), |
1365 params_in_pixel.scale_factor, | 1370 params_in_pixel.scale_factor, |
1366 params_in_pixel.mailbox_name, | 1371 params_in_pixel.mailbox_name, |
1367 params_in_pixel.latency_info, | 1372 latency_info, |
1368 ack_callback); | 1373 ack_callback); |
1369 } | 1374 } |
1370 | 1375 |
1371 void RenderWidgetHostViewAura::SwapDelegatedFrame( | 1376 void RenderWidgetHostViewAura::SwapDelegatedFrame( |
1372 uint32 output_surface_id, | 1377 uint32 output_surface_id, |
1373 scoped_ptr<cc::DelegatedFrameData> frame_data, | 1378 scoped_ptr<cc::DelegatedFrameData> frame_data, |
1374 float frame_device_scale_factor, | 1379 float frame_device_scale_factor, |
1375 const ui::LatencyInfo& latency_info) { | 1380 const std::vector<ui::LatencyInfo>& latency_info) { |
1376 DCHECK_NE(0u, frame_data->render_pass_list.size()); | 1381 DCHECK_NE(0u, frame_data->render_pass_list.size()); |
1377 | 1382 |
1378 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); | 1383 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); |
1379 | 1384 |
1380 gfx::Size frame_size = root_pass->output_rect.size(); | 1385 gfx::Size frame_size = root_pass->output_rect.size(); |
1381 gfx::Size frame_size_in_dip = | 1386 gfx::Size frame_size_in_dip = |
1382 ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 1387 ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
1383 | 1388 |
1384 gfx::Rect damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect); | 1389 gfx::Rect damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect); |
1385 damage_rect.Intersect(gfx::Rect(frame_size)); | 1390 damage_rect.Intersect(gfx::Rect(frame_size)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 if (paint_observer_) | 1466 if (paint_observer_) |
1462 paint_observer_->OnUpdateCompositorContent(); | 1467 paint_observer_->OnUpdateCompositorContent(); |
1463 window_->SchedulePaintInRect(damage_rect_in_dip); | 1468 window_->SchedulePaintInRect(damage_rect_in_dip); |
1464 | 1469 |
1465 pending_delegated_ack_count_++; | 1470 pending_delegated_ack_count_++; |
1466 | 1471 |
1467 ui::Compositor* compositor = GetCompositor(); | 1472 ui::Compositor* compositor = GetCompositor(); |
1468 if (!compositor) { | 1473 if (!compositor) { |
1469 SendDelegatedFrameAck(output_surface_id); | 1474 SendDelegatedFrameAck(output_surface_id); |
1470 } else { | 1475 } else { |
1471 compositor->SetLatencyInfo(latency_info); | 1476 for (size_t i = 0; i < latency_info.size(); i++) |
| 1477 compositor->SetLatencyInfo(latency_info[i]); |
1472 AddOnCommitCallbackAndDisableLocks( | 1478 AddOnCommitCallbackAndDisableLocks( |
1473 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, | 1479 base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck, |
1474 AsWeakPtr(), | 1480 AsWeakPtr(), |
1475 output_surface_id)); | 1481 output_surface_id)); |
1476 } | 1482 } |
1477 DidReceiveFrameFromRenderer(); | 1483 DidReceiveFrameFromRenderer(); |
1478 if (frame_provider_.get()) | 1484 if (frame_provider_.get()) |
1479 delegated_frame_evictor_->SwappedFrame(!host_->is_hidden()); | 1485 delegated_frame_evictor_->SwappedFrame(!host_->is_hidden()); |
1480 // Note: the frame may have been evicted immediately. | 1486 // Note: the frame may have been evicted immediately. |
1481 } | 1487 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 void RenderWidgetHostViewAura::EvictDelegatedFrame() { | 1521 void RenderWidgetHostViewAura::EvictDelegatedFrame() { |
1516 window_->layer()->SetShowPaintedContent(); | 1522 window_->layer()->SetShowPaintedContent(); |
1517 frame_provider_ = NULL; | 1523 frame_provider_ = NULL; |
1518 delegated_frame_evictor_->DiscardedFrame(); | 1524 delegated_frame_evictor_->DiscardedFrame(); |
1519 } | 1525 } |
1520 | 1526 |
1521 void RenderWidgetHostViewAura::SwapSoftwareFrame( | 1527 void RenderWidgetHostViewAura::SwapSoftwareFrame( |
1522 uint32 output_surface_id, | 1528 uint32 output_surface_id, |
1523 scoped_ptr<cc::SoftwareFrameData> frame_data, | 1529 scoped_ptr<cc::SoftwareFrameData> frame_data, |
1524 float frame_device_scale_factor, | 1530 float frame_device_scale_factor, |
1525 const ui::LatencyInfo& latency_info) { | 1531 const std::vector<ui::LatencyInfo>& latency_info) { |
1526 const gfx::Size& frame_size = frame_data->size; | 1532 const gfx::Size& frame_size = frame_data->size; |
1527 const gfx::Rect& damage_rect = frame_data->damage_rect; | 1533 const gfx::Rect& damage_rect = frame_data->damage_rect; |
1528 gfx::Size frame_size_in_dip = | 1534 gfx::Size frame_size_in_dip = |
1529 ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 1535 ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
1530 if (ShouldSkipFrame(frame_size_in_dip)) { | 1536 if (ShouldSkipFrame(frame_size_in_dip)) { |
1531 ReleaseSoftwareFrame(output_surface_id, frame_data->id); | 1537 ReleaseSoftwareFrame(output_surface_id, frame_data->id); |
1532 SendSoftwareFrameAck(output_surface_id); | 1538 SendSoftwareFrameAck(output_surface_id); |
1533 return; | 1539 return; |
1534 } | 1540 } |
1535 | 1541 |
(...skipping 23 matching lines...) Expand all Loading... |
1559 released_front_lock_ = NULL; | 1565 released_front_lock_ = NULL; |
1560 CheckResizeLock(); | 1566 CheckResizeLock(); |
1561 window_->layer()->SetTextureMailbox(mailbox, | 1567 window_->layer()->SetTextureMailbox(mailbox, |
1562 callback.Pass(), | 1568 callback.Pass(), |
1563 frame_device_scale_factor); | 1569 frame_device_scale_factor); |
1564 window_->SchedulePaintInRect( | 1570 window_->SchedulePaintInRect( |
1565 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); | 1571 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); |
1566 | 1572 |
1567 ui::Compositor* compositor = GetCompositor(); | 1573 ui::Compositor* compositor = GetCompositor(); |
1568 if (compositor) { | 1574 if (compositor) { |
1569 compositor->SetLatencyInfo(latency_info); | 1575 for (size_t i = 0; i < latency_info.size(); i++) |
| 1576 compositor->SetLatencyInfo(latency_info[i]); |
1570 AddOnCommitCallbackAndDisableLocks( | 1577 AddOnCommitCallbackAndDisableLocks( |
1571 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck, | 1578 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck, |
1572 AsWeakPtr(), | 1579 AsWeakPtr(), |
1573 output_surface_id)); | 1580 output_surface_id)); |
1574 } | 1581 } |
1575 if (paint_observer_) | 1582 if (paint_observer_) |
1576 paint_observer_->OnUpdateCompositorContent(); | 1583 paint_observer_->OnUpdateCompositorContent(); |
1577 DidReceiveFrameFromRenderer(); | 1584 DidReceiveFrameFromRenderer(); |
1578 | 1585 |
1579 software_frame_manager_->SwapToNewFrameComplete(!host_->is_hidden()); | 1586 software_frame_manager_->SwapToNewFrameComplete(!host_->is_hidden()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 const { | 1685 const { |
1679 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); | 1686 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); |
1680 } | 1687 } |
1681 #endif | 1688 #endif |
1682 | 1689 |
1683 void RenderWidgetHostViewAura::BuffersSwapped( | 1690 void RenderWidgetHostViewAura::BuffersSwapped( |
1684 const gfx::Size& surface_size, | 1691 const gfx::Size& surface_size, |
1685 const gfx::Rect& damage_rect, | 1692 const gfx::Rect& damage_rect, |
1686 float surface_scale_factor, | 1693 float surface_scale_factor, |
1687 const std::string& mailbox_name, | 1694 const std::string& mailbox_name, |
1688 const ui::LatencyInfo& latency_info, | 1695 const std::vector<ui::LatencyInfo>& latency_info, |
1689 const BufferPresentedCallback& ack_callback) { | 1696 const BufferPresentedCallback& ack_callback) { |
1690 scoped_refptr<ui::Texture> previous_texture(current_surface_); | 1697 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
1691 const gfx::Rect surface_rect = gfx::Rect(surface_size); | 1698 const gfx::Rect surface_rect = gfx::Rect(surface_size); |
1692 software_frame_manager_->DiscardCurrentFrame(); | 1699 software_frame_manager_->DiscardCurrentFrame(); |
1693 | 1700 |
1694 if (!SwapBuffersPrepare(surface_rect, | 1701 if (!SwapBuffersPrepare(surface_rect, |
1695 surface_scale_factor, | 1702 surface_scale_factor, |
1696 damage_rect, | 1703 damage_rect, |
1697 mailbox_name, | 1704 mailbox_name, |
1698 ack_callback)) { | 1705 ack_callback)) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 damage_rect.height())); | 1745 damage_rect.height())); |
1739 | 1746 |
1740 // Damage may not have been DIP aligned, so inflate damage to compensate | 1747 // Damage may not have been DIP aligned, so inflate damage to compensate |
1741 // for any round-off error. | 1748 // for any round-off error. |
1742 rect_to_paint.Inset(-1, -1); | 1749 rect_to_paint.Inset(-1, -1); |
1743 rect_to_paint.Intersect(window_->bounds()); | 1750 rect_to_paint.Intersect(window_->bounds()); |
1744 | 1751 |
1745 if (paint_observer_) | 1752 if (paint_observer_) |
1746 paint_observer_->OnUpdateCompositorContent(); | 1753 paint_observer_->OnUpdateCompositorContent(); |
1747 window_->SchedulePaintInRect(rect_to_paint); | 1754 window_->SchedulePaintInRect(rect_to_paint); |
1748 compositor->SetLatencyInfo(latency_info); | 1755 for (size_t i = 0; i < latency_info.size(); i++) |
| 1756 compositor->SetLatencyInfo(latency_info[i]); |
1749 } | 1757 } |
1750 | 1758 |
1751 SwapBuffersCompleted(ack_callback, previous_texture); | 1759 SwapBuffersCompleted(ack_callback, previous_texture); |
1752 } | 1760 } |
1753 | 1761 |
1754 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 1762 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
1755 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1763 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
1756 int gpu_host_id) { | 1764 int gpu_host_id) { |
1757 gfx::Rect damage_rect(params_in_pixel.x, | 1765 gfx::Rect damage_rect(params_in_pixel.x, |
1758 params_in_pixel.y, | 1766 params_in_pixel.y, |
1759 params_in_pixel.width, | 1767 params_in_pixel.width, |
1760 params_in_pixel.height); | 1768 params_in_pixel.height); |
1761 BufferPresentedCallback ack_callback = | 1769 BufferPresentedCallback ack_callback = |
1762 base::Bind(&AcknowledgeBufferForGpu, | 1770 base::Bind(&AcknowledgeBufferForGpu, |
1763 params_in_pixel.route_id, | 1771 params_in_pixel.route_id, |
1764 gpu_host_id, | 1772 gpu_host_id, |
1765 params_in_pixel.mailbox_name); | 1773 params_in_pixel.mailbox_name); |
| 1774 // TODO(miletus) : Pass the params_in_pixel.latency_info directly into |
| 1775 // BuffersSwapped() once GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params |
| 1776 // is converted to contain std::vector<ui::LatencyInfo>. |
| 1777 std::vector<ui::LatencyInfo> latency_info; |
| 1778 latency_info.push_back(params_in_pixel.latency_info); |
1766 BuffersSwapped(params_in_pixel.surface_size, | 1779 BuffersSwapped(params_in_pixel.surface_size, |
1767 damage_rect, | 1780 damage_rect, |
1768 params_in_pixel.surface_scale_factor, | 1781 params_in_pixel.surface_scale_factor, |
1769 params_in_pixel.mailbox_name, | 1782 params_in_pixel.mailbox_name, |
1770 params_in_pixel.latency_info, | 1783 latency_info, |
1771 ack_callback); | 1784 ack_callback); |
1772 } | 1785 } |
1773 | 1786 |
1774 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1787 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
1775 } | 1788 } |
1776 | 1789 |
1777 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1790 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
1778 // This really tells us to release the frontbuffer. | 1791 // This really tells us to release the frontbuffer. |
1779 if (current_surface_.get()) { | 1792 if (current_surface_.get()) { |
1780 ui::Compositor* compositor = GetCompositor(); | 1793 ui::Compositor* compositor = GetCompositor(); |
(...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3491 RenderWidgetHost* widget) { | 3504 RenderWidgetHost* widget) { |
3492 return new RenderWidgetHostViewAura(widget); | 3505 return new RenderWidgetHostViewAura(widget); |
3493 } | 3506 } |
3494 | 3507 |
3495 // static | 3508 // static |
3496 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3509 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3497 GetScreenInfoForWindow(results, NULL); | 3510 GetScreenInfoForWindow(results, NULL); |
3498 } | 3511 } |
3499 | 3512 |
3500 } // namespace content | 3513 } // namespace content |
OLD | NEW |