remove YGMarker code
Summary: Removes code for now unused marker based approach Reviewed By: davidaurelio Differential Revision: D16048800 fbshipit-source-id: 228e0e906252782ee0bed543728b666d1f9cc854
This commit is contained in:
committed by
Facebook Github Bot
parent
7c891db9af
commit
5e40e4b682
@@ -15,7 +15,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/YGMarker.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
@@ -27,7 +26,7 @@ struct TypedEventTestData {};
|
||||
template <>
|
||||
struct TypedEventTestData<Event::LayoutPassEnd> {
|
||||
void* layoutContext;
|
||||
YGMarkerLayoutData layoutData;
|
||||
LayoutData layoutData;
|
||||
};
|
||||
|
||||
struct EventArgs {
|
||||
@@ -147,7 +146,7 @@ TEST_F(EventTest, layout_events_single_node) {
|
||||
ASSERT_EQ(events[3].node, root);
|
||||
ASSERT_EQ(events[3].type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
events[3].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 1);
|
||||
@@ -170,7 +169,7 @@ TEST_F(EventTest, layout_events_counts_multi_node_layout) {
|
||||
ASSERT_EQ(events[11].node, root);
|
||||
ASSERT_EQ(events[11].type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
events[11].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 3);
|
||||
@@ -191,7 +190,7 @@ TEST_F(EventTest, layout_events_counts_cache_hits_single_node_layout) {
|
||||
ASSERT_EQ(events[6].node, root);
|
||||
ASSERT_EQ(events[6].type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
events[6].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 0);
|
||||
@@ -215,7 +214,7 @@ TEST_F(EventTest, layout_events_counts_cache_hits_multi_node_layout) {
|
||||
ASSERT_EQ(lastEvent().node, root);
|
||||
ASSERT_EQ(lastEvent().type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
lastEvent().eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 3);
|
||||
@@ -240,7 +239,7 @@ TEST_F(EventTest, layout_events_has_max_measure_cache) {
|
||||
ASSERT_EQ(lastEvent().node, root);
|
||||
ASSERT_EQ(lastEvent().type, Event::LayoutPassEnd);
|
||||
|
||||
YGMarkerLayoutData layoutData =
|
||||
LayoutData layoutData =
|
||||
lastEvent().eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||
|
||||
ASSERT_EQ(layoutData.layouts, 3);
|
||||
|
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
#include <yoga/Yoga.h>
|
||||
#include <yoga/YGMarker.h>
|
||||
#include <yoga/instrumentation.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
bool operator==(const YGMarkerLayoutData&, const YGMarkerLayoutData&);
|
||||
void PrintTo(const YGMarkerLayoutData, std::ostream*);
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace marker {
|
||||
namespace test {
|
||||
|
||||
template <typename T>
|
||||
using uniquePtr = std::unique_ptr<T, std::function<void(T*)>>;
|
||||
|
||||
struct MarkerTest : public ::testing::Test {
|
||||
struct Data {
|
||||
YGMarker marker;
|
||||
YGNodeRef node;
|
||||
YGMarkerData markerData;
|
||||
};
|
||||
|
||||
struct EndData {
|
||||
Data data;
|
||||
void* cookie;
|
||||
union {
|
||||
YGMarkerLayoutData layout;
|
||||
} markerData;
|
||||
};
|
||||
|
||||
struct MarkerCookie {
|
||||
Data start;
|
||||
EndData end;
|
||||
};
|
||||
|
||||
// std::deque will keep pointers stable on reallocation, whereas std::vector
|
||||
// does not
|
||||
static std::deque<MarkerCookie> markerCookies;
|
||||
|
||||
static void* startMarker(YGMarker, YGNodeRef, YGMarkerData);
|
||||
static void endMarker(YGMarker, YGNodeRef, YGMarkerData, void*);
|
||||
uniquePtr<YGNode> makeNode();
|
||||
uniquePtr<YGNode> addChild(uniquePtr<YGNode>& owner);
|
||||
static void calculateLayout(
|
||||
uniquePtr<YGNode>& node,
|
||||
float width = YGUndefined,
|
||||
float height = YGUndefined);
|
||||
static MarkerCookie& findMarker(YGMarker);
|
||||
static MarkerCookie& findLastMarker(YGMarker);
|
||||
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
uniquePtr<YGConfig> config;
|
||||
};
|
||||
|
||||
void* MarkerTest::startMarker(
|
||||
YGMarker marker,
|
||||
YGNodeRef node,
|
||||
YGMarkerData data) {
|
||||
markerCookies.emplace_back();
|
||||
MarkerCookie* cookie = &markerCookies.back();
|
||||
cookie->start = {marker, node, data};
|
||||
return cookie;
|
||||
}
|
||||
|
||||
void MarkerTest::endMarker(
|
||||
YGMarker marker,
|
||||
YGNodeRef node,
|
||||
YGMarkerData data,
|
||||
void* id) {
|
||||
auto cookie = static_cast<MarkerCookie*>(id);
|
||||
cookie->end = {{marker, node, data}, id, {}};
|
||||
}
|
||||
|
||||
uniquePtr<YGNode> MarkerTest::makeNode() {
|
||||
auto n = uniquePtr<YGNode>{YGNodeNewWithConfig(config.get()), &YGNodeFree};
|
||||
return n;
|
||||
}
|
||||
|
||||
uniquePtr<YGNode> MarkerTest::addChild(uniquePtr<YGNode>& owner) {
|
||||
auto n = makeNode();
|
||||
YGNodeInsertChild(owner.get(), n.get(), YGNodeGetChildCount(owner.get()));
|
||||
return n;
|
||||
}
|
||||
|
||||
void MarkerTest::calculateLayout(
|
||||
uniquePtr<YGNode>& node,
|
||||
float width,
|
||||
float height) {
|
||||
YGNodeCalculateLayout(node.get(), width, height, YGDirectionLTR);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
const char* markerTypeName(YGMarker type) {
|
||||
return "";
|
||||
}
|
||||
|
||||
template <typename It>
|
||||
MarkerTest::MarkerCookie& find(It begin, It end, YGMarker type) {
|
||||
auto result = std::find_if(begin, end, [type](MarkerTest::MarkerCookie& c) {
|
||||
return c.start.marker == type;
|
||||
});
|
||||
if (result == end) {
|
||||
throw std::runtime_error{std::string{"No marker recorded for type: "} +
|
||||
markerTypeName(type)};
|
||||
}
|
||||
return *result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MarkerTest::MarkerCookie& MarkerTest::findMarker(YGMarker markerType) {
|
||||
return find(markerCookies.begin(), markerCookies.end(), markerType);
|
||||
}
|
||||
|
||||
MarkerTest::MarkerCookie& MarkerTest::findLastMarker(YGMarker markerType) {
|
||||
return find(markerCookies.rbegin(), markerCookies.rend(), markerType);
|
||||
}
|
||||
|
||||
void MarkerTest::SetUp() {
|
||||
config = uniquePtr<YGConfig>{YGConfigNew(), &YGConfigFree};
|
||||
YGConfigSetMarkerCallbacks(config.get(), {startMarker, endMarker});
|
||||
}
|
||||
|
||||
void MarkerTest::TearDown() {
|
||||
markerCookies.resize(0);
|
||||
}
|
||||
|
||||
decltype(MarkerTest::markerCookies) MarkerTest::markerCookies = {};
|
||||
|
||||
} // namespace test
|
||||
} // namespace marker
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
bool operator==(const YGMarkerLayoutData& lhs, const YGMarkerLayoutData& rhs) {
|
||||
return lhs.layouts == rhs.layouts && lhs.measures == rhs.measures &&
|
||||
lhs.maxMeasureCache == rhs.maxMeasureCache &&
|
||||
lhs.cachedLayouts == rhs.cachedLayouts &&
|
||||
lhs.cachedMeasures == rhs.cachedMeasures;
|
||||
}
|
||||
|
||||
void PrintTo(const YGMarkerLayoutData data, std::ostream* os) {
|
||||
*os << "YGMarkerLayoutData{ layouts = " << data.layouts
|
||||
<< ", measures = " << data.measures
|
||||
<< ", maxMeasureCache = " << data.maxMeasureCache
|
||||
<< ", cachedLayouts = " << data.cachedLayouts
|
||||
<< ", cachedMeasures = " << data.cachedMeasures << " }";
|
||||
}
|
@@ -5,7 +5,6 @@
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
#include "YGMarker.h"
|
||||
#include "Yoga-internal.h"
|
||||
#include "Yoga.h"
|
||||
|
||||
@@ -44,7 +43,6 @@ public:
|
||||
std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()>
|
||||
experimentalFeatures = {};
|
||||
void* context = nullptr;
|
||||
YGMarkerCallbacks markerCallbacks = {nullptr, nullptr};
|
||||
|
||||
YGConfig(YGLogger logger);
|
||||
void log(YGConfig*, YGNode*, YGLogLevel, void*, const char*, va_list);
|
||||
|
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include "YGMarker.h"
|
||||
#include "YGConfig.h"
|
||||
|
||||
void YGConfigSetMarkerCallbacks(
|
||||
YGConfigRef config,
|
||||
YGMarkerCallbacks markerCallbacks) {
|
||||
config->markerCallbacks = markerCallbacks;
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "YGMacros.h"
|
||||
|
||||
YG_EXTERN_C_BEGIN
|
||||
|
||||
typedef struct YGNode* YGNodeRef;
|
||||
typedef struct YGConfig* YGConfigRef;
|
||||
|
||||
typedef YG_ENUM_BEGIN(YGMarker) {}
|
||||
YG_ENUM_END(YGMarker);
|
||||
|
||||
typedef struct {
|
||||
int layouts;
|
||||
int measures;
|
||||
int maxMeasureCache;
|
||||
int cachedLayouts;
|
||||
int cachedMeasures;
|
||||
int measureCallbacks;
|
||||
} YGMarkerLayoutData;
|
||||
|
||||
typedef struct {
|
||||
bool _unused;
|
||||
} YGMarkerNoData;
|
||||
|
||||
typedef union {
|
||||
YGMarkerNoData* noData;
|
||||
} YGMarkerData;
|
||||
|
||||
typedef struct {
|
||||
// accepts marker type, a node ref, and marker data (depends on marker type)
|
||||
// can return a handle or id that Yoga will pass to endMarker
|
||||
void* (*startMarker)(YGMarker, YGNodeRef, YGMarkerData);
|
||||
// accepts marker type, a node ref, marker data, and marker id as returned by
|
||||
// startMarker
|
||||
void (*endMarker)(YGMarker, YGNodeRef, YGMarkerData, void* id);
|
||||
} YGMarkerCallbacks;
|
||||
|
||||
void YGConfigSetMarkerCallbacks(YGConfigRef, YGMarkerCallbacks);
|
||||
|
||||
YG_EXTERN_C_END
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace marker {
|
||||
namespace detail {
|
||||
|
||||
template <YGMarker M>
|
||||
struct MarkerData;
|
||||
|
||||
struct NoMarkerData {
|
||||
using type = YGMarkerNoData;
|
||||
static type*& get(YGMarkerData& d) { return d.noData; }
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template <YGMarker M>
|
||||
typename detail::MarkerData<M>::type* data(YGMarkerData d) {
|
||||
return detail::MarkerData<M>::get(d);
|
||||
}
|
||||
|
||||
} // namespace marker
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
||||
|
||||
#endif // __cplusplus
|
@@ -15,7 +15,6 @@
|
||||
#include "YGNodePrint.h"
|
||||
#include "Yoga-internal.h"
|
||||
#include "event/event.h"
|
||||
#include "instrumentation.h"
|
||||
#ifdef _MSC_VER
|
||||
#include <float.h>
|
||||
|
||||
@@ -941,7 +940,7 @@ bool YGLayoutNodeInternal(
|
||||
const bool performLayout,
|
||||
const char* reason,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount);
|
||||
@@ -1191,7 +1190,7 @@ static void YGNodeComputeFlexBasisForChild(
|
||||
const YGMeasureMode heightMode,
|
||||
const YGDirection direction,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
@@ -1387,7 +1386,7 @@ static void YGNodeAbsoluteLayoutChild(
|
||||
const float height,
|
||||
const YGDirection direction,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
@@ -1588,7 +1587,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
||||
const YGMeasureMode heightMeasureMode,
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext) {
|
||||
YGAssertWithNode(
|
||||
node,
|
||||
@@ -1836,7 +1835,7 @@ static float YGNodeComputeFlexBasisForChildren(
|
||||
YGFlexDirection mainAxis,
|
||||
const YGConfigRef config,
|
||||
bool performLayout,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
@@ -2020,7 +2019,7 @@ static float YGDistributeFreeSpaceSecondPass(
|
||||
const YGMeasureMode measureModeCrossDim,
|
||||
const bool performLayout,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
@@ -2321,7 +2320,7 @@ static void YGResolveFlexibleLength(
|
||||
const YGMeasureMode measureModeCrossDim,
|
||||
const bool performLayout,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
@@ -2651,7 +2650,7 @@ static void YGNodelayoutImpl(
|
||||
const float ownerHeight,
|
||||
const bool performLayout,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
@@ -3707,7 +3706,7 @@ bool YGLayoutNodeInternal(
|
||||
const bool performLayout,
|
||||
const char* reason,
|
||||
const YGConfigRef config,
|
||||
YGMarkerLayoutData& layoutMarkerData,
|
||||
LayoutData& layoutMarkerData,
|
||||
void* const layoutContext,
|
||||
uint32_t depth,
|
||||
const uint32_t generationCount) {
|
||||
@@ -4065,7 +4064,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
void* layoutContext) {
|
||||
|
||||
Event::publish<Event::LayoutPassStart>(node, {layoutContext});
|
||||
YGMarkerLayoutData markerData = {};
|
||||
LayoutData markerData = {};
|
||||
|
||||
// Increment the generation count. This will force the recursive routine to
|
||||
// visit all dirty nodes at least once. Subsequent visits will be skipped if
|
||||
@@ -4161,7 +4160,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
gCurrentGenerationCount++;
|
||||
// Rerun the layout, and calculate the diff
|
||||
unsetUseLegacyFlagRecursively(nodeWithoutLegacyFlag);
|
||||
YGMarkerLayoutData layoutMarkerData = {};
|
||||
LayoutData layoutMarkerData = {};
|
||||
if (YGLayoutNodeInternal(
|
||||
nodeWithoutLegacyFlag,
|
||||
width,
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <yoga/YGEnums.h>
|
||||
#include <yoga/YGMarker.h>
|
||||
|
||||
struct YGConfig;
|
||||
struct YGNode;
|
||||
@@ -24,6 +23,15 @@ enum LayoutType : int {
|
||||
kCachedMeasure = 3
|
||||
};
|
||||
|
||||
struct LayoutData {
|
||||
int layouts;
|
||||
int measures;
|
||||
int maxMeasureCache;
|
||||
int cachedLayouts;
|
||||
int cachedMeasures;
|
||||
int measureCallbacks;
|
||||
};
|
||||
|
||||
struct Event {
|
||||
enum Type {
|
||||
NodeAllocation,
|
||||
@@ -94,7 +102,7 @@ struct Event::TypedData<Event::LayoutPassStart> {
|
||||
template <>
|
||||
struct Event::TypedData<Event::LayoutPassEnd> {
|
||||
void* layoutContext;
|
||||
YGMarkerLayoutData* layoutData;
|
||||
LayoutData* layoutData;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include "YGConfig.h"
|
||||
#include "YGMarker.h"
|
||||
#include "YGNode.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace yoga {
|
||||
namespace marker {
|
||||
|
||||
template <YGMarker MarkerType>
|
||||
class MarkerSection {
|
||||
private:
|
||||
using Data = detail::MarkerData<MarkerType>;
|
||||
|
||||
public:
|
||||
MarkerSection(YGNodeRef node) : MarkerSection{node, node->getConfig()} {}
|
||||
void end() {
|
||||
if (endMarker_) {
|
||||
endMarker_(MarkerType, node_, markerData(&data), userData_);
|
||||
endMarker_ = nullptr;
|
||||
}
|
||||
}
|
||||
~MarkerSection() { end(); }
|
||||
|
||||
typename Data::type data = {};
|
||||
|
||||
template <typename Ret, typename... Args>
|
||||
static Ret wrap(
|
||||
YGNodeRef node,
|
||||
Ret (YGNode::*method)(Args...),
|
||||
Args... args) {
|
||||
MarkerSection<MarkerType> section{node};
|
||||
return (node->*method)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
decltype(YGMarkerCallbacks{}.endMarker) endMarker_;
|
||||
YGNodeRef node_;
|
||||
void* userData_;
|
||||
|
||||
MarkerSection(YGNodeRef node, YGConfigRef config)
|
||||
: MarkerSection{node, config ? &config->markerCallbacks : nullptr} {}
|
||||
MarkerSection(YGNodeRef node, YGMarkerCallbacks* callbacks)
|
||||
: endMarker_{callbacks ? callbacks->endMarker : nullptr},
|
||||
node_{node},
|
||||
userData_{
|
||||
callbacks && callbacks->startMarker
|
||||
? callbacks->startMarker(MarkerType, node, markerData(&data))
|
||||
: nullptr} {}
|
||||
|
||||
static YGMarkerData markerData(typename Data::type* d) {
|
||||
YGMarkerData markerData = {};
|
||||
Data::get(markerData) = d;
|
||||
return markerData;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace marker
|
||||
} // namespace yoga
|
||||
} // namespace facebook
|
Reference in New Issue
Block a user