Make Yoga thread safe #786
@@ -175,6 +175,8 @@ public class YogaNode implements Cloneable {
|
|||||||
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
|
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private native void jni_YGNodeSetOwner(long nativePointer, long newOwnerNativePointer);
|
||||||
|
|
||||||
private native long jni_YGNodeClone(long nativePointer, Object newNode);
|
private native long jni_YGNodeClone(long nativePointer, Object newNode);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -182,6 +184,14 @@ public class YogaNode implements Cloneable {
|
|||||||
try {
|
try {
|
||||||
YogaNode clonedYogaNode = (YogaNode) super.clone();
|
YogaNode clonedYogaNode = (YogaNode) super.clone();
|
||||||
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
|
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
|
||||||
|
|
||||||
|
if (mChildren != null) {
|
||||||
|
for (YogaNode child : mChildren) {
|
||||||
|
child.jni_YGNodeSetOwner(child.mNativePointer, 0);
|
||||||
|
child.mOwner = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||||
clonedYogaNode.mOwner = null;
|
clonedYogaNode.mOwner = null;
|
||||||
clonedYogaNode.mChildren =
|
clonedYogaNode.mChildren =
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014-present, Facebook, Inc.
|
* 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.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fb/fbjni.h>
|
#include <fb/fbjni.h>
|
||||||
#include <yoga/YGNode.h>
|
#include <yoga/YGNode.h>
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
@@ -268,6 +268,16 @@ jlong jni_YGNodeNewWithConfig(alias_ref<jobject> thiz, jlong configPointer) {
|
|||||||
return reinterpret_cast<jlong>(node);
|
return reinterpret_cast<jlong>(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jni_YGNodeSetOwner(
|
||||||
|
alias_ref<jobject> thiz,
|
||||||
|
jlong nativePointer,
|
||||||
|
jlong newOwnerNativePointer) {
|
||||||
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
||||||
|
const YGNodeRef newOwnerNode = _jlong2YGNodeRef(newOwnerNativePointer);
|
||||||
|
|
||||||
|
node->setOwner(newOwnerNode);
|
||||||
|
}
|
||||||
|
|
||||||
jlong jni_YGNodeClone(
|
jlong jni_YGNodeClone(
|
||||||
alias_ref<jobject> thiz,
|
alias_ref<jobject> thiz,
|
||||||
jlong nativePointer,
|
jlong nativePointer,
|
||||||
@@ -667,6 +677,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
|||||||
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
|
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
|
||||||
YGMakeNativeMethod(jni_YGNodePrint),
|
YGMakeNativeMethod(jni_YGNodePrint),
|
||||||
YGMakeNativeMethod(jni_YGNodeClone),
|
YGMakeNativeMethod(jni_YGNodeClone),
|
||||||
|
YGMakeNativeMethod(jni_YGNodeSetOwner),
|
||||||
});
|
});
|
||||||
registerNatives(
|
registerNatives(
|
||||||
"com/facebook/yoga/YogaConfig",
|
"com/facebook/yoga/YogaConfig",
|
||||||
|
12381
website/package-lock.json
generated
12381
website/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,21 +4,22 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
|
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"antd": "^3.2.0",
|
"antd": "^3.6.5",
|
||||||
"atob": "^2.0.3",
|
"atob": "^2.1.1",
|
||||||
"gatsby": "^1.9.158",
|
"btoa": "^1.2.1",
|
||||||
"gatsby-link": "^1.6.34",
|
"gatsby": "^1.9.273",
|
||||||
"gatsby-plugin-antd": "^1.0.10",
|
"gatsby-link": "^1.6.45",
|
||||||
"gatsby-plugin-google-analytics": "^1.0.19",
|
"gatsby-plugin-antd": "^1.0.12",
|
||||||
"gatsby-plugin-less": "^1.1.4",
|
"gatsby-plugin-google-analytics": "^1.0.31",
|
||||||
"gatsby-plugin-react-helmet": "^2.0.3",
|
"gatsby-plugin-less": "^1.1.8",
|
||||||
"gatsby-plugin-react-next": "^1.0.8",
|
"gatsby-plugin-react-helmet": "^2.0.11",
|
||||||
"gatsby-remark-prismjs": "^1.2.14",
|
"gatsby-plugin-react-next": "^1.0.11",
|
||||||
"gatsby-source-filesystem": "^1.5.18",
|
"gatsby-remark-prismjs": "^2.0.4",
|
||||||
"gatsby-transformer-remark": "^1.7.31",
|
"gatsby-source-filesystem": "^1.5.39",
|
||||||
|
"gatsby-transformer-remark": "^1.7.44",
|
||||||
"immutable": "^4.0.0-rc.9",
|
"immutable": "^4.0.0-rc.9",
|
||||||
"react-helmet": "^5.2.0",
|
"react-helmet": "^5.2.0",
|
||||||
"react-syntax-highlighter": "^7.0.0",
|
"react-syntax-highlighter": "^8.0.0",
|
||||||
"yoga-layout": "^1.9.3"
|
"yoga-layout": "^1.9.3"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -31,6 +32,6 @@
|
|||||||
"develop": "gatsby develop"
|
"develop": "gatsby develop"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "1.13.4"
|
"prettier": "1.13.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ import PositionRecord from './PositionRecord';
|
|||||||
import LayoutRecord from './LayoutRecord';
|
import LayoutRecord from './LayoutRecord';
|
||||||
import Sidebar from './Sidebar';
|
import Sidebar from './Sidebar';
|
||||||
import {Row, Col, Button} from 'antd';
|
import {Row, Col, Button} from 'antd';
|
||||||
|
import btoa from 'btoa';
|
||||||
import type {LayoutRecordT} from './LayoutRecord';
|
import type {LayoutRecordT} from './LayoutRecord';
|
||||||
import type {Yoga$Direction} from 'yoga-layout';
|
import type {Yoga$Direction} from 'yoga-layout';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
@@ -183,12 +183,14 @@ const AboutSectionTwo = () => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<Page className="landing-page" title="A cross-platform layout engine">
|
<div>
|
||||||
<HeroSection />
|
<Page className="landing-page" title="A cross-platform layout engine">
|
||||||
<PlaygroundSection />
|
<HeroSection />
|
||||||
<AboutSectionOne />
|
<PlaygroundSection />
|
||||||
<hr />
|
<AboutSectionOne />
|
||||||
<AboutSectionTwo />
|
<hr />
|
||||||
<Footer />
|
<AboutSectionTwo />
|
||||||
</Page>
|
<Footer />
|
||||||
|
</Page>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
|
2581
website/yarn.lock
2581
website/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -246,9 +246,6 @@ YGNodeRef YGNodeClone(YGNodeRef oldNode) {
|
|||||||
node != nullptr,
|
node != nullptr,
|
||||||
"Could not allocate memory for node");
|
"Could not allocate memory for node");
|
||||||
oldNode->setChildRoot(node);
|
oldNode->setChildRoot(node);
|
||||||
for (auto &item : oldNode->getChildren()) {
|
|
||||||
item->setOwner(nullptr);
|
|
||||||
}
|
|
||||||
gNodeInstanceCount++;
|
gNodeInstanceCount++;
|
||||||
node->setOwner(nullptr);
|
node->setOwner(nullptr);
|
||||||
return node;
|
return node;
|
||||||
|
Reference in New Issue
Block a user