YGLayout.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the LICENSE
  5. * file in the root directory of this source tree.
  6. */
  7. #pragma once
  8. #include "YGFloatOptional.h"
  9. #include "Yoga-internal.h"
  10. constexpr std::array<float, 2> kYGDefaultDimensionValues = {
  11. {YGUndefined, YGUndefined}};
  12. struct YGLayout {
  13. std::array<float, 4> position = {};
  14. std::array<float, 2> dimensions = kYGDefaultDimensionValues;
  15. std::array<float, 6> margin = {};
  16. std::array<float, 6> border = {};
  17. std::array<float, 6> padding = {};
  18. YGDirection direction : 2;
  19. bool didUseLegacyFlag : 1;
  20. bool doesLegacyStretchFlagAffectsLayout : 1;
  21. bool hadOverflow : 1;
  22. uint32_t computedFlexBasisGeneration = 0;
  23. YGFloatOptional computedFlexBasis = {};
  24. // Instead of recomputing the entire layout every single time, we cache some
  25. // information to break early when nothing changed
  26. uint32_t generationCount = 0;
  27. YGDirection lastOwnerDirection = (YGDirection) -1;
  28. uint32_t nextCachedMeasurementsIndex = 0;
  29. std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>
  30. cachedMeasurements = {};
  31. std::array<float, 2> measuredDimensions = kYGDefaultDimensionValues;
  32. YGCachedMeasurement cachedLayout = YGCachedMeasurement();
  33. YGLayout()
  34. : direction(YGDirectionInherit),
  35. didUseLegacyFlag(false),
  36. doesLegacyStretchFlagAffectsLayout(false),
  37. hadOverflow(false) {}
  38. bool operator==(YGLayout layout) const;
  39. bool operator!=(YGLayout layout) const {
  40. return !(*this == layout);
  41. }
  42. };