Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Unified Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 2863883002: Tracing for NSMenu timelines
Patch Set: big CL with more trace points Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/controls/menu/menu_runner_impl_cocoa.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_native_widget.mm
diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
index b79029c300d7f392699bb36439d9b13024ce2dd7..4f299e5d3edf8706fc66b003d32951207b998db2 100644
--- a/ui/views/cocoa/bridged_native_widget.mm
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -1063,6 +1063,15 @@ void BridgedNativeWidget::ReorderChildViews() {
[bridged_view_ sortSubviewsUsingFunction:&SubviewSorter context:&rank];
}
+void BridgedNativeWidget::PumpCompositor() {
+ // Set the "needs commit" flag in the LayerTreeHost if isn't already set.
+ compositor_->ScheduleDraw();
+ frame_swapped_ = false;
+
+ constexpr int kPumpTimeoutMS = 100;
+ WaitForFrame(kPumpTimeoutMS, [this] { return frame_swapped_; });
+}
+
////////////////////////////////////////////////////////////////////////////////
// BridgedNativeWidget, internal::InputMethodDelegate:
@@ -1158,6 +1167,8 @@ void BridgedNativeWidget::AcceleratedWidgetSwapCompleted() {
invalidate_shadow_on_frame_swap_ = false;
[window_ invalidateShadow];
}
+
+ frame_swapped_ = true;
}
////////////////////////////////////////////////////////////////////////////////
@@ -1373,20 +1384,26 @@ void BridgedNativeWidget::MaybeWaitForFrame(const gfx::Size& size_in_dip) {
if (!layer()->IsDrawn() || compositor_widget_->HasFrameOfSize(size_in_dip))
return;
- const int kPaintMsgTimeoutMS = 50;
+ constexpr int kPaintMsgTimeoutMS = 50;
+ WaitForFrame(kPaintMsgTimeoutMS, [&, this] {
+ // Since the UI thread is blocked, the size shouldn't change.
+ DCHECK(size_in_dip == GetClientAreaSize());
+ return compositor_widget_->HasFrameOfSize(size_in_dip);
+ });
+}
+
+void BridgedNativeWidget::WaitForFrame(int timeout_ms,
+ std::function<bool()> predicate) {
const base::TimeTicks start_time = base::TimeTicks::Now();
const base::TimeTicks timeout_time =
- start_time + base::TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS);
+ start_time + base::TimeDelta::FromMilliseconds(timeout_ms);
ui::WindowResizeHelperMac* resize_helper = ui::WindowResizeHelperMac::Get();
for (base::TimeTicks now = start_time; now < timeout_time;
now = base::TimeTicks::Now()) {
if (!resize_helper->WaitForSingleTaskToRun(timeout_time - now))
return; // Timeout.
-
- // Since the UI thread is blocked, the size shouldn't change.
- DCHECK(size_in_dip == GetClientAreaSize());
- if (compositor_widget_->HasFrameOfSize(size_in_dip))
+ if (predicate())
return; // Frame arrived.
}
}
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/controls/menu/menu_runner_impl_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698