123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /**
- * Copyright (c) 2014-present, Facebook, Inc.
- *
- * 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 <algorithm>
- #include <array>
- #include <cmath>
- #include <vector>
- #include "Yoga.h"
- using YGVector = std::vector<YGNodeRef>;
- YG_EXTERN_C_BEGIN
- WIN_EXPORT float YGRoundValueToPixelGrid(const float value,
- const float pointScaleFactor,
- const bool forceCeil,
- const bool forceFloor);
- YG_EXTERN_C_END
- extern const std::array<YGEdge, 4> trailing;
- extern const std::array<YGEdge, 4> leading;
- extern bool YGValueEqual(const YGValue a, const YGValue b);
- extern const YGValue YGValueUndefined;
- extern const YGValue YGValueAuto;
- extern const YGValue YGValueZero;
- template <std::size_t size>
- bool YGValueArrayEqual(
- const std::array<YGValue, size> val1,
- const std::array<YGValue, size> val2) {
- bool areEqual = true;
- for (uint32_t i = 0; i < size && areEqual; ++i) {
- areEqual = YGValueEqual(val1[i], val2[i]);
- }
- return areEqual;
- }
- struct YGCachedMeasurement {
- float availableWidth;
- float availableHeight;
- YGMeasureMode widthMeasureMode;
- YGMeasureMode heightMeasureMode;
- float computedWidth;
- float computedHeight;
- YGCachedMeasurement()
- : availableWidth(0),
- availableHeight(0),
- widthMeasureMode((YGMeasureMode)-1),
- heightMeasureMode((YGMeasureMode)-1),
- computedWidth(-1),
- computedHeight(-1) {}
- bool operator==(YGCachedMeasurement measurement) const {
- bool isEqual = widthMeasureMode == measurement.widthMeasureMode &&
- heightMeasureMode == measurement.heightMeasureMode;
- if (!YGFloatIsUndefined(availableWidth) ||
- !YGFloatIsUndefined(measurement.availableWidth)) {
- isEqual = isEqual && availableWidth == measurement.availableWidth;
- }
- if (!YGFloatIsUndefined(availableHeight) ||
- !YGFloatIsUndefined(measurement.availableHeight)) {
- isEqual = isEqual && availableHeight == measurement.availableHeight;
- }
- if (!YGFloatIsUndefined(computedWidth) ||
- !YGFloatIsUndefined(measurement.computedWidth)) {
- isEqual = isEqual && computedWidth == measurement.computedWidth;
- }
- if (!YGFloatIsUndefined(computedHeight) ||
- !YGFloatIsUndefined(measurement.computedHeight)) {
- isEqual = isEqual && computedHeight == measurement.computedHeight;
- }
- return isEqual;
- }
- };
- // This value was chosen based on empiracle data. Even the most complicated
- // layouts should not require more than 16 entries to fit within the cache.
- #define YG_MAX_CACHED_RESULT_COUNT 16
- static const float kDefaultFlexGrow = 0.0f;
- static const float kDefaultFlexShrink = 0.0f;
- static const float kWebDefaultFlexShrink = 1.0f;
- extern bool YGFloatsEqual(const float a, const float b);
- extern bool YGValueEqual(const YGValue a, const YGValue b);
- extern const YGValue* YGComputedEdgeValue(
- const std::array<YGValue, YGEdgeCount>& edges,
- const YGEdge edge,
- const YGValue* const defaultValue);
|