Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ImageProps::ImageProps(
rawProps,
"resizeMethod",
sourceProps.resizeMethod,
{})),
{"auto"})),
resizeMultiplier(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.resizeMultiplier
Expand All @@ -107,7 +107,7 @@ ImageProps::ImageProps(
rawProps,
"resizeMultiplier",
sourceProps.resizeMultiplier,
{})),
1)),
shouldNotifyLoadEvents(
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
? sourceProps.shouldNotifyLoadEvents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class ImageProps final : public ViewProps {
EdgeInsets capInsets{};
SharedColor tintColor{};
std::string internal_analyticTag{};
std::string resizeMethod{};
Float resizeMultiplier{};
std::string resizeMethod{"auto"};
Float resizeMultiplier{1.f};
bool shouldNotifyLoadEvents{};
SharedColor overlayColor{};
Float fadeDuration{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ void ImageShadowNode::updateStateIfNeeded() {
imageProps.fadeDuration,
imageProps.progressiveRenderingEnabled,
imageProps.loadingIndicatorSource,
imageProps.internal_analyticTag
imageProps.internal_analyticTag,
Size{
.width =
layoutMetrics_.frame.size.width * layoutMetrics_.pointScaleFactor,
.height = layoutMetrics_.frame.size.height *
layoutMetrics_.pointScaleFactor}
#endif
);

Expand All @@ -85,7 +90,9 @@ void ImageShadowNode::updateStateIfNeeded() {
(uri.starts_with("content://") || uri.starts_with("file://")));
// If we would resize but have no dimensions, skip creating the request
if (shouldResize &&
(newImageSource.size.width == 0 || newImageSource.size.height == 0)) {
(newImageSource.size.width == 0 || newImageSource.size.height == 0 ||
layoutMetrics_.frame.size.width == 0 ||
layoutMetrics_.frame.size.height == 0)) {
// Keep the old state - don't create a new image request
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class ImageRequestParams {
Float fadeDuration,
bool progressiveRenderingEnabled,
ImageSource loadingIndicatorSource,
std::string analyticTag)
std::string analyticTag,
Size size)
: blurRadius(blurRadius),
defaultSource(std::move(defaultSource)),
resizeMode(resizeMode),
Expand All @@ -42,7 +43,8 @@ class ImageRequestParams {
fadeDuration(fadeDuration),
progressiveRenderingEnabled(progressiveRenderingEnabled),
loadingIndicatorSource(std::move(loadingIndicatorSource)),
analyticTag(std::move(analyticTag))
analyticTag(std::move(analyticTag)),
size(size)
{
}

Expand All @@ -58,6 +60,7 @@ class ImageRequestParams {
bool progressiveRenderingEnabled{};
ImageSource loadingIndicatorSource{};
std::string analyticTag{};
Size size{};

bool operator==(const ImageRequestParams &rhs) const
{
Expand All @@ -73,7 +76,8 @@ class ImageRequestParams {
this->fadeDuration,
this->progressiveRenderingEnabled,
this->loadingIndicatorSource,
this->analyticTag) ==
this->analyticTag,
this->size) ==
std::tie(
rhs.blurRadius,
rhs.defaultSource,
Expand All @@ -86,7 +90,8 @@ class ImageRequestParams {
rhs.fadeDuration,
rhs.progressiveRenderingEnabled,
rhs.loadingIndicatorSource,
rhs.analyticTag);
rhs.analyticTag,
rhs.size);
}

bool operator!=(const ImageRequestParams &rhs) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ constexpr MapBuffer::Key IS_KEY_DEFAULT_SRC = 1;
constexpr MapBuffer::Key IS_KEY_RESIZE_MODE = 2;
constexpr MapBuffer::Key IS_KEY_RESIZE_METHOD = 3;
constexpr MapBuffer::Key IS_KEY_BLUR_RADIUS = 4;
constexpr MapBuffer::Key IS_KEY_VIEW_WIDTH = 5;
constexpr MapBuffer::Key IS_KEY_VIEW_HEIGHT = 6;
constexpr MapBuffer::Key IS_KEY_IMAGE_WIDTH = 5;
constexpr MapBuffer::Key IS_KEY_IMAGE_HEIGHT = 6;
constexpr MapBuffer::Key IS_KEY_RESIZE_MULTIPLIER = 7;
constexpr MapBuffer::Key IS_KEY_SHOULD_NOTIFY_LOAD_EVENTS = 8;
constexpr MapBuffer::Key IS_KEY_OVERLAY_COLOR = 9;
Expand All @@ -35,16 +35,20 @@ constexpr MapBuffer::Key IS_KEY_PROGRESSIVE_RENDERING_ENABLED = 12;
constexpr MapBuffer::Key IS_KEY_LOADING_INDICATOR_SRC = 13;
constexpr MapBuffer::Key IS_KEY_ANALYTIC_TAG = 14;
constexpr MapBuffer::Key IS_KEY_TAG = 15;
constexpr MapBuffer::Key IS_KEY_VIEW_WIDTH = 16;
constexpr MapBuffer::Key IS_KEY_VIEW_HEIGHT = 17;

inline void serializeImageSource(MapBufferBuilder &builder, const ImageSource &imageSource)
{
builder.putString(IS_KEY_URI, imageSource.uri);
builder.putInt(IS_KEY_VIEW_WIDTH, static_cast<int32_t>(imageSource.size.width));
builder.putInt(IS_KEY_VIEW_HEIGHT, static_cast<int32_t>(imageSource.size.height));
builder.putInt(IS_KEY_IMAGE_WIDTH, static_cast<int32_t>(imageSource.size.width));
builder.putInt(IS_KEY_IMAGE_HEIGHT, static_cast<int32_t>(imageSource.size.height));
}

inline void serializeImageRequestParams(MapBufferBuilder &builder, const ImageRequestParams &imageRequestParams)
{
builder.putInt(IS_KEY_VIEW_WIDTH, static_cast<int32_t>(imageRequestParams.size.width));
builder.putInt(IS_KEY_VIEW_HEIGHT, static_cast<int32_t>(imageRequestParams.size.height));
builder.putString(IS_KEY_DEFAULT_SRC, imageRequestParams.defaultSource.uri);
builder.putInt(IS_KEY_RESIZE_MODE, to_underlying(imageRequestParams.resizeMode));
builder.putString(IS_KEY_RESIZE_METHOD, imageRequestParams.resizeMethod);
Expand Down
Loading