-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove JNI Binding usage of layoutContext (#39402)
Summary: Pull Request resolved: #39402 X-link: facebook/yoga#1377 To avoid keeping a per-node mapping on native Yoga nodes to Java nodes, a per-layout context was added, to be able to pass information from the start of the layout, to measure functions, log functions, etc. The way this was done was super invasive, and added quite a few private APIs used only by the JNI functions. This change removes the context-using functions from the JNI bindings in favor of it managing its own context. Next diff removes all the cruft. Differential Revision: D49179243 fbshipit-source-id: 0b55b48444f3c88761fd22a93079509760f56060
- Loading branch information
1 parent
a8d4fbe
commit ae79b1c
Showing
4 changed files
with
71 additions
and
33 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni/LayoutContext.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "LayoutContext.h" | ||
|
||
namespace facebook::yoga::vanillajni { | ||
|
||
thread_local std::stack<PtrJNodeMapVanilla*> LayoutContext::contexts_; | ||
|
||
} // namespace facebook::yoga::vanillajni |
32 changes: 32 additions & 0 deletions
32
packages/react-native/ReactAndroid/src/main/jni/first-party/yogajni/jni/LayoutContext.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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 <stack> | ||
#include "YGJTypesVanilla.h" | ||
|
||
namespace facebook::yoga::vanillajni { | ||
|
||
class LayoutContext { | ||
public: | ||
struct Holder { | ||
explicit Holder(PtrJNodeMapVanilla* data) { | ||
LayoutContext::contexts_.push(data); | ||
} | ||
~Holder() { LayoutContext::contexts_.pop(); } | ||
}; | ||
|
||
static PtrJNodeMapVanilla* getCurrent() { | ||
return contexts_.empty() ? nullptr : contexts_.top(); | ||
} | ||
|
||
private: | ||
static thread_local std::stack<PtrJNodeMapVanilla*> contexts_; | ||
}; | ||
|
||
} // namespace facebook::yoga::vanillajni |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters