forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ImageRequestParams (facebook#47723)
Summary: Identity of `ImageRequest` is based on `ImageSource` and a subset of `ImageProps`. If any of those change, the request must be recreated and resubmitted. Currently, the relevant subset of ImageProps is represented by a single `blurRadius` prop. This list will grow in the future. In order to simplify adding new props to the image request, we introduce the `ImageRequestParams` type that will wrap all the relevant props. The alternative approach to pass `ImageProps` directly to `ImageManager` is worse because it would introduce dependency cycle between `ImageManager` and the `Image` component, and also it would require to store the props in State, which is bad. Changelog: [Internal] Differential Revision: D66172570
- Loading branch information
1 parent
9a61b84
commit d376a37
Showing
11 changed files
with
151 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...eact-native/ReactCommon/react/renderer/imagemanager/platform/android/ImageRequestParams.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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/renderer/graphics/Float.h> | ||
|
||
namespace facebook::react { | ||
|
||
class ImageRequestParams { | ||
public: | ||
ImageRequestParams() = default; | ||
ImageRequestParams(Float blurRadius) : blurRadius(blurRadius) {} | ||
|
||
Float blurRadius{}; | ||
|
||
bool operator==(const ImageRequestParams& rhs) const { | ||
return this->blurRadius == rhs.blurRadius; | ||
} | ||
|
||
bool operator!=(const ImageRequestParams& rhs) const { | ||
return !(*this == rhs); | ||
} | ||
}; | ||
|
||
} // namespace facebook::react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...react/renderer/imagemanager/platform/cxx/react/renderer/imagemanager/ImageRequestParams.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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/renderer/graphics/Float.h> | ||
|
||
namespace facebook::react { | ||
|
||
class ImageRequestParams { | ||
public: | ||
ImageRequestParams() = default; | ||
explicit ImageRequestParams(Float blurRadius) : blurRadius(blurRadius) {} | ||
|
||
Float blurRadius{}; | ||
|
||
bool operator==(const ImageRequestParams& rhs) const { | ||
return this->blurRadius == rhs.blurRadius; | ||
} | ||
|
||
bool operator!=(const ImageRequestParams& rhs) const { | ||
return !(*this == rhs); | ||
} | ||
}; | ||
|
||
} // namespace facebook::react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...react/renderer/imagemanager/platform/ios/react/renderer/imagemanager/ImageRequestParams.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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/renderer/graphics/Float.h> | ||
|
||
namespace facebook::react { | ||
|
||
class ImageRequestParams { | ||
public: | ||
ImageRequestParams() {} | ||
ImageRequestParams(Float blurRadius) : blurRadius(blurRadius) {} | ||
|
||
Float blurRadius{}; | ||
|
||
bool operator==(const ImageRequestParams& rhs) const { | ||
return this->blurRadius == rhs.blurRadius; | ||
} | ||
|
||
bool operator!=(const ImageRequestParams& rhs) const { | ||
return !(*this == rhs); | ||
} | ||
}; | ||
|
||
} // namespace facebook::react |