diff --git a/ReactCommon/fabric/components/art/BUCK b/ReactCommon/fabric/components/art/BUCK index 56d972980fb..d14d6bcbfad 100644 --- a/ReactCommon/fabric/components/art/BUCK +++ b/ReactCommon/fabric/components/art/BUCK @@ -31,6 +31,7 @@ rn_xplat_cxx_library( ("", "*.h"), ("group", "*.h"), ("shape", "*.h"), + ("state", "*.h"), ("surfaceview", "*.h"), ("text", "*.h"), ], diff --git a/ReactCommon/fabric/components/art/state/Element.cpp b/ReactCommon/fabric/components/art/state/Element.cpp new file mode 100644 index 00000000000..fd1891ed200 --- /dev/null +++ b/ReactCommon/fabric/components/art/state/Element.cpp @@ -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 + +namespace facebook { +namespace react {} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/components/art/state/Element.h b/ReactCommon/fabric/components/art/state/Element.h new file mode 100644 index 00000000000..9bc702083ae --- /dev/null +++ b/ReactCommon/fabric/components/art/state/Element.h @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +/* + * Simple, cross-platfrom, React-specific implementation of base ART Element + */ +class Element { + public: + using Shared = std::shared_ptr; + using ListOfShared = better::small_vector; + + Element() = default; + Element(int elementType, Float opacity, std::vector transform) + : elementType(elementType), opacity(opacity), transform(transform){}; + virtual ~Element(){}; + + int elementType; + Float opacity; + std::vector transform; + +#ifdef ANDROID + virtual folly::dynamic getDynamic() const = 0; +#endif +}; + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/components/art/state/ElementFactory.cpp b/ReactCommon/fabric/components/art/state/ElementFactory.cpp new file mode 100644 index 00000000000..cae822dd2cf --- /dev/null +++ b/ReactCommon/fabric/components/art/state/ElementFactory.cpp @@ -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 diff --git a/ReactCommon/fabric/components/art/state/Group.cpp b/ReactCommon/fabric/components/art/state/Group.cpp new file mode 100644 index 00000000000..f74e75c7524 --- /dev/null +++ b/ReactCommon/fabric/components/art/state/Group.cpp @@ -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 +#include + +namespace facebook { +namespace react { + +#ifdef ANDROID +folly::dynamic Group::getDynamic() const { + return folly::dynamic::object(); +} +#endif + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/components/art/state/Group.h b/ReactCommon/fabric/components/art/state/Group.h new file mode 100644 index 00000000000..3515f58d432 --- /dev/null +++ b/ReactCommon/fabric/components/art/state/Group.h @@ -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 +#include +#include +#include + +namespace facebook { +namespace react { + +/* + * Simple, cross-platfrom, React-specific implementation of ART Group element + */ +class Group : public Element { + public: + using Shared = std::shared_ptr; + Group( + Float opacity, + std::vector transform, + Element::ListOfShared elements, + std::vector clipping) + : Element(1, opacity, transform), + elements(elements), + clipping(clipping){}; + Group() = default; + virtual ~Group(){}; + + Element::ListOfShared elements{}; + + std::vector clipping{}; + +#ifdef ANDROID + folly::dynamic getDynamic() const override; +#endif +}; + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/components/art/state/Shape.cpp b/ReactCommon/fabric/components/art/state/Shape.cpp new file mode 100644 index 00000000000..f07c09e2593 --- /dev/null +++ b/ReactCommon/fabric/components/art/state/Shape.cpp @@ -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 +#include + +namespace facebook { +namespace react { + +#ifdef ANDROID +folly::dynamic Shape::getDynamic() const { + return folly::dynamic::object(); +} +#endif + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/components/art/state/Shape.h b/ReactCommon/fabric/components/art/state/Shape.h new file mode 100644 index 00000000000..f1ffe2c8044 --- /dev/null +++ b/ReactCommon/fabric/components/art/state/Shape.h @@ -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 +#include +#include +#include + +namespace facebook { +namespace react { + +/* + * Simple, cross-platfrom, React-specific implementation of ART Shape Element + */ +class Shape : public Element { + public: + using Shared = std::shared_ptr; + Shape( + Float opacity, + std::vector transform, + std::vector d, + std::vector stroke, + std::vector strokeDash, + std::vector 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 d{}; + std::vector stroke{}; + std::vector strokeDash{}; + std::vector fill{}; + Float strokeWidth{1.0}; + int strokeCap{1}; + int strokeJoin{1}; + +#ifdef ANDROID + folly::dynamic getDynamic() const override; +#endif +}; + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/components/art/state/Text.cpp b/ReactCommon/fabric/components/art/state/Text.cpp new file mode 100644 index 00000000000..e7b183357b5 --- /dev/null +++ b/ReactCommon/fabric/components/art/state/Text.cpp @@ -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 +#include + +namespace facebook { +namespace react { + +#ifdef ANDROID +folly::dynamic Shape::getDynamic() const { + return folly::dynamic::object(); +} +#endif + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/components/art/state/Text.h b/ReactCommon/fabric/components/art/state/Text.h new file mode 100644 index 00000000000..cf9139d2896 --- /dev/null +++ b/ReactCommon/fabric/components/art/state/Text.h @@ -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 +#include +#include +#include +#include + +namespace facebook { +namespace react { + +/* + * Simple, cross-platfrom, React-specific implementation of ART Text Element + */ +class Text : public Shape { + public: + using Shared = std::shared_ptr; + 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 diff --git a/ReactCommon/fabric/components/art/state/primitives.h b/ReactCommon/fabric/components/art/state/primitives.h new file mode 100644 index 00000000000..afa2ebbf989 --- /dev/null +++ b/ReactCommon/fabric/components/art/state/primitives.h @@ -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 +#include + +namespace facebook { +namespace react { + +enum class ElementType { Shape, Text, Group }; + +} // namespace react +} // namespace facebook