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.
Android: Initiate image prefetching on ImageShadowNode layout (facebo…
…ok#47932) Summary: This diff introduces a code path to trigger image prefetching from `ImageShadowNode::layout`. Changelog: [Internal] Reviewed By: javache Differential Revision: D66454087
- Loading branch information
1 parent
318db8e
commit 7fb8128
Showing
6 changed files
with
111 additions
and
12 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
43 changes: 43 additions & 0 deletions
43
...react/renderer/imagemanager/platform/android/react/renderer/imagemanager/ImageFetcher.cpp
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,43 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "ImageFetcher.h" | ||
#include <react/renderer/imagemanager/conversions.h> | ||
|
||
namespace facebook::react { | ||
|
||
ImageRequest ImageFetcher::requestImage( | ||
const ImageSource& imageSource, | ||
const ImageRequestParams& imageRequestParams, | ||
SurfaceId surfaceId, | ||
Tag tag) const { | ||
auto fabricUIManager_ = | ||
contextContainer_->at<jni::global_ref<jobject>>("FabricUIManager"); | ||
static auto requestImage = | ||
fabricUIManager_->getClass() | ||
->getMethod<void( | ||
std::string, SurfaceId, Tag, JReadableMapBuffer::javaobject)>( | ||
"experimental_prefetchResource"); | ||
|
||
auto serializedImageRequest = | ||
serializeImageRequest(imageSource, imageRequestParams); | ||
|
||
auto readableMapBuffer = | ||
JReadableMapBuffer::createWithContents(std::move(serializedImageRequest)); | ||
|
||
requestImage( | ||
fabricUIManager_, | ||
"RCTImageView", | ||
surfaceId, | ||
tag, | ||
readableMapBuffer.get()); | ||
|
||
auto telemetry = std::make_shared<ImageTelemetry>(surfaceId); | ||
|
||
return {imageSource, telemetry}; | ||
} | ||
} // namespace facebook::react |
36 changes: 36 additions & 0 deletions
36
...n/react/renderer/imagemanager/platform/android/react/renderer/imagemanager/ImageFetcher.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,36 @@ | ||
/* | ||
* 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 <fbjni/fbjni.h> | ||
|
||
#include <react/common/mapbuffer/JReadableMapBuffer.h> | ||
#include <react/jni/ReadableNativeMap.h> | ||
#include <react/renderer/imagemanager/ImageRequest.h> | ||
#include <react/renderer/imagemanager/ImageRequestParams.h> | ||
#include <react/utils/ContextContainer.h> | ||
|
||
#include <utility> | ||
|
||
namespace facebook::react { | ||
|
||
class ImageFetcher { | ||
public: | ||
ImageFetcher(ContextContainer::Shared contextContainer) | ||
: contextContainer_(std::move(contextContainer)) {} | ||
|
||
ImageRequest requestImage( | ||
const ImageSource& imageSource, | ||
const ImageRequestParams& imageRequestParams, | ||
SurfaceId surfaceId, | ||
Tag tag) const; | ||
|
||
private: | ||
ContextContainer::Shared contextContainer_; | ||
}; | ||
} // 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