Files
yoga/yoga/algorithm/PixelGrid.h
Nick Gerleman 66cc95f932 Breaking: per-node pointScaleFactor (#1379)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1379

X-link: https://github.com/facebook/react-native/pull/39403

Right now we have a `pointScaleFactor` per-node, but only ever read the one off the root node. In most cases where config is global, these will be the same, but it is possible for these to differ.

This... doesn't make much sense from an API perspective, and there are edge cases where we may want to allow laying out a subtree with a different DPI then the rest of the tree (though I think there might be other solutions to that).

We should rethink some of what is currently on config being allowed per-node (do we really need each node to be able to have a separate logger?), but this makes the model consistent in the meantime.

This change is breaking to any users relying on setting `pointScaleFactor` on the config of the root node, but not other nodes.

Reviewed By: yungsters

Differential Revision: D49181131

fbshipit-source-id: f1363ca242094f04b995fd50c1e56834d5003425
2023-09-13 14:11:25 -07:00

30 lines
746 B
C++

/*
* Copyright (c) Meta Platforms, Inc. and 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 <yoga/Yoga.h>
#include <yoga/node/Node.h>
namespace facebook::yoga {
// Round a point value to the nearest physical pixel based on DPI
// (pointScaleFactor)
float roundValueToPixelGrid(
const double value,
const double pointScaleFactor,
const bool forceCeil,
const bool forceFloor);
// Round the layout results of a node and its subtree to the pixel grid.
void roundLayoutResultsToPixelGrid(
yoga::Node* const node,
const double absoluteLeft,
const double absoluteTop);
} // namespace facebook::yoga