mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
iOS: added helper functions to gate image instrumentations
Summary: Introduced 2 helper functions to toggle image instrumentation/logging (not in this diff) so that gating check is more efficient and easy to access across RN iOS core. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D18597208 fbshipit-source-id: 0b22031802ab020b16d6fb63e52461cf80a37ab5
This commit is contained in:
committed by
Facebook Github Bot
parent
5ee8202b26
commit
65a7ec4473
@@ -8,6 +8,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTDefines.h>
|
||||
#import <React/RCTResizeMode.h>
|
||||
#import <React/RCTURLRequestHandler.h>
|
||||
#import <React/RCTImageDataDecoder.h>
|
||||
@@ -15,6 +16,11 @@
|
||||
#import <React/RCTImageCache.h>
|
||||
#import <React/RCTImageLoaderProtocol.h>
|
||||
|
||||
RCT_EXTERN BOOL RCTImageLoadingInstrumentationEnabled(void);
|
||||
RCT_EXTERN BOOL RCTImageLoadingPerfInstrumentationEnabled(void);
|
||||
RCT_EXTERN void RCTEnableImageLoadingInstrumentation(BOOL enabled);
|
||||
RCT_EXTERN void RCTEnableImageLoadingPerfInstrumentation(BOOL enabled);
|
||||
|
||||
@interface RCTImageLoader : NSObject <RCTBridgeModule, RCTImageLoaderProtocol>
|
||||
- (instancetype)init;
|
||||
- (instancetype)initWithRedirectDelegate:(id<RCTImageRedirectProtocol>)redirectDelegate NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@@ -25,6 +25,29 @@
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
static BOOL imageInstrumentationEnabled = NO;
|
||||
static BOOL imagePerfInstrumentationEnabled = NO;
|
||||
|
||||
BOOL RCTImageLoadingInstrumentationEnabled(void)
|
||||
{
|
||||
return imageInstrumentationEnabled;
|
||||
}
|
||||
|
||||
BOOL RCTImageLoadingPerfInstrumentationEnabled(void)
|
||||
{
|
||||
return imagePerfInstrumentationEnabled;
|
||||
}
|
||||
|
||||
void RCTEnableImageLoadingInstrumentation(BOOL enabled)
|
||||
{
|
||||
imageInstrumentationEnabled = enabled;
|
||||
}
|
||||
|
||||
void RCTEnableImageLoadingPerfInstrumentation(BOOL enabled)
|
||||
{
|
||||
imagePerfInstrumentationEnabled = enabled;
|
||||
}
|
||||
|
||||
static NSInteger RCTImageBytesForImage(UIImage *image)
|
||||
{
|
||||
NSInteger singleImageBytes = image.size.width * image.size.height * image.scale * image.scale * 4;
|
||||
|
||||
Reference in New Issue
Block a user