mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Storing ImageLoader (instead of ImageManager) in ContextConteiner
Summary: ImageLoader is an actual external dependency, not a ImageManager. That change allows to remove dependency on ImageManager from SurfacePresenter and make some other code simpler. Reviewed By: mdvacca Differential Revision: D15242047 fbshipit-source-id: 8622d15b8fdb5c3a7e25091adf7be1108f87ecd5
This commit is contained in:
committed by
Facebook Github Bot
parent
656c415f76
commit
8c0ba25f19
@@ -29,7 +29,6 @@
|
||||
#import <react/components/root/RootShadowNode.h>
|
||||
#import <react/core/LayoutConstraints.h>
|
||||
#import <react/core/LayoutContext.h>
|
||||
#import <react/imagemanager/ImageManager.h>
|
||||
#import <react/uimanager/ComponentDescriptorFactory.h>
|
||||
#import <react/utils/ContextContainer.h>
|
||||
#import <react/utils/ManagedObjectWrapper.h>
|
||||
@@ -245,7 +244,7 @@ using namespace facebook::react;
|
||||
|
||||
_contextContainer->registerInstance(runtimeExecutor, "runtime-executor");
|
||||
|
||||
_contextContainer->registerInstance(std::make_shared<ImageManager>((__bridge void *)[_bridge imageLoader]), "ImageManager");
|
||||
_contextContainer->registerInstance(wrapManagedObject([_bridge imageLoader]), "RCTImageLoader");
|
||||
return _contextContainer;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,19 +25,7 @@ class ImageComponentDescriptor final
|
||||
EventDispatcher::Shared eventDispatcher,
|
||||
ContextContainer::Shared const &contextContainer)
|
||||
: ConcreteComponentDescriptor(eventDispatcher),
|
||||
// TODO (39486757): implement image manager on Android, currently Android does
|
||||
// not have an ImageManager so this will crash
|
||||
#ifndef ANDROID
|
||||
imageManager_(
|
||||
contextContainer
|
||||
? contextContainer->getInstance<SharedImageManager>(
|
||||
"ImageManager")
|
||||
: nullptr) {
|
||||
}
|
||||
#else
|
||||
imageManager_(nullptr) {
|
||||
}
|
||||
#endif
|
||||
imageManager_(std::make_shared<ImageManager>(contextContainer)){};
|
||||
|
||||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
@@ -24,22 +24,11 @@ class SliderComponentDescriptor final
|
||||
EventDispatcher::Shared eventDispatcher,
|
||||
ContextContainer::Shared const &contextContainer)
|
||||
: ConcreteComponentDescriptor(eventDispatcher),
|
||||
// TODO (39486757): implement image manager on Android, currently Android does
|
||||
// not have an ImageManager so this will crash
|
||||
#ifndef ANDROID
|
||||
imageManager_(
|
||||
contextContainer
|
||||
? contextContainer->getInstance<SharedImageManager>(
|
||||
"ImageManager")
|
||||
: nullptr),
|
||||
#else
|
||||
imageManager_(nullptr),
|
||||
#endif
|
||||
imageManager_(std::make_shared<ImageManager>(contextContainer)),
|
||||
measurementsManager_(
|
||||
SliderMeasurementsManager::shouldMeasureSlider()
|
||||
? std::make_shared<SliderMeasurementsManager>(contextContainer)
|
||||
: nullptr) {
|
||||
}
|
||||
: nullptr) {}
|
||||
|
||||
void adopt(UnsharedShadowNode shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <react/imagemanager/ImageRequest.h>
|
||||
#include <react/imagemanager/primitives.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
@@ -24,7 +25,7 @@ using SharedImageManager = std::shared_ptr<ImageManager>;
|
||||
*/
|
||||
class ImageManager {
|
||||
public:
|
||||
ImageManager(void *platformSpecificCounterpart);
|
||||
ImageManager(ContextContainer::Shared const &contextContainer);
|
||||
~ImageManager();
|
||||
|
||||
ImageRequest requestImage(const ImageSource &imageSource) const;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ImageManager::ImageManager(void *platformSpecificCounterpart) {
|
||||
ImageManager::ImageManager(ContextContainer::Shared const &contextContainer) {
|
||||
// Silence unused-private-field warning.
|
||||
(void)self_;
|
||||
// Not implemented.
|
||||
|
||||
@@ -8,16 +8,18 @@
|
||||
#include "ImageManager.h"
|
||||
|
||||
#import <React/RCTImageLoader.h>
|
||||
#import <react/utils/ManagedObjectWrapper.h>
|
||||
|
||||
#import "RCTImageManager.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ImageManager::ImageManager(void *platformSpecificCounterpart) {
|
||||
self_ = (__bridge_retained void *)[[RCTImageManager alloc]
|
||||
initWithImageLoader:(__bridge RCTImageLoader *)
|
||||
platformSpecificCounterpart];
|
||||
ImageManager::ImageManager(ContextContainer::Shared const &contextContainer)
|
||||
{
|
||||
RCTImageLoader *imageLoader =
|
||||
(RCTImageLoader *)unwrapManagedObject(contextContainer->getInstance<std::shared_ptr<void>>("RCTImageLoader"));
|
||||
self_ = (__bridge_retained void *)[[RCTImageManager alloc] initWithImageLoader:imageLoader];
|
||||
}
|
||||
|
||||
ImageManager::~ImageManager() {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
#include <react/components/image/ImageComponentDescriptor.h>
|
||||
#include <react/components/rncore/ComponentDescriptors.h>
|
||||
#include <react/components/scrollview/ScrollViewComponentDescriptor.h>
|
||||
#include <react/components/view/ViewComponentDescriptor.h>
|
||||
@@ -33,9 +32,6 @@ ComponentRegistryFactory getDefaultComponentRegistryFactory() {
|
||||
auto registry = std::make_shared<ComponentDescriptorRegistry>();
|
||||
registry->registerComponentDescriptor(
|
||||
std::make_shared<ViewComponentDescriptor>(eventDispatcher));
|
||||
registry->registerComponentDescriptor(
|
||||
std::make_shared<ImageComponentDescriptor>(
|
||||
eventDispatcher, contextContainer));
|
||||
registry->registerComponentDescriptor(
|
||||
std::make_shared<ScrollViewComponentDescriptor>(eventDispatcher));
|
||||
registry->registerComponentDescriptor(
|
||||
|
||||
Reference in New Issue
Block a user