yeet
This commit is contained in:
47
node_modules/react-native/ReactCommon/fabric/graphics/platform/cxx/Color.cpp
generated
vendored
Normal file
47
node_modules/react-native/ReactCommon/fabric/graphics/platform/cxx/Color.cpp
generated
vendored
Normal file
@ -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.
|
||||
*/
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
SharedColor colorFromComponents(ColorComponents components) {
|
||||
float ratio = 255.9999;
|
||||
return SharedColor(
|
||||
((int)(components.alpha * ratio) & 0xff) << 24 |
|
||||
((int)(components.red * ratio) & 0xff) << 16 |
|
||||
((int)(components.green * ratio) & 0xff) << 8 |
|
||||
((int)(components.blue * ratio) & 0xff));
|
||||
}
|
||||
|
||||
ColorComponents colorComponentsFromColor(SharedColor sharedColor) {
|
||||
float ratio = 256;
|
||||
Color color = *sharedColor;
|
||||
return ColorComponents{(float)((color >> 16) & 0xff) / ratio,
|
||||
(float)((color >> 8) & 0xff) / ratio,
|
||||
(float)((color >> 0) & 0xff) / ratio,
|
||||
(float)((color >> 24) & 0xff) / ratio};
|
||||
}
|
||||
|
||||
SharedColor clearColor() {
|
||||
static SharedColor color = colorFromComponents(ColorComponents{0, 0, 0, 0});
|
||||
return color;
|
||||
}
|
||||
|
||||
SharedColor blackColor() {
|
||||
static SharedColor color = colorFromComponents(ColorComponents{0, 0, 0, 1});
|
||||
return color;
|
||||
}
|
||||
|
||||
SharedColor whiteColor() {
|
||||
static SharedColor color = colorFromComponents(ColorComponents{1, 1, 1, 1});
|
||||
return color;
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
78
node_modules/react-native/ReactCommon/fabric/graphics/platform/cxx/Color.h
generated
vendored
Normal file
78
node_modules/react-native/ReactCommon/fabric/graphics/platform/cxx/Color.h
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
#include <react/graphics/ColorComponents.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
using Color = int;
|
||||
|
||||
/*
|
||||
* On Android, a color can be represented as 32 bits integer, so there is no
|
||||
* need to instantiate complex color objects and then pass them as shared
|
||||
* pointers. Hense instead of using shared_ptr, we use a simple wrapper class
|
||||
* which provides a pointer-like interface.
|
||||
*/
|
||||
class SharedColor {
|
||||
public:
|
||||
static const Color UndefinedColor = std::numeric_limits<Color>::max();
|
||||
|
||||
SharedColor() : color_(UndefinedColor) {}
|
||||
|
||||
SharedColor(const SharedColor &sharedColor) : color_(sharedColor.color_) {}
|
||||
|
||||
SharedColor(Color color) : color_(color) {}
|
||||
|
||||
SharedColor &operator=(const SharedColor &sharedColor) {
|
||||
color_ = sharedColor.color_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Color operator*() const {
|
||||
return color_;
|
||||
}
|
||||
|
||||
bool operator==(const SharedColor &otherColor) const {
|
||||
return color_ == otherColor.color_;
|
||||
}
|
||||
|
||||
bool operator!=(const SharedColor &otherColor) const {
|
||||
return color_ != otherColor.color_;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return color_ != UndefinedColor;
|
||||
}
|
||||
|
||||
private:
|
||||
Color color_;
|
||||
};
|
||||
|
||||
SharedColor colorFromComponents(ColorComponents components);
|
||||
ColorComponents colorComponentsFromColor(SharedColor color);
|
||||
|
||||
SharedColor clearColor();
|
||||
SharedColor blackColor();
|
||||
SharedColor whiteColor();
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<facebook::react::SharedColor> {
|
||||
size_t operator()(const facebook::react::SharedColor &sharedColor) const {
|
||||
return hash<decltype(*sharedColor)>{}(*sharedColor);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
22
node_modules/react-native/ReactCommon/fabric/graphics/platform/cxx/Float.h
generated
vendored
Normal file
22
node_modules/react-native/ReactCommon/fabric/graphics/platform/cxx/Float.h
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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 <limits>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/*
|
||||
* Exact type of float numbers which ideally should match a type behing
|
||||
* platform- and chip-architecture-specific float type.
|
||||
*/
|
||||
using Float = float;
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
55
node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/Color.cpp
generated
vendored
Normal file
55
node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/Color.cpp
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 "Color.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
SharedColor colorFromComponents(ColorComponents components) {
|
||||
const CGFloat componentsArray[] = {
|
||||
components.red, components.green, components.blue, components.alpha};
|
||||
|
||||
auto color = CGColorCreate(CGColorSpaceCreateDeviceRGB(), componentsArray);
|
||||
|
||||
return SharedColor(color, CFRelease);
|
||||
}
|
||||
|
||||
ColorComponents colorComponentsFromColor(SharedColor color) {
|
||||
if (!color) {
|
||||
// Empty color object can be considered as `clear` (black, fully
|
||||
// transparent) color.
|
||||
return ColorComponents{0, 0, 0, 0};
|
||||
}
|
||||
|
||||
auto numberOfComponents __unused = CGColorGetNumberOfComponents(color.get());
|
||||
assert(numberOfComponents == 4);
|
||||
const CGFloat *components = CGColorGetComponents(color.get());
|
||||
return ColorComponents{(float)components[0],
|
||||
(float)components[1],
|
||||
(float)components[2],
|
||||
(float)components[3]};
|
||||
}
|
||||
|
||||
SharedColor clearColor() {
|
||||
static SharedColor color = colorFromComponents(ColorComponents{0, 0, 0, 0});
|
||||
return color;
|
||||
}
|
||||
|
||||
SharedColor blackColor() {
|
||||
static SharedColor color = colorFromComponents(ColorComponents{0, 0, 0, 1});
|
||||
return color;
|
||||
}
|
||||
|
||||
SharedColor whiteColor() {
|
||||
static SharedColor color = colorFromComponents(ColorComponents{1, 1, 1, 1});
|
||||
return color;
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
30
node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/Color.h
generated
vendored
Normal file
30
node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/Color.h
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 <memory>
|
||||
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
#include <react/graphics/ColorComponents.h>
|
||||
#include <react/graphics/Float.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
using Color = CGColor;
|
||||
using SharedColor = std::shared_ptr<Color>;
|
||||
|
||||
SharedColor colorFromComponents(ColorComponents components);
|
||||
ColorComponents colorComponentsFromColor(SharedColor color);
|
||||
|
||||
SharedColor clearColor();
|
||||
SharedColor blackColor();
|
||||
SharedColor whiteColor();
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
23
node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/Float.h
generated
vendored
Normal file
23
node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/Float.h
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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 <CoreGraphics/CoreGraphics.h>
|
||||
#include <limits>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/*
|
||||
* Exact type of float numbers which ideally should match a type behing
|
||||
* platform- and chip-architecture-specific float type.
|
||||
*/
|
||||
using Float = CGFloat;
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
Reference in New Issue
Block a user