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

Unified Diff: components/exo/wayland/clients/motion_events.cc

Issue 2480783002: exo: Connect frame callbacks with UI compositor begin frames. (Closed)
Patch Set: Created 4 years, 1 month 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 | « components/exo/surface.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/wayland/clients/motion_events.cc
diff --git a/components/exo/wayland/clients/motion_events.cc b/components/exo/wayland/clients/motion_events.cc
index a55b6cd1971a61cceac43768127d2926203620a6..99e38eba2b79c3ddac9e12daf2ca9fc85fdb2ec3 100644
--- a/components/exo/wayland/clients/motion_events.cc
+++ b/components/exo/wayland/clients/motion_events.cc
@@ -34,6 +34,7 @@ DEFAULT_DELETER(wl_shell_surface, wl_shell_surface_destroy)
DEFAULT_DELETER(wl_seat, wl_seat_destroy)
DEFAULT_DELETER(wl_pointer, wl_pointer_destroy)
DEFAULT_DELETER(wl_touch, wl_touch_destroy)
+DEFAULT_DELETER(wl_callback, wl_callback_destroy)
namespace exo {
namespace wayland {
@@ -105,6 +106,7 @@ struct MainLoopContext {
uint32_t color = 0xffffffff;
bool needs_redraw = true;
bool shutdown = false;
+ bool throttled = false;
};
void PointerEnter(void* data,
@@ -195,6 +197,12 @@ void TouchFrame(void* data, wl_touch* touch) {}
void TouchCancel(void* data, wl_touch* touch) {}
+void FrameCallback(void* data, wl_callback* callback, uint32_t time) {
+ MainLoopContext* context = static_cast<MainLoopContext*>(data);
+
+ context->throttled = false;
+}
+
} // namespace
int MotionEventsMain() {
@@ -305,6 +313,9 @@ int MotionEventsMain() {
TouchFrame, TouchCancel};
wl_touch_add_listener(touch.get(), &touch_listener, &context);
+ std::unique_ptr<wl_callback> frame_callback;
+ wl_callback_listener frame_listener = {FrameCallback};
+
do {
if (context.shutdown)
break;
@@ -312,6 +323,9 @@ int MotionEventsMain() {
if (!context.needs_redraw)
continue;
+ if (context.throttled)
+ continue;
+
BufferState* buffer =
std::find_if(std::begin(buffers), std::end(buffers),
[](const BufferState& buffer) { return !buffer.busy; });
@@ -331,6 +345,10 @@ int MotionEventsMain() {
wl_surface_attach(surface.get(), buffer->buffer.get(), 0, 0);
buffer->busy = true;
+ frame_callback.reset(wl_surface_frame(surface.get()));
+ wl_callback_add_listener(frame_callback.get(), &frame_listener, &context);
+ context.throttled = true;
+
wl_surface_commit(surface.get());
wl_display_flush(display.get());
} while (wl_display_dispatch(display.get()) != -1);
« no previous file with comments | « components/exo/surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698