Chromium Code Reviews| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 #endif | 85 #endif |
| 86 | 86 |
| 87 using gfx::RectToSkIRect; | 87 using gfx::RectToSkIRect; |
| 88 using gfx::SkIRectToRect; | 88 using gfx::SkIRectToRect; |
| 89 | 89 |
| 90 using WebKit::WebScreenInfo; | 90 using WebKit::WebScreenInfo; |
| 91 using WebKit::WebTouchEvent; | 91 using WebKit::WebTouchEvent; |
| 92 | 92 |
| 93 namespace content { | 93 namespace content { |
| 94 | 94 |
| 95 void ReleaseMailbox(scoped_refptr<MemoryHolder> holder, | |
| 96 unsigned sync_point, | |
| 97 bool lost_resource) {} | |
| 98 | |
| 99 class MemoryHolder : public base::RefCounted<MemoryHolder> { | |
| 100 public: | |
| 101 MemoryHolder(scoped_ptr<base::SharedMemory> shared_memory, | |
| 102 gfx::Size frame_size, | |
| 103 base::Callback<void()> callback) | |
| 104 : shared_memory_(shared_memory.Pass()), | |
| 105 frame_size_(frame_size), | |
| 106 callback_(callback) {} | |
| 107 | |
| 108 void GetMailbox(cc::TextureMailbox* mailbox, | |
| 109 scoped_ptr<cc::SingleReleaseCallback>* release_callback) { | |
| 110 *mailbox = cc::TextureMailbox(shared_memory_.get(), frame_size_); | |
| 111 *release_callback = cc::SingleReleaseCallback::Create( | |
| 112 base::Bind(ReleaseMailbox, make_scoped_refptr(this))); | |
| 113 } | |
| 114 | |
| 115 private: | |
| 116 friend class base::RefCounted<MemoryHolder>; | |
| 117 ~MemoryHolder() { callback_.Run(); } | |
| 118 | |
| 119 scoped_ptr<base::SharedMemory> shared_memory_; | |
| 120 gfx::Size frame_size_; | |
| 121 base::Callback<void()> callback_; | |
| 122 }; | |
| 123 | |
| 124 namespace { | 95 namespace { |
| 125 | 96 |
| 126 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, | 97 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, |
| 127 unsigned sync_point, bool lost_resource) { | 98 unsigned sync_point, bool lost_resource) { |
| 128 // NOTE: shared_memory will get released when we go out of scope. | 99 // NOTE: shared_memory will get released when we go out of scope. |
| 129 } | 100 } |
| 130 | 101 |
| 131 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting | 102 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting |
| 132 // the border of the view, in order to get valid movement information. However, | 103 // the border of the view, in order to get valid movement information. However, |
| 133 // forcing the cursor back to the center of the view after each mouse move | 104 // forcing the cursor back to the center of the view after each mouse move |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 window_(new aura::Window(this)), | 556 window_(new aura::Window(this)), |
| 586 in_shutdown_(false), | 557 in_shutdown_(false), |
| 587 is_fullscreen_(false), | 558 is_fullscreen_(false), |
| 588 popup_parent_host_view_(NULL), | 559 popup_parent_host_view_(NULL), |
| 589 popup_child_host_view_(NULL), | 560 popup_child_host_view_(NULL), |
| 590 is_loading_(false), | 561 is_loading_(false), |
| 591 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 562 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 592 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 563 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 593 can_compose_inline_(true), | 564 can_compose_inline_(true), |
| 594 has_composition_text_(false), | 565 has_composition_text_(false), |
| 566 software_framebuffer_(new SoftwareFramebuffer( | |
| 567 this, RenderWidgetHostImpl::From(host))), | |
| 595 last_output_surface_id_(0), | 568 last_output_surface_id_(0), |
| 596 skipped_frames_(false), | 569 skipped_frames_(false), |
| 597 last_swapped_surface_scale_factor_(1.f), | 570 last_swapped_surface_scale_factor_(1.f), |
| 598 paint_canvas_(NULL), | 571 paint_canvas_(NULL), |
| 599 synthetic_move_sent_(false), | 572 synthetic_move_sent_(false), |
| 600 accelerated_compositing_state_changed_(false), | 573 accelerated_compositing_state_changed_(false), |
| 601 can_lock_compositor_(YES), | 574 can_lock_compositor_(YES), |
| 602 cursor_visibility_state_in_renderer_(UNKNOWN), | 575 cursor_visibility_state_in_renderer_(UNKNOWN), |
| 603 paint_observer_(NULL), | 576 paint_observer_(NULL), |
| 604 touch_editing_client_(NULL) { | 577 touch_editing_client_(NULL) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 | 662 |
| 690 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 663 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
| 691 return host_; | 664 return host_; |
| 692 } | 665 } |
| 693 | 666 |
| 694 void RenderWidgetHostViewAura::WasShown() { | 667 void RenderWidgetHostViewAura::WasShown() { |
| 695 DCHECK(host_); | 668 DCHECK(host_); |
| 696 if (!host_->is_hidden()) | 669 if (!host_->is_hidden()) |
| 697 return; | 670 return; |
| 698 host_->WasShown(); | 671 host_->WasShown(); |
| 699 if (framebuffer_holder_) | 672 software_framebuffer_->WasShown(); |
| 700 FrameMemoryManager::GetInstance()->SetFrameVisibility(this, true); | |
| 701 | 673 |
| 702 aura::RootWindow* root = window_->GetRootWindow(); | 674 aura::RootWindow* root = window_->GetRootWindow(); |
| 703 if (root) { | 675 if (root) { |
| 704 aura::client::CursorClient* cursor_client = | 676 aura::client::CursorClient* cursor_client = |
| 705 aura::client::GetCursorClient(root); | 677 aura::client::GetCursorClient(root); |
| 706 if (cursor_client) | 678 if (cursor_client) |
| 707 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 679 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
| 708 } | 680 } |
| 709 | 681 |
| 710 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && | 682 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && |
| 711 !released_front_lock_.get()) { | 683 !released_front_lock_.get()) { |
| 712 ui::Compositor* compositor = GetCompositor(); | 684 ui::Compositor* compositor = GetCompositor(); |
| 713 if (compositor) | 685 if (compositor) |
| 714 released_front_lock_ = compositor->GetCompositorLock(); | 686 released_front_lock_ = compositor->GetCompositorLock(); |
| 715 } | 687 } |
| 716 | 688 |
| 717 #if defined(OS_WIN) | 689 #if defined(OS_WIN) |
| 718 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 690 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
| 719 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); | 691 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); |
| 720 transient_observer_->SendPluginCutoutRects(); | 692 transient_observer_->SendPluginCutoutRects(); |
| 721 #endif | 693 #endif |
| 722 } | 694 } |
| 723 | 695 |
| 724 void RenderWidgetHostViewAura::WasHidden() { | 696 void RenderWidgetHostViewAura::WasHidden() { |
| 725 if (!host_ || host_->is_hidden()) | 697 if (!host_ || host_->is_hidden()) |
| 726 return; | 698 return; |
| 727 host_->WasHidden(); | 699 host_->WasHidden(); |
| 728 if (framebuffer_holder_) | 700 software_framebuffer_->WasHidden(); |
| 729 FrameMemoryManager::GetInstance()->SetFrameVisibility(this, false); | |
| 730 | 701 |
| 731 released_front_lock_ = NULL; | 702 released_front_lock_ = NULL; |
| 732 | 703 |
| 733 #if defined(OS_WIN) | 704 #if defined(OS_WIN) |
| 734 aura::RootWindow* root_window = window_->GetRootWindow(); | 705 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 735 if (root_window) { | 706 if (root_window) { |
| 736 HWND parent = root_window->GetAcceleratedWidget(); | 707 HWND parent = root_window->GetAcceleratedWidget(); |
| 737 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 708 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
| 738 | 709 |
| 739 EnumChildWindows(parent, HideWindowsCallback, lparam); | 710 EnumChildWindows(parent, HideWindowsCallback, lparam); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1279 // software mode or set the external texture if going to accelerated mode). | 1250 // software mode or set the external texture if going to accelerated mode). |
| 1280 if (accelerated_compositing_state_changed_) | 1251 if (accelerated_compositing_state_changed_) |
| 1281 accelerated_compositing_state_changed_ = false; | 1252 accelerated_compositing_state_changed_ = false; |
| 1282 | 1253 |
| 1283 bool is_compositing_active = host_->is_accelerated_compositing_active(); | 1254 bool is_compositing_active = host_->is_accelerated_compositing_active(); |
| 1284 if (is_compositing_active && current_surface_.get()) { | 1255 if (is_compositing_active && current_surface_.get()) { |
| 1285 window_->layer()->SetExternalTexture(current_surface_.get()); | 1256 window_->layer()->SetExternalTexture(current_surface_.get()); |
| 1286 current_frame_size_ = ConvertSizeToDIP( | 1257 current_frame_size_ = ConvertSizeToDIP( |
| 1287 current_surface_->device_scale_factor(), current_surface_->size()); | 1258 current_surface_->device_scale_factor(), current_surface_->size()); |
| 1288 CheckResizeLock(); | 1259 CheckResizeLock(); |
| 1289 framebuffer_holder_ = NULL; | 1260 software_framebuffer_->DiscardCurrentFrame(); |
| 1290 FrameMemoryManager::GetInstance()->RemoveFrame(this); | 1261 } else if (is_compositing_active && |
| 1291 } else if (is_compositing_active && framebuffer_holder_) { | 1262 software_framebuffer_->HasCurrentFrame()) { |
| 1292 cc::TextureMailbox mailbox; | 1263 cc::TextureMailbox mailbox; |
| 1293 scoped_ptr<cc::SingleReleaseCallback> callback; | 1264 scoped_ptr<cc::SingleReleaseCallback> callback; |
| 1294 framebuffer_holder_->GetMailbox(&mailbox, &callback); | 1265 software_framebuffer_->GetCurrentFrameMailbox(&mailbox, &callback); |
| 1295 window_->layer()->SetTextureMailbox(mailbox, | 1266 window_->layer()->SetTextureMailbox(mailbox, |
| 1296 callback.Pass(), | 1267 callback.Pass(), |
| 1297 last_swapped_surface_scale_factor_); | 1268 last_swapped_surface_scale_factor_); |
| 1298 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, | 1269 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, |
| 1299 mailbox.shared_memory_size()); | 1270 mailbox.shared_memory_size()); |
| 1300 CheckResizeLock(); | 1271 CheckResizeLock(); |
| 1301 } else { | 1272 } else { |
| 1302 window_->layer()->SetShowPaintedContent(); | 1273 window_->layer()->SetShowPaintedContent(); |
| 1303 resize_lock_.reset(); | 1274 resize_lock_.reset(); |
| 1304 host_->WasResized(); | 1275 host_->WasResized(); |
| 1305 framebuffer_holder_ = NULL; | 1276 software_framebuffer_->DiscardCurrentFrame(); |
| 1306 FrameMemoryManager::GetInstance()->RemoveFrame(this); | |
| 1307 } | 1277 } |
| 1308 } | 1278 } |
| 1309 | 1279 |
| 1310 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | 1280 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| 1311 const gfx::Rect& surface_rect, | 1281 const gfx::Rect& surface_rect, |
| 1312 float surface_scale_factor, | 1282 float surface_scale_factor, |
| 1313 const gfx::Rect& damage_rect, | 1283 const gfx::Rect& damage_rect, |
| 1314 const std::string& mailbox_name, | 1284 const std::string& mailbox_name, |
| 1315 const BufferPresentedCallback& ack_callback) { | 1285 const BufferPresentedCallback& ack_callback) { |
| 1316 if (last_swapped_surface_size_ != surface_rect.size()) { | 1286 if (last_swapped_surface_size_ != surface_rect.size()) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1431 | 1401 |
| 1432 gfx::Size frame_size = root_pass->output_rect.size(); | 1402 gfx::Size frame_size = root_pass->output_rect.size(); |
| 1433 gfx::Size frame_size_in_dip = | 1403 gfx::Size frame_size_in_dip = |
| 1434 ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 1404 ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
| 1435 | 1405 |
| 1436 gfx::Rect damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect); | 1406 gfx::Rect damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect); |
| 1437 damage_rect.Intersect(gfx::Rect(frame_size)); | 1407 damage_rect.Intersect(gfx::Rect(frame_size)); |
| 1438 gfx::Rect damage_rect_in_dip = | 1408 gfx::Rect damage_rect_in_dip = |
| 1439 ConvertRectToDIP(frame_device_scale_factor, damage_rect); | 1409 ConvertRectToDIP(frame_device_scale_factor, damage_rect); |
| 1440 | 1410 |
| 1441 framebuffer_holder_ = NULL; | 1411 software_framebuffer_->DiscardCurrentFrame(); |
| 1442 FrameMemoryManager::GetInstance()->RemoveFrame(this); | |
| 1443 | 1412 |
| 1444 if (ShouldSkipFrame(frame_size_in_dip)) { | 1413 if (ShouldSkipFrame(frame_size_in_dip)) { |
| 1445 cc::CompositorFrameAck ack; | 1414 cc::CompositorFrameAck ack; |
| 1446 cc::TransferableResource::ReturnResources(frame_data->resource_list, | 1415 cc::TransferableResource::ReturnResources(frame_data->resource_list, |
| 1447 &ack.resources); | 1416 &ack.resources); |
| 1448 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | 1417 RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
| 1449 host_->GetRoutingID(), output_surface_id, | 1418 host_->GetRoutingID(), output_surface_id, |
| 1450 host_->GetProcess()->GetID(), ack); | 1419 host_->GetProcess()->GetID(), ack); |
| 1451 skipped_frames_ = true; | 1420 skipped_frames_ = true; |
| 1452 return; | 1421 return; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1512 void RenderWidgetHostViewAura::SwapSoftwareFrame( | 1481 void RenderWidgetHostViewAura::SwapSoftwareFrame( |
| 1513 uint32 output_surface_id, | 1482 uint32 output_surface_id, |
| 1514 scoped_ptr<cc::SoftwareFrameData> frame_data, | 1483 scoped_ptr<cc::SoftwareFrameData> frame_data, |
| 1515 float frame_device_scale_factor, | 1484 float frame_device_scale_factor, |
| 1516 const ui::LatencyInfo& latency_info) { | 1485 const ui::LatencyInfo& latency_info) { |
| 1517 const gfx::Size& frame_size = frame_data->size; | 1486 const gfx::Size& frame_size = frame_data->size; |
| 1518 const gfx::Rect& damage_rect = frame_data->damage_rect; | 1487 const gfx::Rect& damage_rect = frame_data->damage_rect; |
| 1519 gfx::Size frame_size_in_dip = | 1488 gfx::Size frame_size_in_dip = |
| 1520 ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 1489 ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
| 1521 if (ShouldSkipFrame(frame_size_in_dip)) { | 1490 if (ShouldSkipFrame(frame_size_in_dip)) { |
| 1522 ReleaseSoftwareFrame(output_surface_id, frame_data->id); | 1491 software_framebuffer_->ReleaseSoftwareFrame(output_surface_id, |
| 1523 SendSoftwareFrameAck(output_surface_id); | 1492 frame_data->id); |
| 1493 software_framebuffer_->SendSoftwareFrameAck(output_surface_id); | |
| 1524 return; | 1494 return; |
| 1525 } | 1495 } |
| 1526 | 1496 |
| 1527 const size_t size_in_bytes = 4 * frame_size.GetArea(); | 1497 software_framebuffer_->SwapToNewFrame( |
|
ccameron
2013/10/03 21:46:00
This is a functional change, in that we have fused
piman
2013/10/08 02:58:38
Can the eviction cause re-entrancy? Is that ok?
Ca
ccameron
2013/10/22 07:15:55
The potentialy re-entrancy seemed too iffy... chan
| |
| 1528 #ifdef OS_WIN | 1498 output_surface_id, frame_data.get(), frame_device_scale_factor); |
| 1529 scoped_ptr<base::SharedMemory> shared_memory( | |
| 1530 new base::SharedMemory(frame_data->handle, true, | |
| 1531 host_->GetProcess()->GetHandle())); | |
| 1532 #else | |
| 1533 scoped_ptr<base::SharedMemory> shared_memory( | |
| 1534 new base::SharedMemory(frame_data->handle, true)); | |
| 1535 #endif | |
| 1536 | 1499 |
| 1537 if (!shared_memory->Map(size_in_bytes)) { | 1500 // The frame may have immediately evicted if this view is not visible. |
| 1538 host_->GetProcess()->ReceivedBadMessage(); | 1501 if (!software_framebuffer_->HasCurrentFrame()) { |
| 1502 software_framebuffer_->SendSoftwareFrameAck(output_surface_id); | |
| 1539 return; | 1503 return; |
| 1540 } | 1504 } |
| 1541 | 1505 |
| 1542 if (last_swapped_surface_size_ != frame_size) { | 1506 if (last_swapped_surface_size_ != frame_size) { |
| 1543 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) | 1507 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) |
| 1544 << "Expected full damage rect"; | 1508 << "Expected full damage rect"; |
| 1545 } | 1509 } |
| 1546 last_swapped_surface_size_ = frame_size; | 1510 last_swapped_surface_size_ = frame_size; |
| 1547 last_swapped_surface_scale_factor_ = frame_device_scale_factor; | 1511 last_swapped_surface_scale_factor_ = frame_device_scale_factor; |
| 1548 | 1512 |
| 1549 scoped_refptr<MemoryHolder> holder(new MemoryHolder( | |
| 1550 shared_memory.Pass(), | |
| 1551 frame_size, | |
| 1552 base::Bind(&RenderWidgetHostViewAura::ReleaseSoftwareFrame, | |
| 1553 AsWeakPtr(), | |
| 1554 output_surface_id, | |
| 1555 frame_data->id))); | |
| 1556 framebuffer_holder_.swap(holder); | |
| 1557 cc::TextureMailbox mailbox; | 1513 cc::TextureMailbox mailbox; |
| 1558 scoped_ptr<cc::SingleReleaseCallback> callback; | 1514 scoped_ptr<cc::SingleReleaseCallback> callback; |
| 1559 framebuffer_holder_->GetMailbox(&mailbox, &callback); | 1515 software_framebuffer_->GetCurrentFrameMailbox(&mailbox, &callback); |
| 1560 DCHECK(mailbox.IsSharedMemory()); | 1516 DCHECK(mailbox.IsSharedMemory()); |
| 1561 current_frame_size_ = frame_size_in_dip; | 1517 current_frame_size_ = frame_size_in_dip; |
| 1562 | 1518 |
| 1563 released_front_lock_ = NULL; | 1519 released_front_lock_ = NULL; |
| 1564 CheckResizeLock(); | 1520 CheckResizeLock(); |
| 1565 window_->layer()->SetTextureMailbox(mailbox, | 1521 window_->layer()->SetTextureMailbox(mailbox, |
| 1566 callback.Pass(), | 1522 callback.Pass(), |
| 1567 frame_device_scale_factor); | 1523 frame_device_scale_factor); |
| 1568 window_->SchedulePaintInRect( | 1524 window_->SchedulePaintInRect( |
| 1569 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); | 1525 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); |
| 1570 | 1526 |
| 1571 ui::Compositor* compositor = GetCompositor(); | 1527 ui::Compositor* compositor = GetCompositor(); |
| 1572 if (compositor) { | 1528 if (compositor) { |
| 1573 compositor->SetLatencyInfo(latency_info); | 1529 compositor->SetLatencyInfo(latency_info); |
| 1574 AddOnCommitCallbackAndDisableLocks( | 1530 AddOnCommitCallbackAndDisableLocks( |
| 1575 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck, | 1531 base::Bind(&SoftwareFramebuffer::SendSoftwareFrameAck, |
| 1576 AsWeakPtr(), | 1532 software_framebuffer_->AsWeakPtr(), |
| 1577 output_surface_id)); | 1533 output_surface_id)); |
| 1578 } | 1534 } |
| 1579 if (paint_observer_) | 1535 if (paint_observer_) |
| 1580 paint_observer_->OnUpdateCompositorContent(); | 1536 paint_observer_->OnUpdateCompositorContent(); |
| 1581 DidReceiveFrameFromRenderer(); | 1537 DidReceiveFrameFromRenderer(); |
| 1582 FrameMemoryManager::GetInstance()->AddFrame(this, !host_->is_hidden()); | |
| 1583 } | |
| 1584 | |
| 1585 void RenderWidgetHostViewAura::SendSoftwareFrameAck(uint32 output_surface_id) { | |
| 1586 unsigned software_frame_id = 0; | |
| 1587 if (!released_software_frames_.empty()) { | |
| 1588 unsigned released_output_surface_id = | |
| 1589 released_software_frames_.back().output_surface_id; | |
| 1590 if (released_output_surface_id == output_surface_id) { | |
| 1591 software_frame_id = released_software_frames_.back().frame_id; | |
| 1592 released_software_frames_.pop_back(); | |
| 1593 } | |
| 1594 } | |
| 1595 | |
| 1596 cc::CompositorFrameAck ack; | |
| 1597 ack.last_software_frame_id = software_frame_id; | |
| 1598 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | |
| 1599 host_->GetRoutingID(), output_surface_id, | |
| 1600 host_->GetProcess()->GetID(), ack); | |
| 1601 SendReclaimSoftwareFrames(); | |
| 1602 } | |
| 1603 | |
| 1604 void RenderWidgetHostViewAura::SendReclaimSoftwareFrames() { | |
| 1605 while (!released_software_frames_.empty()) { | |
| 1606 cc::CompositorFrameAck ack; | |
| 1607 ack.last_software_frame_id = released_software_frames_.back().frame_id; | |
| 1608 RenderWidgetHostImpl::SendReclaimCompositorResources( | |
| 1609 host_->GetRoutingID(), | |
| 1610 released_software_frames_.back().output_surface_id, | |
| 1611 host_->GetProcess()->GetID(), | |
| 1612 ack); | |
| 1613 released_software_frames_.pop_back(); | |
| 1614 } | |
| 1615 } | |
| 1616 | |
| 1617 void RenderWidgetHostViewAura::ReleaseSoftwareFrame( | |
| 1618 uint32 output_surface_id, | |
| 1619 unsigned software_frame_id) { | |
| 1620 SendReclaimSoftwareFrames(); | |
| 1621 released_software_frames_.push_back( | |
| 1622 ReleasedFrameInfo(output_surface_id, software_frame_id)); | |
| 1623 } | 1538 } |
| 1624 | 1539 |
| 1625 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 1540 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
| 1626 uint32 output_surface_id, | 1541 uint32 output_surface_id, |
| 1627 scoped_ptr<cc::CompositorFrame> frame) { | 1542 scoped_ptr<cc::CompositorFrame> frame) { |
| 1628 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 1543 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
| 1629 if (frame->delegated_frame_data) { | 1544 if (frame->delegated_frame_data) { |
| 1630 SwapDelegatedFrame(output_surface_id, | 1545 SwapDelegatedFrame(output_surface_id, |
| 1631 frame->delegated_frame_data.Pass(), | 1546 frame->delegated_frame_data.Pass(), |
| 1632 frame->metadata.device_scale_factor, | 1547 frame->metadata.device_scale_factor, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1682 | 1597 |
| 1683 void RenderWidgetHostViewAura::BuffersSwapped( | 1598 void RenderWidgetHostViewAura::BuffersSwapped( |
| 1684 const gfx::Size& surface_size, | 1599 const gfx::Size& surface_size, |
| 1685 const gfx::Rect& damage_rect, | 1600 const gfx::Rect& damage_rect, |
| 1686 float surface_scale_factor, | 1601 float surface_scale_factor, |
| 1687 const std::string& mailbox_name, | 1602 const std::string& mailbox_name, |
| 1688 const ui::LatencyInfo& latency_info, | 1603 const ui::LatencyInfo& latency_info, |
| 1689 const BufferPresentedCallback& ack_callback) { | 1604 const BufferPresentedCallback& ack_callback) { |
| 1690 scoped_refptr<ui::Texture> previous_texture(current_surface_); | 1605 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
| 1691 const gfx::Rect surface_rect = gfx::Rect(surface_size); | 1606 const gfx::Rect surface_rect = gfx::Rect(surface_size); |
| 1692 framebuffer_holder_ = NULL; | 1607 software_framebuffer_->DiscardCurrentFrame(); |
| 1693 FrameMemoryManager::GetInstance()->RemoveFrame(this); | |
| 1694 | 1608 |
| 1695 if (!SwapBuffersPrepare(surface_rect, | 1609 if (!SwapBuffersPrepare(surface_rect, |
| 1696 surface_scale_factor, | 1610 surface_scale_factor, |
| 1697 damage_rect, | 1611 damage_rect, |
| 1698 mailbox_name, | 1612 mailbox_name, |
| 1699 ack_callback)) { | 1613 ack_callback)) { |
| 1700 return; | 1614 return; |
| 1701 } | 1615 } |
| 1702 | 1616 |
| 1703 SkRegion damage(RectToSkIRect(damage_rect)); | 1617 SkRegion damage(RectToSkIRect(damage_rect)); |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2987 | 2901 |
| 2988 //////////////////////////////////////////////////////////////////////////////// | 2902 //////////////////////////////////////////////////////////////////////////////// |
| 2989 // RenderWidgetHostViewAura, aura::RootWindowObserver implementation: | 2903 // RenderWidgetHostViewAura, aura::RootWindowObserver implementation: |
| 2990 | 2904 |
| 2991 void RenderWidgetHostViewAura::OnRootWindowHostMoved( | 2905 void RenderWidgetHostViewAura::OnRootWindowHostMoved( |
| 2992 const aura::RootWindow* root, | 2906 const aura::RootWindow* root, |
| 2993 const gfx::Point& new_origin) { | 2907 const gfx::Point& new_origin) { |
| 2994 UpdateScreenInfo(window_); | 2908 UpdateScreenInfo(window_); |
| 2995 } | 2909 } |
| 2996 | 2910 |
| 2997 void RenderWidgetHostViewAura::ReleaseCurrentFrame() { | 2911 //////////////////////////////////////////////////////////////////////////////// |
|
ccameron
2013/10/03 21:46:00
This is a functional change in that we now ignore
| |
| 2998 if (framebuffer_holder_.get() && !current_surface_.get()) { | 2912 // RenderWidgetHostViewAura, SoftwareFramebufferClient implementation: |
| 2999 framebuffer_holder_ = NULL; | 2913 |
| 3000 ui::Compositor* compositor = GetCompositor(); | 2914 void RenderWidgetHostViewAura::CurrentSoftwareFrameWasDiscarded() { |
| 3001 if (compositor) { | 2915 ui::Compositor* compositor = GetCompositor(); |
| 3002 AddOnCommitCallbackAndDisableLocks(base::Bind( | 2916 if (compositor) { |
| 3003 &RenderWidgetHostViewAura::SendReclaimSoftwareFrames, AsWeakPtr())); | 2917 AddOnCommitCallbackAndDisableLocks(base::Bind( |
| 3004 } | 2918 &SoftwareFramebuffer::SendReclaimSoftwareFrames, |
| 3005 UpdateExternalTexture(); | 2919 software_framebuffer_->AsWeakPtr())); |
| 3006 } | 2920 } |
| 2921 UpdateExternalTexture(); | |
| 3007 } | 2922 } |
| 3008 | 2923 |
| 3009 //////////////////////////////////////////////////////////////////////////////// | 2924 //////////////////////////////////////////////////////////////////////////////// |
| 3010 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: | 2925 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: |
| 3011 | 2926 |
| 3012 void RenderWidgetHostViewAura::OnCompositingDidCommit( | 2927 void RenderWidgetHostViewAura::OnCompositingDidCommit( |
| 3013 ui::Compositor* compositor) { | 2928 ui::Compositor* compositor) { |
| 3014 if (can_lock_compositor_ == NO_PENDING_COMMIT) { | 2929 if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
| 3015 can_lock_compositor_ = YES; | 2930 can_lock_compositor_ = YES; |
| 3016 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) | 2931 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3170 popup_child_host_view_->popup_parent_host_view_ == this); | 3085 popup_child_host_view_->popup_parent_host_view_ == this); |
| 3171 popup_child_host_view_->popup_parent_host_view_ = NULL; | 3086 popup_child_host_view_->popup_parent_host_view_ = NULL; |
| 3172 } | 3087 } |
| 3173 aura::client::SetTooltipText(window_, NULL); | 3088 aura::client::SetTooltipText(window_, NULL); |
| 3174 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); | 3089 gfx::Screen::GetScreenFor(window_)->RemoveObserver(this); |
| 3175 | 3090 |
| 3176 // This call is usually no-op since |this| object is already removed from the | 3091 // This call is usually no-op since |this| object is already removed from the |
| 3177 // Aura root window and we don't have a way to get an input method object | 3092 // Aura root window and we don't have a way to get an input method object |
| 3178 // associated with the window, but just in case. | 3093 // associated with the window, but just in case. |
| 3179 DetachFromInputMethod(); | 3094 DetachFromInputMethod(); |
| 3180 FrameMemoryManager::GetInstance()->RemoveFrame(this); | |
| 3181 // The destruction of the holder may call back into the RWHVA, so do it | |
| 3182 // early. | |
| 3183 framebuffer_holder_ = NULL; | |
|
ccameron
2013/10/03 21:46:00
The SoftwareFramebuffer destructor un-sets is back
| |
| 3184 } | 3095 } |
| 3185 | 3096 |
| 3186 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 3097 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
| 3187 const gfx::Point screen_point = | 3098 const gfx::Point screen_point = |
| 3188 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 3099 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
| 3189 aura::RootWindow* root_window = window_->GetRootWindow(); | 3100 aura::RootWindow* root_window = window_->GetRootWindow(); |
| 3190 if (!root_window) | 3101 if (!root_window) |
| 3191 return; | 3102 return; |
| 3192 | 3103 |
| 3193 gfx::Rect screen_rect = GetViewBounds(); | 3104 gfx::Rect screen_rect = GetViewBounds(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3383 RenderWidgetHost* widget) { | 3294 RenderWidgetHost* widget) { |
| 3384 return new RenderWidgetHostViewAura(widget); | 3295 return new RenderWidgetHostViewAura(widget); |
| 3385 } | 3296 } |
| 3386 | 3297 |
| 3387 // static | 3298 // static |
| 3388 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3299 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3389 GetScreenInfoForWindow(results, NULL); | 3300 GetScreenInfoForWindow(results, NULL); |
| 3390 } | 3301 } |
| 3391 | 3302 |
| 3392 } // namespace content | 3303 } // namespace content |
| OLD | NEW |