| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 using gfx::RectToSkIRect; | 88 using gfx::RectToSkIRect; |
| 89 using gfx::SkIRectToRect; | 89 using gfx::SkIRectToRect; |
| 90 | 90 |
| 91 using WebKit::WebScreenInfo; | 91 using WebKit::WebScreenInfo; |
| 92 using WebKit::WebTouchEvent; | 92 using WebKit::WebTouchEvent; |
| 93 | 93 |
| 94 namespace content { | 94 namespace content { |
| 95 | 95 |
| 96 void ReleaseMailbox(scoped_refptr<MemoryHolder> holder, | |
| 97 unsigned sync_point, | |
| 98 bool lost_resource) {} | |
| 99 | |
| 100 class MemoryHolder : public base::RefCounted<MemoryHolder> { | |
| 101 public: | |
| 102 MemoryHolder(scoped_ptr<base::SharedMemory> shared_memory, | |
| 103 gfx::Size frame_size, | |
| 104 base::Callback<void()> callback) | |
| 105 : shared_memory_(shared_memory.Pass()), | |
| 106 frame_size_(frame_size), | |
| 107 callback_(callback) {} | |
| 108 | |
| 109 void GetMailbox(cc::TextureMailbox* mailbox, | |
| 110 scoped_ptr<cc::SingleReleaseCallback>* release_callback) { | |
| 111 *mailbox = cc::TextureMailbox(shared_memory_.get(), frame_size_); | |
| 112 *release_callback = cc::SingleReleaseCallback::Create( | |
| 113 base::Bind(ReleaseMailbox, make_scoped_refptr(this))); | |
| 114 } | |
| 115 | |
| 116 private: | |
| 117 friend class base::RefCounted<MemoryHolder>; | |
| 118 ~MemoryHolder() { callback_.Run(); } | |
| 119 | |
| 120 scoped_ptr<base::SharedMemory> shared_memory_; | |
| 121 gfx::Size frame_size_; | |
| 122 base::Callback<void()> callback_; | |
| 123 }; | |
| 124 | |
| 125 namespace { | 96 namespace { |
| 126 | 97 |
| 127 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, | 98 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, |
| 128 unsigned sync_point, bool lost_resource) { | 99 unsigned sync_point, bool lost_resource) { |
| 129 // NOTE: shared_memory will get released when we go out of scope. | 100 // NOTE: shared_memory will get released when we go out of scope. |
| 130 } | 101 } |
| 131 | 102 |
| 132 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting | 103 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting |
| 133 // the border of the view, in order to get valid movement information. However, | 104 // the border of the view, in order to get valid movement information. However, |
| 134 // forcing the cursor back to the center of the view after each mouse move | 105 // forcing the cursor back to the center of the view after each mouse move |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 last_output_surface_id_(0), | 567 last_output_surface_id_(0), |
| 597 pending_delegated_ack_count_(0), | 568 pending_delegated_ack_count_(0), |
| 598 skipped_frames_(false), | 569 skipped_frames_(false), |
| 599 last_swapped_surface_scale_factor_(1.f), | 570 last_swapped_surface_scale_factor_(1.f), |
| 600 paint_canvas_(NULL), | 571 paint_canvas_(NULL), |
| 601 synthetic_move_sent_(false), | 572 synthetic_move_sent_(false), |
| 602 accelerated_compositing_state_changed_(false), | 573 accelerated_compositing_state_changed_(false), |
| 603 can_lock_compositor_(YES), | 574 can_lock_compositor_(YES), |
| 604 cursor_visibility_state_in_renderer_(UNKNOWN), | 575 cursor_visibility_state_in_renderer_(UNKNOWN), |
| 605 paint_observer_(NULL), | 576 paint_observer_(NULL), |
| 606 touch_editing_client_(NULL) { | 577 touch_editing_client_(NULL), |
| 578 weak_ptr_factory_(this) { |
| 607 host_->SetView(this); | 579 host_->SetView(this); |
| 608 window_observer_.reset(new WindowObserver(this)); | 580 window_observer_.reset(new WindowObserver(this)); |
| 609 aura::client::SetTooltipText(window_, &tooltip_); | 581 aura::client::SetTooltipText(window_, &tooltip_); |
| 610 aura::client::SetActivationDelegate(window_, this); | 582 aura::client::SetActivationDelegate(window_, this); |
| 611 aura::client::SetActivationChangeObserver(window_, this); | 583 aura::client::SetActivationChangeObserver(window_, this); |
| 612 aura::client::SetFocusChangeObserver(window_, this); | 584 aura::client::SetFocusChangeObserver(window_, this); |
| 613 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 585 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
| 614 #if defined(OS_WIN) | 586 #if defined(OS_WIN) |
| 615 transient_observer_.reset(new TransientWindowObserver(this)); | 587 transient_observer_.reset(new TransientWindowObserver(this)); |
| 616 #endif | 588 #endif |
| 589 software_frame_manager_.reset(new SoftwareFrameManager( |
| 590 weak_ptr_factory_.GetWeakPtr())); |
| 617 } | 591 } |
| 618 | 592 |
| 619 //////////////////////////////////////////////////////////////////////////////// | 593 //////////////////////////////////////////////////////////////////////////////// |
| 620 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 594 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
| 621 | 595 |
| 622 void RenderWidgetHostViewAura::InitAsChild( | 596 void RenderWidgetHostViewAura::InitAsChild( |
| 623 gfx::NativeView parent_view) { | 597 gfx::NativeView parent_view) { |
| 624 window_->Init(ui::LAYER_TEXTURED); | 598 window_->Init(ui::LAYER_TEXTURED); |
| 625 window_->SetName("RenderWidgetHostViewAura"); | 599 window_->SetName("RenderWidgetHostViewAura"); |
| 626 } | 600 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 665 |
| 692 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 666 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
| 693 return host_; | 667 return host_; |
| 694 } | 668 } |
| 695 | 669 |
| 696 void RenderWidgetHostViewAura::WasShown() { | 670 void RenderWidgetHostViewAura::WasShown() { |
| 697 DCHECK(host_); | 671 DCHECK(host_); |
| 698 if (!host_->is_hidden()) | 672 if (!host_->is_hidden()) |
| 699 return; | 673 return; |
| 700 host_->WasShown(); | 674 host_->WasShown(); |
| 701 if (framebuffer_holder_) | 675 software_frame_manager_->SetVisibility(true); |
| 702 FrameMemoryManager::GetInstance()->SetFrameVisibility(this, true); | |
| 703 | 676 |
| 704 aura::RootWindow* root = window_->GetRootWindow(); | 677 aura::RootWindow* root = window_->GetRootWindow(); |
| 705 if (root) { | 678 if (root) { |
| 706 aura::client::CursorClient* cursor_client = | 679 aura::client::CursorClient* cursor_client = |
| 707 aura::client::GetCursorClient(root); | 680 aura::client::GetCursorClient(root); |
| 708 if (cursor_client) | 681 if (cursor_client) |
| 709 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 682 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
| 710 } | 683 } |
| 711 | 684 |
| 712 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && | 685 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && |
| 713 !released_front_lock_.get()) { | 686 !released_front_lock_.get()) { |
| 714 ui::Compositor* compositor = GetCompositor(); | 687 ui::Compositor* compositor = GetCompositor(); |
| 715 if (compositor) | 688 if (compositor) |
| 716 released_front_lock_ = compositor->GetCompositorLock(); | 689 released_front_lock_ = compositor->GetCompositorLock(); |
| 717 } | 690 } |
| 718 | 691 |
| 719 #if defined(OS_WIN) | 692 #if defined(OS_WIN) |
| 720 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 693 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
| 721 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); | 694 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); |
| 722 transient_observer_->SendPluginCutoutRects(); | 695 transient_observer_->SendPluginCutoutRects(); |
| 723 #endif | 696 #endif |
| 724 } | 697 } |
| 725 | 698 |
| 726 void RenderWidgetHostViewAura::WasHidden() { | 699 void RenderWidgetHostViewAura::WasHidden() { |
| 727 if (!host_ || host_->is_hidden()) | 700 if (!host_ || host_->is_hidden()) |
| 728 return; | 701 return; |
| 729 host_->WasHidden(); | 702 host_->WasHidden(); |
| 730 if (framebuffer_holder_) | 703 software_frame_manager_->SetVisibility(false); |
| 731 FrameMemoryManager::GetInstance()->SetFrameVisibility(this, false); | |
| 732 | |
| 733 released_front_lock_ = NULL; | 704 released_front_lock_ = NULL; |
| 734 | 705 |
| 735 #if defined(OS_WIN) | 706 #if defined(OS_WIN) |
| 736 aura::RootWindow* root_window = window_->GetRootWindow(); | 707 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 737 if (root_window) { | 708 if (root_window) { |
| 738 HWND parent = root_window->GetAcceleratedWidget(); | 709 HWND parent = root_window->GetAcceleratedWidget(); |
| 739 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 710 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
| 740 | 711 |
| 741 EnumChildWindows(parent, HideWindowsCallback, lparam); | 712 EnumChildWindows(parent, HideWindowsCallback, lparam); |
| 742 } | 713 } |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 // software mode or set the external texture if going to accelerated mode). | 1252 // software mode or set the external texture if going to accelerated mode). |
| 1282 if (accelerated_compositing_state_changed_) | 1253 if (accelerated_compositing_state_changed_) |
| 1283 accelerated_compositing_state_changed_ = false; | 1254 accelerated_compositing_state_changed_ = false; |
| 1284 | 1255 |
| 1285 bool is_compositing_active = host_->is_accelerated_compositing_active(); | 1256 bool is_compositing_active = host_->is_accelerated_compositing_active(); |
| 1286 if (is_compositing_active && current_surface_.get()) { | 1257 if (is_compositing_active && current_surface_.get()) { |
| 1287 window_->layer()->SetExternalTexture(current_surface_.get()); | 1258 window_->layer()->SetExternalTexture(current_surface_.get()); |
| 1288 current_frame_size_ = ConvertSizeToDIP( | 1259 current_frame_size_ = ConvertSizeToDIP( |
| 1289 current_surface_->device_scale_factor(), current_surface_->size()); | 1260 current_surface_->device_scale_factor(), current_surface_->size()); |
| 1290 CheckResizeLock(); | 1261 CheckResizeLock(); |
| 1291 framebuffer_holder_ = NULL; | 1262 software_frame_manager_->DiscardCurrentFrame(); |
| 1292 FrameMemoryManager::GetInstance()->RemoveFrame(this); | 1263 } else if (is_compositing_active && |
| 1293 } else if (is_compositing_active && framebuffer_holder_) { | 1264 software_frame_manager_->HasCurrentFrame()) { |
| 1294 cc::TextureMailbox mailbox; | 1265 cc::TextureMailbox mailbox; |
| 1295 scoped_ptr<cc::SingleReleaseCallback> callback; | 1266 scoped_ptr<cc::SingleReleaseCallback> callback; |
| 1296 framebuffer_holder_->GetMailbox(&mailbox, &callback); | 1267 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); |
| 1297 window_->layer()->SetTextureMailbox(mailbox, | 1268 window_->layer()->SetTextureMailbox(mailbox, |
| 1298 callback.Pass(), | 1269 callback.Pass(), |
| 1299 last_swapped_surface_scale_factor_); | 1270 last_swapped_surface_scale_factor_); |
| 1300 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, | 1271 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, |
| 1301 mailbox.shared_memory_size()); | 1272 mailbox.shared_memory_size()); |
| 1302 CheckResizeLock(); | 1273 CheckResizeLock(); |
| 1303 } else { | 1274 } else { |
| 1304 window_->layer()->SetShowPaintedContent(); | 1275 window_->layer()->SetShowPaintedContent(); |
| 1305 resize_lock_.reset(); | 1276 resize_lock_.reset(); |
| 1306 host_->WasResized(); | 1277 host_->WasResized(); |
| 1307 framebuffer_holder_ = NULL; | 1278 software_frame_manager_->DiscardCurrentFrame(); |
| 1308 FrameMemoryManager::GetInstance()->RemoveFrame(this); | |
| 1309 } | 1279 } |
| 1310 } | 1280 } |
| 1311 | 1281 |
| 1312 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | 1282 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| 1313 const gfx::Rect& surface_rect, | 1283 const gfx::Rect& surface_rect, |
| 1314 float surface_scale_factor, | 1284 float surface_scale_factor, |
| 1315 const gfx::Rect& damage_rect, | 1285 const gfx::Rect& damage_rect, |
| 1316 const std::string& mailbox_name, | 1286 const std::string& mailbox_name, |
| 1317 const BufferPresentedCallback& ack_callback) { | 1287 const BufferPresentedCallback& ack_callback) { |
| 1318 if (last_swapped_surface_size_ != surface_rect.size()) { | 1288 if (last_swapped_surface_size_ != surface_rect.size()) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 | 1403 |
| 1434 gfx::Size frame_size = root_pass->output_rect.size(); | 1404 gfx::Size frame_size = root_pass->output_rect.size(); |
| 1435 gfx::Size frame_size_in_dip = | 1405 gfx::Size frame_size_in_dip = |
| 1436 ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 1406 ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
| 1437 | 1407 |
| 1438 gfx::Rect damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect); | 1408 gfx::Rect damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect); |
| 1439 damage_rect.Intersect(gfx::Rect(frame_size)); | 1409 damage_rect.Intersect(gfx::Rect(frame_size)); |
| 1440 gfx::Rect damage_rect_in_dip = | 1410 gfx::Rect damage_rect_in_dip = |
| 1441 ConvertRectToDIP(frame_device_scale_factor, damage_rect); | 1411 ConvertRectToDIP(frame_device_scale_factor, damage_rect); |
| 1442 | 1412 |
| 1443 framebuffer_holder_ = NULL; | 1413 software_frame_manager_->DiscardCurrentFrame(); |
| 1444 FrameMemoryManager::GetInstance()->RemoveFrame(this); | |
| 1445 | 1414 |
| 1446 if (ShouldSkipFrame(frame_size_in_dip)) { | 1415 if (ShouldSkipFrame(frame_size_in_dip)) { |
| 1447 cc::CompositorFrameAck ack; | 1416 cc::CompositorFrameAck ack; |
| 1448 cc::TransferableResource::ReturnResources(frame_data->resource_list, | 1417 cc::TransferableResource::ReturnResources(frame_data->resource_list, |
| 1449 &ack.resources); | 1418 &ack.resources); |
| 1450 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | 1419 RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
| 1451 host_->GetRoutingID(), output_surface_id, | 1420 host_->GetRoutingID(), output_surface_id, |
| 1452 host_->GetProcess()->GetID(), ack); | 1421 host_->GetProcess()->GetID(), ack); |
| 1453 skipped_frames_ = true; | 1422 skipped_frames_ = true; |
| 1454 return; | 1423 return; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 const gfx::Size& frame_size = frame_data->size; | 1537 const gfx::Size& frame_size = frame_data->size; |
| 1569 const gfx::Rect& damage_rect = frame_data->damage_rect; | 1538 const gfx::Rect& damage_rect = frame_data->damage_rect; |
| 1570 gfx::Size frame_size_in_dip = | 1539 gfx::Size frame_size_in_dip = |
| 1571 ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 1540 ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
| 1572 if (ShouldSkipFrame(frame_size_in_dip)) { | 1541 if (ShouldSkipFrame(frame_size_in_dip)) { |
| 1573 ReleaseSoftwareFrame(output_surface_id, frame_data->id); | 1542 ReleaseSoftwareFrame(output_surface_id, frame_data->id); |
| 1574 SendSoftwareFrameAck(output_surface_id); | 1543 SendSoftwareFrameAck(output_surface_id); |
| 1575 return; | 1544 return; |
| 1576 } | 1545 } |
| 1577 | 1546 |
| 1578 const size_t size_in_bytes = 4 * frame_size.GetArea(); | 1547 if (!software_frame_manager_->SwapToNewFrame( |
| 1579 #ifdef OS_WIN | 1548 output_surface_id, |
| 1580 scoped_ptr<base::SharedMemory> shared_memory( | 1549 frame_data.get(), |
| 1581 new base::SharedMemory(frame_data->handle, true, | 1550 frame_device_scale_factor, |
| 1582 host_->GetProcess()->GetHandle())); | 1551 host_->GetProcess()->GetHandle())) { |
| 1583 #else | |
| 1584 scoped_ptr<base::SharedMemory> shared_memory( | |
| 1585 new base::SharedMemory(frame_data->handle, true)); | |
| 1586 #endif | |
| 1587 | |
| 1588 #ifdef OS_WIN | |
| 1589 if (!shared_memory->Map(0)) { | |
| 1590 DLOG(ERROR) << "Unable to map renderer memory."; | |
| 1591 RecordAction(UserMetricsAction("BadMessageTerminate_RWHVA1")); | |
| 1592 host_->GetProcess()->ReceivedBadMessage(); | 1552 host_->GetProcess()->ReceivedBadMessage(); |
| 1593 return; | 1553 return; |
| 1594 } | 1554 } |
| 1595 | 1555 |
| 1596 if (shared_memory->mapped_size() < size_in_bytes) { | |
| 1597 DLOG(ERROR) << "Shared memory too small for given rectangle"; | |
| 1598 RecordAction(UserMetricsAction("BadMessageTerminate_RWHVA2")); | |
| 1599 host_->GetProcess()->ReceivedBadMessage(); | |
| 1600 return; | |
| 1601 } | |
| 1602 #else | |
| 1603 if (!shared_memory->Map(size_in_bytes)) { | |
| 1604 DLOG(ERROR) << "Unable to map renderer memory."; | |
| 1605 RecordAction(UserMetricsAction("BadMessageTerminate_RWHVA1")); | |
| 1606 host_->GetProcess()->ReceivedBadMessage(); | |
| 1607 return; | |
| 1608 } | |
| 1609 #endif | |
| 1610 | |
| 1611 if (last_swapped_surface_size_ != frame_size) { | 1556 if (last_swapped_surface_size_ != frame_size) { |
| 1612 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) | 1557 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) |
| 1613 << "Expected full damage rect"; | 1558 << "Expected full damage rect"; |
| 1614 } | 1559 } |
| 1615 last_swapped_surface_size_ = frame_size; | 1560 last_swapped_surface_size_ = frame_size; |
| 1616 last_swapped_surface_scale_factor_ = frame_device_scale_factor; | 1561 last_swapped_surface_scale_factor_ = frame_device_scale_factor; |
| 1617 | 1562 |
| 1618 scoped_refptr<MemoryHolder> holder(new MemoryHolder( | |
| 1619 shared_memory.Pass(), | |
| 1620 frame_size, | |
| 1621 base::Bind(&RenderWidgetHostViewAura::ReleaseSoftwareFrame, | |
| 1622 AsWeakPtr(), | |
| 1623 output_surface_id, | |
| 1624 frame_data->id))); | |
| 1625 framebuffer_holder_.swap(holder); | |
| 1626 cc::TextureMailbox mailbox; | 1563 cc::TextureMailbox mailbox; |
| 1627 scoped_ptr<cc::SingleReleaseCallback> callback; | 1564 scoped_ptr<cc::SingleReleaseCallback> callback; |
| 1628 framebuffer_holder_->GetMailbox(&mailbox, &callback); | 1565 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); |
| 1629 DCHECK(mailbox.IsSharedMemory()); | 1566 DCHECK(mailbox.IsSharedMemory()); |
| 1630 current_frame_size_ = frame_size_in_dip; | 1567 current_frame_size_ = frame_size_in_dip; |
| 1631 | 1568 |
| 1632 released_front_lock_ = NULL; | 1569 released_front_lock_ = NULL; |
| 1633 CheckResizeLock(); | 1570 CheckResizeLock(); |
| 1634 window_->layer()->SetTextureMailbox(mailbox, | 1571 window_->layer()->SetTextureMailbox(mailbox, |
| 1635 callback.Pass(), | 1572 callback.Pass(), |
| 1636 frame_device_scale_factor); | 1573 frame_device_scale_factor); |
| 1637 window_->SchedulePaintInRect( | 1574 window_->SchedulePaintInRect( |
| 1638 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); | 1575 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); |
| 1639 | 1576 |
| 1640 ui::Compositor* compositor = GetCompositor(); | 1577 ui::Compositor* compositor = GetCompositor(); |
| 1641 if (compositor) { | 1578 if (compositor) { |
| 1642 compositor->SetLatencyInfo(latency_info); | 1579 compositor->SetLatencyInfo(latency_info); |
| 1643 AddOnCommitCallbackAndDisableLocks( | 1580 AddOnCommitCallbackAndDisableLocks( |
| 1644 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck, | 1581 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck, |
| 1645 AsWeakPtr(), | 1582 AsWeakPtr(), |
| 1646 output_surface_id)); | 1583 output_surface_id)); |
| 1647 } | 1584 } |
| 1648 if (paint_observer_) | 1585 if (paint_observer_) |
| 1649 paint_observer_->OnUpdateCompositorContent(); | 1586 paint_observer_->OnUpdateCompositorContent(); |
| 1650 DidReceiveFrameFromRenderer(); | 1587 DidReceiveFrameFromRenderer(); |
| 1651 FrameMemoryManager::GetInstance()->AddFrame(this, !host_->is_hidden()); | 1588 |
| 1589 software_frame_manager_->SwapToNewFrameComplete(!host_->is_hidden()); |
| 1652 } | 1590 } |
| 1653 | 1591 |
| 1654 void RenderWidgetHostViewAura::SendSoftwareFrameAck(uint32 output_surface_id) { | 1592 void RenderWidgetHostViewAura::SendSoftwareFrameAck(uint32 output_surface_id) { |
| 1655 unsigned software_frame_id = 0; | 1593 unsigned software_frame_id = 0; |
| 1656 if (released_software_frame_ && | 1594 if (released_software_frame_ && |
| 1657 released_software_frame_->output_surface_id == output_surface_id) { | 1595 released_software_frame_->output_surface_id == output_surface_id) { |
| 1658 software_frame_id = released_software_frame_->frame_id; | 1596 software_frame_id = released_software_frame_->frame_id; |
| 1659 released_software_frame_.reset(); | 1597 released_software_frame_.reset(); |
| 1660 } | 1598 } |
| 1661 | 1599 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1749 | 1687 |
| 1750 void RenderWidgetHostViewAura::BuffersSwapped( | 1688 void RenderWidgetHostViewAura::BuffersSwapped( |
| 1751 const gfx::Size& surface_size, | 1689 const gfx::Size& surface_size, |
| 1752 const gfx::Rect& damage_rect, | 1690 const gfx::Rect& damage_rect, |
| 1753 float surface_scale_factor, | 1691 float surface_scale_factor, |
| 1754 const std::string& mailbox_name, | 1692 const std::string& mailbox_name, |
| 1755 const ui::LatencyInfo& latency_info, | 1693 const ui::LatencyInfo& latency_info, |
| 1756 const BufferPresentedCallback& ack_callback) { | 1694 const BufferPresentedCallback& ack_callback) { |
| 1757 scoped_refptr<ui::Texture> previous_texture(current_surface_); | 1695 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
| 1758 const gfx::Rect surface_rect = gfx::Rect(surface_size); | 1696 const gfx::Rect surface_rect = gfx::Rect(surface_size); |
| 1759 framebuffer_holder_ = NULL; | 1697 software_frame_manager_->DiscardCurrentFrame(); |
| 1760 FrameMemoryManager::GetInstance()->RemoveFrame(this); | |
| 1761 | 1698 |
| 1762 if (!SwapBuffersPrepare(surface_rect, | 1699 if (!SwapBuffersPrepare(surface_rect, |
| 1763 surface_scale_factor, | 1700 surface_scale_factor, |
| 1764 damage_rect, | 1701 damage_rect, |
| 1765 mailbox_name, | 1702 mailbox_name, |
| 1766 ack_callback)) { | 1703 ack_callback)) { |
| 1767 return; | 1704 return; |
| 1768 } | 1705 } |
| 1769 | 1706 |
| 1770 SkRegion damage(RectToSkIRect(damage_rect)); | 1707 SkRegion damage(RectToSkIRect(damage_rect)); |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3063 | 3000 |
| 3064 //////////////////////////////////////////////////////////////////////////////// | 3001 //////////////////////////////////////////////////////////////////////////////// |
| 3065 // RenderWidgetHostViewAura, aura::RootWindowObserver implementation: | 3002 // RenderWidgetHostViewAura, aura::RootWindowObserver implementation: |
| 3066 | 3003 |
| 3067 void RenderWidgetHostViewAura::OnRootWindowHostMoved( | 3004 void RenderWidgetHostViewAura::OnRootWindowHostMoved( |
| 3068 const aura::RootWindow* root, | 3005 const aura::RootWindow* root, |
| 3069 const gfx::Point& new_origin) { | 3006 const gfx::Point& new_origin) { |
| 3070 UpdateScreenInfo(window_); | 3007 UpdateScreenInfo(window_); |
| 3071 } | 3008 } |
| 3072 | 3009 |
| 3073 void RenderWidgetHostViewAura::ReleaseCurrentFrame() { | 3010 //////////////////////////////////////////////////////////////////////////////// |
| 3074 if (framebuffer_holder_.get() && !current_surface_.get()) { | 3011 // RenderWidgetHostViewAura, SoftwareFrameManagerClient implementation: |
| 3075 framebuffer_holder_ = NULL; | 3012 |
| 3076 ui::Compositor* compositor = GetCompositor(); | 3013 void RenderWidgetHostViewAura::SoftwareFrameWasFreed( |
| 3077 if (compositor) { | 3014 uint32 output_surface_id, unsigned frame_id) { |
| 3078 AddOnCommitCallbackAndDisableLocks(base::Bind( | 3015 ReleaseSoftwareFrame(output_surface_id, frame_id); |
| 3079 &RenderWidgetHostViewAura::SendReclaimSoftwareFrames, AsWeakPtr())); | 3016 } |
| 3080 } | 3017 |
| 3081 UpdateExternalTexture(); | 3018 void RenderWidgetHostViewAura::ReleaseReferencesToSoftwareFrame() { |
| 3019 ui::Compositor* compositor = GetCompositor(); |
| 3020 if (compositor) { |
| 3021 AddOnCommitCallbackAndDisableLocks(base::Bind( |
| 3022 &RenderWidgetHostViewAura::SendReclaimSoftwareFrames, AsWeakPtr())); |
| 3082 } | 3023 } |
| 3024 UpdateExternalTexture(); |
| 3083 } | 3025 } |
| 3084 | 3026 |
| 3085 //////////////////////////////////////////////////////////////////////////////// | 3027 //////////////////////////////////////////////////////////////////////////////// |
| 3086 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: | 3028 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: |
| 3087 | 3029 |
| 3088 void RenderWidgetHostViewAura::OnCompositingDidCommit( | 3030 void RenderWidgetHostViewAura::OnCompositingDidCommit( |
| 3089 ui::Compositor* compositor) { | 3031 ui::Compositor* compositor) { |
| 3090 if (can_lock_compositor_ == NO_PENDING_COMMIT) { | 3032 if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
| 3091 can_lock_compositor_ = YES; | 3033 can_lock_compositor_ = YES; |
| 3092 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) | 3034 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3246 popup_child_host_view_->popup_parent_host_view_ == this); | 3188 popup_child_host_view_->popup_parent_host_view_ == this); |
| 3247 popup_child_host_view_->popup_parent_host_view_ = NULL; | 3189 popup_child_host_view_->popup_parent_host_view_ = NULL; |
| 3248 } | 3190 } |
| 3249 aura::client::SetTooltipText(window_, NULL); | 3191 aura::client::SetTooltipText(window_, NULL); |
| 3250 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); | 3192 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); |
| 3251 | 3193 |
| 3252 // This call is usually no-op since |this| object is already removed from the | 3194 // This call is usually no-op since |this| object is already removed from the |
| 3253 // Aura root window and we don't have a way to get an input method object | 3195 // Aura root window and we don't have a way to get an input method object |
| 3254 // associated with the window, but just in case. | 3196 // associated with the window, but just in case. |
| 3255 DetachFromInputMethod(); | 3197 DetachFromInputMethod(); |
| 3256 FrameMemoryManager::GetInstance()->RemoveFrame(this); | |
| 3257 // The destruction of the holder may call back into the RWHVA, so do it | |
| 3258 // early. | |
| 3259 framebuffer_holder_ = NULL; | |
| 3260 | 3198 |
| 3261 if (resource_collection_.get()) | 3199 if (resource_collection_.get()) |
| 3262 resource_collection_->SetClient(NULL); | 3200 resource_collection_->SetClient(NULL); |
| 3263 } | 3201 } |
| 3264 | 3202 |
| 3265 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 3203 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
| 3266 const gfx::Point screen_point = | 3204 const gfx::Point screen_point = |
| 3267 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 3205 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
| 3268 aura::RootWindow* root_window = window_->GetRootWindow(); | 3206 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 3269 if (!root_window) | 3207 if (!root_window) |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3465 RenderWidgetHost* widget) { | 3403 RenderWidgetHost* widget) { |
| 3466 return new RenderWidgetHostViewAura(widget); | 3404 return new RenderWidgetHostViewAura(widget); |
| 3467 } | 3405 } |
| 3468 | 3406 |
| 3469 // static | 3407 // static |
| 3470 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3408 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3471 GetScreenInfoForWindow(results, NULL); | 3409 GetScreenInfoForWindow(results, NULL); |
| 3472 } | 3410 } |
| 3473 | 3411 |
| 3474 } // namespace content | 3412 } // namespace content |
| OLD | NEW |