mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
64 lines
1.5 KiB
C++
64 lines
1.5 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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <react/components/art/ARTElement.h>
|
|
#include <react/components/art/primitives.h>
|
|
#include <react/graphics/Geometry.h>
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/*
|
|
* Simple, cross-platfrom, React-specific implementation of ART Shape Element
|
|
*/
|
|
class ARTShape : public ARTElement {
|
|
public:
|
|
using Shared = std::shared_ptr<const ARTShape>;
|
|
ARTShape(
|
|
Float opacity,
|
|
std::vector<Float> transform,
|
|
std::vector<Float> d,
|
|
std::vector<Float> stroke,
|
|
std::vector<Float> strokeDash,
|
|
std::vector<Float> fill,
|
|
Float strokeWidth,
|
|
int strokeCap,
|
|
int strokeJoin)
|
|
: ARTElement(ARTElementType::Shape, opacity, transform),
|
|
d(d),
|
|
stroke(stroke),
|
|
strokeDash(strokeDash),
|
|
fill(fill),
|
|
strokeWidth(strokeWidth),
|
|
strokeCap(strokeCap),
|
|
strokeJoin(strokeJoin){};
|
|
ARTShape() = default;
|
|
virtual ~ARTShape(){};
|
|
|
|
std::vector<Float> d{};
|
|
std::vector<Float> stroke{};
|
|
std::vector<Float> strokeDash{};
|
|
std::vector<Float> fill{};
|
|
Float strokeWidth{1.0};
|
|
int strokeCap{1};
|
|
int strokeJoin{1};
|
|
|
|
bool operator==(const ARTElement &rhs) const override;
|
|
bool operator!=(const ARTElement &rhs) const override;
|
|
|
|
#ifdef ANDROID
|
|
folly::dynamic getDynamic() const override;
|
|
#endif
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|