mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
58a7ddd55d
Summary: Here I'm implementing equality methods for ARTGroup, ARTShape and ARTText and I'm using these methods to update the state only when it is necessary. This will improve perf in rendering of ART changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D21695127 fbshipit-source-id: b438ddea4c34bd7a0bdf26a6aac4fd62a9f78b49
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <react/components/art/ARTSurfaceViewShadowNode.h>
|
|
#include <react/components/art/ARTBaseShadowNode.h>
|
|
#include <react/components/art/ARTGroupShadowNode.h>
|
|
#include <react/components/art/ARTSurfaceViewState.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
using Content = ARTSurfaceViewShadowNode::Content;
|
|
|
|
extern const char ARTSurfaceViewComponentName[] = "ARTSurfaceView";
|
|
|
|
void ARTSurfaceViewShadowNode::layout(LayoutContext layoutContext) {
|
|
ensureUnsealed();
|
|
auto content = getContent();
|
|
updateStateIfNeeded(content);
|
|
}
|
|
|
|
Content const &ARTSurfaceViewShadowNode::getContent() const {
|
|
if (content_.has_value()) {
|
|
return content_.value();
|
|
}
|
|
ensureUnsealed();
|
|
auto elements = ARTElement::ListOfShared{};
|
|
ARTBaseShadowNode::buildElements(*this, elements);
|
|
content_ = Content{elements};
|
|
return content_.value();
|
|
}
|
|
|
|
void ARTSurfaceViewShadowNode::updateStateIfNeeded(Content const &content) {
|
|
ensureUnsealed();
|
|
auto &state = getStateData();
|
|
if (content.elements == state.elements) {
|
|
return;
|
|
}
|
|
setStateData(ARTSurfaceViewState{content.elements});
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|