mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Create classes to represent C++ state of ART
Summary: This diff introduces a set of classes that are going to be used to represent the internal State of ART nodes changeLog: [Internal][Android] Internal change to support ART in Fabric Reviewed By: JoshuaGross, shergin Differential Revision: D21657612 fbshipit-source-id: ea6d94b06807ff02d222dfa129a1cae384dceeaa
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4830085f40
commit
192bea1613
@@ -31,6 +31,7 @@ rn_xplat_cxx_library(
|
||||
("", "*.h"),
|
||||
("group", "*.h"),
|
||||
("shape", "*.h"),
|
||||
("state", "*.h"),
|
||||
("surfaceview", "*.h"),
|
||||
("text", "*.h"),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* 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/Element.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 <folly/Hash.h>
|
||||
#include <folly/Optional.h>
|
||||
#include <react/components/art/Primitives.h>
|
||||
#include <react/core/Sealable.h>
|
||||
#include <react/core/ShadowNode.h>
|
||||
#include <react/debug/DebugStringConvertible.h>
|
||||
#include <react/graphics/Geometry.h>
|
||||
#include <react/mounting/ShadowView.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/*
|
||||
* Simple, cross-platfrom, React-specific implementation of base ART Element
|
||||
*/
|
||||
class Element {
|
||||
public:
|
||||
using Shared = std::shared_ptr<const Element>;
|
||||
using ListOfShared = better::small_vector<Element::Shared, 0>;
|
||||
|
||||
Element() = default;
|
||||
Element(int elementType, Float opacity, std::vector<Float> transform)
|
||||
: elementType(elementType), opacity(opacity), transform(transform){};
|
||||
virtual ~Element(){};
|
||||
|
||||
int elementType;
|
||||
Float opacity;
|
||||
std::vector<Float> transform;
|
||||
|
||||
#ifdef ANDROID
|
||||
virtual folly::dynamic getDynamic() const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace facebook {
|
||||
namespace react {} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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/Group.h>
|
||||
#include <react/components/art/Element.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic Group::getDynamic() const {
|
||||
return folly::dynamic::object();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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/Element.h>
|
||||
#include <react/graphics/Geometry.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/*
|
||||
* Simple, cross-platfrom, React-specific implementation of ART Group element
|
||||
*/
|
||||
class Group : public Element {
|
||||
public:
|
||||
using Shared = std::shared_ptr<const Group>;
|
||||
Group(
|
||||
Float opacity,
|
||||
std::vector<Float> transform,
|
||||
Element::ListOfShared elements,
|
||||
std::vector<Float> clipping)
|
||||
: Element(1, opacity, transform),
|
||||
elements(elements),
|
||||
clipping(clipping){};
|
||||
Group() = default;
|
||||
virtual ~Group(){};
|
||||
|
||||
Element::ListOfShared elements{};
|
||||
|
||||
std::vector<Float> clipping{};
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic getDynamic() const override;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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/Shape.h>
|
||||
#include <react/components/art/Element.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic Shape::getDynamic() const {
|
||||
return folly::dynamic::object();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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/Element.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 Shape : public Element {
|
||||
public:
|
||||
using Shared = std::shared_ptr<const Shape>;
|
||||
Shape(
|
||||
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)
|
||||
: Element(2, opacity, transform),
|
||||
d(d),
|
||||
stroke(stroke),
|
||||
strokeDash(strokeDash),
|
||||
fill(fill),
|
||||
strokeWidth(strokeWidth),
|
||||
strokeCap(strokeCap),
|
||||
strokeJoin(strokeJoin){};
|
||||
Shape() = default;
|
||||
virtual ~Shape(){};
|
||||
|
||||
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};
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic getDynamic() const override;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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/Text.h>
|
||||
#include <react/components/art/Element.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic Shape::getDynamic() const {
|
||||
return folly::dynamic::object();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/Element.h>
|
||||
#include <react/components/art/Shape.h>
|
||||
#include <react/graphics/Geometry.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/*
|
||||
* Simple, cross-platfrom, React-specific implementation of ART Text Element
|
||||
*/
|
||||
class Text : public Shape {
|
||||
public:
|
||||
using Shared = std::shared_ptr<const Text>;
|
||||
Text(int elementType) : Shape(){};
|
||||
Text() = default;
|
||||
virtual ~Text(){};
|
||||
|
||||
int aligment{0};
|
||||
|
||||
// TODO T64130144: add frame data
|
||||
// ARTTextFrameStruct frame{}
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic getDynamic() const override;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 <functional>
|
||||
#include <limits>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
enum class ElementType { Shape, Text, Group };
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
Reference in New Issue
Block a user