Commit Graph

1739 Commits

Author SHA1 Message Date
David Aurelio
c235301b52 gentest: remove empty line after license
Summary:
@public

This gets flagged by the linter. Remove it.

Reviewed By: SidharthGuglani

Differential Revision: D14682386

fbshipit-source-id: 612508b0906285e6420a553ac7a96d1024f1eac6
2019-03-29 06:32:20 -07:00
David Aurelio
2fb81500c1 gentest: adapt license
Summary:
@public

Adapts the license header text to the format we currently use.

Reviewed By: SidharthGuglani

Differential Revision: D14653591

fbshipit-source-id: f79446e4f85623326f770fe73482eab00edd9234
2019-03-28 04:47:56 -07:00
Alexander Vasyuk
68d9209dd9 Revert D14368107: [yoga] moved all the properties used for layout outputs to YogaNodeJNI
Differential Revision:
D14368107

Original commit changeset: 75ca330c1e7f

fbshipit-source-id: 9a9f5140bf8b1563c9ba85b3fe5f93fc6d8fdf41
2019-03-26 20:21:24 -07:00
Alexander Vasyuk
e91569cdad Revert D14368114: [yoga] removing unused const int
Differential Revision:
D14368114

Original commit changeset: f63b978813a0

fbshipit-source-id: 86a517b1483b0635f283702602712c42c3d51e20
2019-03-26 20:21:23 -07:00
Sidharth Guglani
f31917aa01 removing unused const int
Summary: Removed unused const int

Reviewed By: davidaurelio

Differential Revision: D14368114

fbshipit-source-id: f63b978813a01a37710fac299dc7ec9aff610844
2019-03-26 08:51:41 -07:00
Will Wilson
74202aecff Adds workspace for more efficient yoga development
Summary: This workspace should ease yoga development

Reviewed By: dinhviethoa

Differential Revision: D14600002

fbshipit-source-id: 49f6d36680acad5835fcf96e80bcd547b667c0c8
2019-03-26 07:43:30 -07:00
Sidharth Guglani
9c2108c69e moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368107

fbshipit-source-id: 75ca330c1e7f07adc0ab8e7a5927d93977088918
2019-03-26 07:35:17 -07:00
David Aurelio
3d2836a947 CompactValue overrides of YGResolveValue/YGValueEqual
Summary:
@public

I would like to get rid of implicit conversions between `YGValue` and `CompactValue`, because they don’t come for free.

That’s why I am adding `CompactValue` specific overrides for `YGResolveValue` and  `YGValueEqual`, that do explicit casts. Up the commit stack, we will be able mark both `CompactValue(const YGValue&)` and `CompactValue::operator YGValue()` as `explicit`.

Reviewed By: SidharthGuglani

Differential Revision: D14598447

fbshipit-source-id: 75dc15cefb2dddcf8def891c5fb37893cacd9d46
2019-03-26 05:21:35 -07:00
David Aurelio
e4856a2264 Remove duplicated function declaration
Summary:
@public

Just removes a duplicated function declaration.

Reviewed By: SidharthGuglani

Differential Revision: D14598446

fbshipit-source-id: b4d8fe192f9a07f512f6a346f27d9046bb3bae23
2019-03-26 05:21:35 -07:00
Sidharth Guglani
a2ee0f65bd fixed @Nullable missing infer errors
Summary: Fixed Nullable lint errors

Reviewed By: davidaurelio

Differential Revision: D14383930

fbshipit-source-id: 0847e19c50a0b8d4039199045b74aa86c96ac096
2019-03-25 06:36:28 -07:00
David Aurelio
85352c4e45 Automatic lint fixes
Summary:
@public
A round of automatic lint fixes.

Reviewed By: SidharthGuglani

Differential Revision: D14590396

fbshipit-source-id: f0b4a0ce503a1d9d46ea7ae788f9f2eac09c2ac7
2019-03-25 05:41:30 -07:00
David Aurelio
7d7b7b9e18 Sample workspace: remove XML comment
Summary:
@public

Xcode does not like it

Reviewed By: astreet

Differential Revision: D14580168

fbshipit-source-id: 6d26b3961b45a59ef9dc977b21493e60e3cf9396
1.12.0-pre.3
2019-03-22 11:46:58 -07:00
David Aurelio
62d8a911ff Switch style getters to JNI fast calls
Summary:
@public

After changing native methods to return `long` rather than `YogaValue`, we switch them to JNI fast calls, as there is no more interaction with the Java GC.

Reviewed By: pasqualeanatriello

Differential Revision: D14576815

fbshipit-source-id: b5a33caef7343ba1de3d9634a50dc82ab3148cc7
2019-03-22 10:36:56 -07:00
David Aurelio
ca46c67e9e Create YogaValue instances in Java, not C++
Summary:
@public

Passing primitive data via JNI is more efficient than passing objects.

Here, we avoid creating `YogaValue` (Java) instances via JNI, and rather pass a `long` back to Java. The instance is then created by extracting the necessary bytes on the Java side.

Reviewed By: foghina

Differential Revision: D14576755

fbshipit-source-id: 22d09ad50c3ac6c49b0a797a0dad639ea4829df9
2019-03-22 10:36:55 -07:00
David Aurelio
5bb2265083 Move native methods to a single class
Summary:
@public

Moving all native methods in a single class provides the benefit of not having to load native bindings eagerly when just creating config objects in the startup paths, or setting Java-only values on them.
Loading native bindings triggers additional class loads (`YogaConfig` / `YogaNode`), and can lead to problems in multi-dex scenarions.

Reviewed By: pasqualeanatriello

Differential Revision: D14560658

fbshipit-source-id: 14e31e3c3b560675b5a752a38ae75ab80a565ea1
1.12.0-pre.2
2019-03-22 09:33:37 -07:00
David Aurelio
ab3bf40c7d Fix license headers
Summary:
@public

Yoga's Java license headers were not in the correct format.

Reviewed By: muraziz

Differential Revision: D14541087

fbshipit-source-id: 5b3cff398875bd59dadeaddbb43020700ef027e2
2019-03-21 04:56:49 -07:00
Sidharth Guglani
f273e80c77 created a new class YogaNodeJNI which extends YogaNodeJNIBase and using YogaNodeJNi for new object creation
Summary:
Added a child class of YogaNodeJNIBase which will be used to separate layout outputs transfer logic.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368098

fbshipit-source-id: e0f10fb61cd09ee47cf9ce41fb400f4cfb3dd795
2019-03-20 08:57:13 -07:00
David Aurelio
1471be54e3 JNI: Simplify node context
Summary:
@public
Contexts of nodes only hold a bit mask after we got rid of weak JNI refs.
We can simply store that data in a pointer-sized unsigned int.

Here, we replace all context heap allocations with usage of the node context (`void *`) as bitmask. We also add a couple of utility operators in order to keep the code comprehensible.

Reviewed By: fabiomassimo

Differential Revision: D14425742

fbshipit-source-id: f32c2184a1f09268c39dbb8cd09ac96517339674
2019-03-20 08:42:24 -07:00
Sidharth Guglani
f039835249 renamed YogaNodeJNI to YogaNodeJNIBase
Summary:
Renamed class from YogaNodeJNI to YogaNodeJNIBase.
This change set is for adding experiment for layout outputs batching using a float array where we will have two separate classes which will override how layout outputs are transferred to java YogaNode object.

We needed two separate classes because having everything in one class was causing memory issues as both the individual fields for width, height etc. and float array for batching needs to be present in code.

Reviewed By: davidaurelio

Differential Revision: D14368069

fbshipit-source-id: 0e98e28c8c7a9788345ccb92b2cd0f2cd4a53525
2019-03-20 07:53:48 -07:00
Yedidya Feldblum
f793ba2d6b Upgrade mobile BUCK and .bzl files to use C++14
Summary:
Upgrade mobile `BUCK` and `.bzl` files to use C++14.

Let's see what happens.

Reviewed By: mzlee

Differential Revision: D14223329

fbshipit-source-id: ff642ca017103d9415c4d7f5beaf5ded07ef7ff1
2019-03-16 02:25:21 -07:00
Peter van der Zee
9f72ad05ce Bump Prettier to 1.16.4
Summary:
@public
This bumps Prettier to v1.16.4
Only format source files were updated.

Reviewed By: mjesun

Differential Revision: D14454893

fbshipit-source-id: 72f9872fe764a79dbf0d9fab9bebb1456b039f2f
2019-03-14 07:00:56 -07:00
Eric Schlanger
14f3827491 Exclude logging functionality outside debug builds
Summary: Don't compile in YGNodePrint in production builds

Reviewed By: davidaurelio

Differential Revision: D14258269

fbshipit-source-id: 15b5e94d241a752fea74a45263aa343265071451
2019-03-13 07:52:26 -07:00
Sidharth Guglani
0d96098fd9 moved together the java object fields which are set always
Summary:
Moved all layout outputs fields which are set always on yoga node java object.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14355025

fbshipit-source-id: 371d9c49fcb631efa8a79b62f8051ba5a17c232c
2019-03-13 06:28:05 -07:00
Sidharth Guglani
42e3b78f04 change BOrder constant to 4 to set correct field bits
Summary: These constants are used for setting bit fields so they should be in power of 2

Reviewed By: davidaurelio

Differential Revision: D14384999

fbshipit-source-id: fa1f6994c874aff7a039ca98d5947cba317fa749
2019-03-13 03:20:25 -07:00
David Aurelio
3ad49d27d9 Remove configuration for avoiding JNI refs
Summary:
@public

Removes the configuration field to avoid weak JNI refs. It is no longer used.

Reviewed By: marco-cova

Differential Revision: D14424594

fbshipit-source-id: f0877022615a11ac5079354e0977c6893b7d58d7
2019-03-12 13:19:02 -07:00
David Aurelio
3331a9e480 No more weak JNI refs!
Summary:
@public

Completely removes the usage of weak JNI refs.

This is great, because node allocation and deallocation no longer go through a VM-global lock to access the weak reference table.
This is also great, because we can no longer overflow that ref table.
Performance is comparable to weak refs.

Reviewed By: marco-cova

Differential Revision: D14423068

fbshipit-source-id: 62003d2d6fd971e91460a26fb3477046f26e2ba5
2019-03-12 13:19:02 -07:00
David Aurelio
7890672ecc Fix Xcode Workspace
Summary: Turns out Xcode does not like document-level comments.

Reviewed By: SidharthGuglani

Differential Revision: D14301138

fbshipit-source-id: f515a1881daa109031963688c1556cb8ef42758f
2019-03-04 09:11:17 -08:00
Sidharth Guglani
d7bfbf3646 bump yoga version to 1.13.1-SNAPSHOT
Summary: Version bump to 1.13.1-SNAPSHOT

Reviewed By: davidaurelio

Differential Revision: D14300336

fbshipit-source-id: 2c0293d5eb95dc029d431133ce97e75fccd46897
2019-03-04 08:29:28 -08:00
Sidharth Guglani
6d271c05f6 update yoga version to 1.13.0
Summary: Bump yoga version to 1.13.0

Reviewed By: davidaurelio

Differential Revision: D14300306

fbshipit-source-id: 2865462731bcea7666ea14768dd6eb1a112944a9
v1.13.0
2019-03-04 07:42:35 -08:00
David Aurelio
a9bddf87ff Fix problems with GCC < v8
Summary:
@public

GCC up until v7 flags our way of reading edges in `YGNodeSetStyleInputs` as unused variables. I managed to work around that by rearranging the casts a bit.

Reviewed By: SidharthGuglani

Differential Revision: D14299439

fbshipit-source-id: eec0266185504d1b790b9ef574bd4a83c0059d3a
2019-03-04 02:37:17 -08:00
David Aurelio
88994129ae 1.12.0-pre.1 (#865)
Summary:
Push version in podspec. We will use `-SNAPSHOT` for bintray
Pull Request resolved: https://github.com/facebook/yoga/pull/865

Differential Revision: D14299474

Pulled By: davidaurelio

fbshipit-source-id: e788479677e1b3c4155a24a336e625508e085f86
1.12.0-pre.1 v1.12.0-pre.1
2019-03-04 01:34:36 -08:00
David Aurelio
888892885e Encapsulate all used java classes
Summary:
@public

Moves all Java classes used from C++ to their own header + implementation file. In `YGJNI.cpp`, we only call methods on these objects deriving from `jni::JavaClass`.

This is only a bit of cleanup, no functional change.

Reviewed By: SidharthGuglani

Differential Revision: D14261043

fbshipit-source-id: 2db1d81cb7f56a4cdc24b182b2166e1d7e24ba3c
2019-03-04 01:30:15 -08:00
David Aurelio
de79f2a1d4 for experimentation: configurable measure cache size
Summary:
@public

Allows to limit the number of measure cache entries used. This is purely for experimentation.

The measure cache uses about half of every `YGNode`. Reducing its size would allow us to reduce resident memory used by Yoga.

Reviewed By: SidharthGuglani

Differential Revision: D14279027

fbshipit-source-id: e0d22138230bee7fb129c193eb6e4085de02a36e
v1.12.0-pre.0
2019-03-02 12:43:01 -08:00
David Aurelio
6368416178 clean up config context
Summary: `YGConfigContext` was using `global_ref` instances for the config, leading to the config object never being freed. Since we no longer need it after getting rid of cloning, we can make the context a pointer to a `global_ref` to the logger.

Reviewed By: SidharthGuglani

Differential Revision: D14258571

fbshipit-source-id: cce632499839a680eef00a3854f61ab74ae2a87a
2019-03-01 05:45:15 -08:00
David Aurelio
a935a222b5 YGNode remove assignment operators
Summary:
@public

Having assignment operators for `YGNode` means that existing children on the node assigned to would have to be handled somehow.

Deallocating might be incorrect. Ignoring might leak.

Here, we `delete` copy assignment, and make move assignment private (it is used in `YGNode::reset()`).

Copy and move constructors *can* be implemented. The move constructor has to take ownership of the children, while the copy constructor leaves ownership untouched. Since children are copied lazily during layout, this does not expose true value semantics. We should consider removing the copy constructor, too.

Reviewed By: SidharthGuglani

Differential Revision: D14241663

fbshipit-source-id: 39ffdb07f1028bfcf2710c0674a06cdebf3bd650
2019-03-01 04:22:04 -08:00
Sidharth Guglani
7c4da0a341 added positive tests for all style inputs in batching API
Summary: Positive tests for all style input properties using JNI batching API

Reviewed By: davidaurelio

Differential Revision: D14207552

fbshipit-source-id: b7165c2115ace67bf131c76929d37df438921bf2
2019-02-28 12:52:01 -08:00
Sidharth Guglani
b047af25ca Setting flags for margin, padding, position and border
Summary:
We set flags to true when setting margin, padding, border, position individually
Doing the same for batching API

Reviewed By: davidaurelio

Differential Revision: D14207550

fbshipit-source-id: ddfdcd5056bea0dd76bd6762f47e90370e26c9e1
2019-02-28 12:52:01 -08:00
Sidharth Guglani
2abd9dd91b Added getters for flexWrap and flex style inputs in java bindings
Summary: Added getters fro flexWrap an flex style input properties in java bindings

Reviewed By: davidaurelio

Differential Revision: D14207517

fbshipit-source-id: e8d2ad17b5edbdf02e69011c6d95a4de076bd366
2019-02-28 12:52:01 -08:00
Sidharth Guglani
afadc5cf6b JNI batching API using float array
Summary:
Added a new API `YGNodeSetLayoutStyleInputs` to pass layout style inputs from java to native code.
All the style inputs are passed in a float array in [key1, key2, value2, key3, value3a, value3b .....] format over JNI layer.
There are three types of style inputs
- do not need any value to be passed along with them like WidthAuto, HeightAuto
- need one value to be passed like Width, Height
- need two values to be passed like Margin, Padding (edge value and actual margin, padding value)

Reviewed By: davidaurelio

Differential Revision: D14166948

fbshipit-source-id: 4bea64d6a429959c3962c87e337914dcd99199fd
2019-02-28 12:52:01 -08:00
Sidharth Guglani
8823cc357a added mEdgeSetFlags inside YogaNodeContext and using it YGJNI in getters/setters of margin, padding, border
Summary:
We have now create a yoga node context which consists of weak reference to java yoga node object and flag which tells us whether margin, padding , border are set or not.

This flag was initially in java layer and we have moved this to native layer as it will help us with enabling the bacthing API for setting style inputs.

Reviewed By: davidaurelio

Differential Revision: D14243378

fbshipit-source-id: fed935ef18c1abf2b07e5d69d9ca79ced51699f2
2019-02-28 12:52:01 -08:00
Sidharth Guglani
8b8d9a05b7 not setting flags when setting margin, padding, border and position on yoga node
Summary: We are now not setting flags when we set style inputs margin, padding, border and position on yoga node.

Reviewed By: davidaurelio

Differential Revision: D14224000

fbshipit-source-id: deef4c1ab1a60fbc4909183bc2aa59fa23939d43
2019-02-28 12:52:01 -08:00
David Aurelio
15668aceb6 Move reset logic to YGNode::reset()
Summary:
@public

Moving logic from free C functions to the C++ layer.

This will allow us to get rid of the dangerous copy / move assignment operators of `YGNode`.

Reviewed By: SidharthGuglani

Differential Revision: D14241564

fbshipit-source-id: aae9f2a7ffd23bb839f1747e4a0694578bae86ae
2019-02-28 06:31:34 -08:00
David Aurelio
e25fe994b3 Breaking remove YogaNode#clone
Summary:
@public

The cloning features of YogaNode don’t seem to be used. Let’s remove them.

Reviewed By: SidharthGuglani

Differential Revision: D14165624

fbshipit-source-id: 5b710964a4abf1b35f3bcc25b143ffc719a03cec
2019-02-27 04:43:34 -08:00
Chris Sarbora
47abe1c482 Rename makeCriticalNativeMethod to discourage over-use
Summary: "Critical" or "Fast" JNI methods are enticing by their name, but carry dangers that are not trivially visible.

Reviewed By: davidaurelio

Differential Revision: D14184560

fbshipit-source-id: 89ec70f53bb2cb89ff568d8b1fe222ede86c9824
2019-02-22 14:30:35 -08:00
David Aurelio
95169c3150 Don't call jni_YGNodeFree as fast native method
Summary:
@public

If `jni_YGNodeFree` is called while GC is running, the weak reference table lock is held by the GC, leading to deadlock.

Here, we revert the method to being a regular native method, solving that problem.

Reviewed By: SidharthGuglani

Differential Revision: D14184220

fbshipit-source-id: 2882fa10586617cea2df99550a7dd8885376d11e
2019-02-22 08:59:35 -08:00
David Aurelio
7331de78bd setBaseLine -> setBaseline
Summary:
@public

`setBaseLine` was the only place where we used a capitalised *L.* Fixed here.

Reviewed By: SidharthGuglani

Differential Revision: D14152320

fbshipit-source-id: abf54fe7d6088e03775968baa8421c4bf43d6a6e
2019-02-21 05:38:45 -08:00
David Aurelio
05f36a835a Allow to use JNI without global refs
Summary:
@public

Adds the ability to opt into avoiding global weak JNI refs via `YogaConfig`.

Note that only homogeneous trees are supported, i.e. **mixing weak-ref and non-weak-ref nodes will break!**

Not using JNI refs hopefully will help with avoiding JNI reference table overflows, and will help creating trees on multiple threads, as no lock has to be acquired at any time.

Reviewed By: SidharthGuglani

Differential Revision: D14151037

fbshipit-source-id: 56d94713d39aee080d54be4cb4cdf5e3eccb473a
2019-02-21 05:38:45 -08:00
Michael Lee
dcd9438488 Clean up unnecessary header glob
Reviewed By: davidaurelio

Differential Revision: D13509119

fbshipit-source-id: 35d32c82b4fbaf7529828982e69b15e1c61b9e25
2019-02-20 16:53:40 -08:00
David Aurelio
d38db1292c Use YGNodeRemoveAllChildren where appropriate
Summary:
@public

`YGNodeRemoveAllChildren` can be used instead of removing children of a yoga node in a loop.

Reviewed By: zats

Differential Revision: D14131679

fbshipit-source-id: 6ee31f1e288b9b161c641b5bca4f2c1156d58c38
2019-02-20 12:35:27 -08:00
David Aurelio
4463fe0856 Add config for avoiding JNI refs
Summary:
@public

Adds `YogaConfig#avoidGlobalJNIRefs` to control whether nodes created with a config will use weak global JNI refs. Used for experimentation.

Reviewed By: SidharthGuglani

Differential Revision: D14149982

fbshipit-source-id: c777c8b3af2167d96154db5aa6afec1476dac35b
2019-02-20 12:01:15 -08:00