From 73224c62b5e4f8fd02438418e2fc794cf73326c3 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Fri, 28 Jun 2019 09:53:15 -0700 Subject: [PATCH] Publish two events for measure callbacks Summary: Publishing two events will allow us to replace marker functionality completely with events. This also allows us to remove measuring time spent from Yoga itself. Reviewed By: SidharthGuglani Differential Revision: D16049810 fbshipit-source-id: 98628a92ed3c94d479e9fbcd53fac90c5f524087 --- tests/EventsTest.cpp | 5 ++--- yoga/Yoga.cpp | 3 ++- yoga/event/event.h | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/EventsTest.cpp b/tests/EventsTest.cpp index b940c6b1..c34dd547 100644 --- a/tests/EventsTest.cpp +++ b/tests/EventsTest.cpp @@ -134,10 +134,9 @@ void EventTest::listen(const YGNode& node, Event::Type type, Event::Data data) { events.push_back(createArgs(node, data)); break; case Event::LayoutPassStart: - break; case Event::LayoutPassEnd: - break; - case Event::NodeMeasure: + case Event::MeasureCallbackStart: + case Event::MeasureCallbackEnd: break; } } diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 7b470f5d..0888710f 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -1642,6 +1642,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions( } else { #ifdef YG_ENABLE_EVENTS auto start = steady_clock::now(); + Event::publish(node); #endif // Measure the text under the current constraints. @@ -1661,7 +1662,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions( auto measureCallbackDuration = duration_cast>(end - start); - Event::publish( + Event::publish( node, {layoutContext, innerWidth, diff --git a/yoga/event/event.h b/yoga/event/event.h index 4179e9be..eb32b457 100644 --- a/yoga/event/event.h +++ b/yoga/event/event.h @@ -31,7 +31,8 @@ struct Event { NodeLayout, LayoutPassStart, LayoutPassEnd, - NodeMeasure, + MeasureCallbackStart, + MeasureCallbackEnd, }; class Data; using Subscriber = void(const YGNode&, Type, Data); @@ -93,7 +94,7 @@ struct Event::TypedData { }; template <> -struct Event::TypedData { +struct Event::TypedData { void* layoutContext; float width; YGMeasureMode widthMeasureMode;