From 6b5bf570c8a922a5cd76c0675ed2f7f05177d380 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Sat, 15 Jun 2019 10:15:49 -0700 Subject: [PATCH] Count the number measure callback invocations Summary: Counts how many times measure callbacks have been invoked during a layout pass. This is made available via the marker and event APIs. Reviewed By: SidharthGuglani Differential Revision: D15836983 fbshipit-source-id: 3835bef94e497375821c9f2ad8209447b4f11518 --- yoga/YGMarker.h | 1 + yoga/Yoga.cpp | 11 +++++++---- yoga/event/event.h | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/yoga/YGMarker.h b/yoga/YGMarker.h index 625adc2c..d9bb1277 100644 --- a/yoga/YGMarker.h +++ b/yoga/YGMarker.h @@ -25,6 +25,7 @@ typedef struct { int maxMeasureCache; int cachedLayouts; int cachedMeasures; + int measureCallbacks; } YGMarkerLayoutData; typedef struct { diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 1fa81110..cbdb9561 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -1581,6 +1581,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions( const YGMeasureMode heightMeasureMode, const float ownerWidth, const float ownerHeight, + YGMarkerLayoutData& layoutMarkerData, void* const layoutContext) { YGAssertWithNode( node, @@ -1634,6 +1635,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions( innerHeight, heightMeasureMode, layoutContext); + layoutMarkerData.measureCallbacks += 1; #ifdef YG_ENABLE_EVENTS Event::publish( @@ -2700,6 +2702,7 @@ static void YGNodelayoutImpl( heightMeasureMode, ownerWidth, ownerHeight, + layoutMarkerData, layoutContext); return; } @@ -4101,13 +4104,13 @@ void YGNodeCalculateLayoutWithContext( #endif } +#ifdef YG_ENABLE_EVENTS + Event::publish(node, {layoutContext, &marker->data}); +#endif + // end marker here marker = nullptr; -#ifdef YG_ENABLE_EVENTS - Event::publish(node, {layoutContext}); -#endif - // We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we // aren't sure whether client's of yoga have gotten rid off this flag or not. // So logging this in YGLayout would help to find out the call sites depending diff --git a/yoga/event/event.h b/yoga/event/event.h index 5a955ea9..c461de3e 100644 --- a/yoga/event/event.h +++ b/yoga/event/event.h @@ -9,6 +9,7 @@ #include #include #include "../YGEnums.h" +#include "../YGMarker.h" struct YGConfig; struct YGNode; @@ -81,6 +82,7 @@ struct Event::TypedData { template <> struct Event::TypedData { void* layoutContext; + YGMarkerLayoutData* layoutData; }; template <>