Files
react-native/ReactCommon/fabric/components/art/state/ARTGroup.cpp
T
David Vacca 58a7ddd55d Implement equality of ARTElements and use it in ARTState
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
2020-05-22 01:23:37 -07:00

41 lines
1001 B
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/ARTGroup.h>
#include <react/components/art/ARTElement.h>
#include <react/components/art/conversions.h>
namespace facebook {
namespace react {
bool ARTGroup::operator==(const ARTElement &rhs) const {
if (rhs.elementType != ARTElementType::Group) {
return false;
}
auto group = (const ARTGroup &)(rhs);
return std::tie(elementType, opacity, transform, clipping) ==
std::tie(
group.elementType,
group.opacity,
group.transform,
group.clipping) &&
elements == group.elements;
}
bool ARTGroup::operator!=(const ARTElement &rhs) const {
return !(*this == rhs);
}
#ifdef ANDROID
folly::dynamic ARTGroup::getDynamic() const {
return toDynamic(*this);
}
#endif
} // namespace react
} // namespace facebook