Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gl-react-native-v2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
gl-react-native-v2
Commits
9e11d627
Commit
9e11d627
authored
Mar 08, 2017
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example/ios/GLImage.m was accidentally committed
parent
d146e478
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
121 deletions
+0
-121
example/ios/GLImage.m
example/ios/GLImage.m
+0
-121
No files found.
example/ios/GLImage.m
deleted
100644 → 0
View file @
d146e478
#import <React/RCTBridge.h>
#import <React/RCTImageLoader.h>
#import <React/RCTLog.h>
#import <React/RCTUtils.h>
#import "GLImage.h"
#import "GLImageData.h"
#import "GLTexture.h"
@implementation
GLImage
{
RCTBridge
*
_bridge
;
// React's bridge allow to access the imageLoader
UIImage
*
_image
;
// The currently loaded image (nil if no image fully loaded yet)
GLImageData
*
_data
;
// Cache of the data related to this image (computed by getImageData)
GLTexture
*
_texture
;
// Cache of the texture
void
(
^
_onload
)(
void
);
// called everytime an image loads
RCTImageLoaderCancellationBlock
_loading
;
// the current loading cancellation function
}
-
(
instancetype
)
initWithBridge
:(
RCTBridge
*
)
bridge
withOnLoad
:(
void
(
^
)(
void
))
onload
{
if
((
self
=
[
super
init
]))
{
_bridge
=
bridge
;
_onload
=
onload
;
_image
=
nil
;
_loading
=
nil
;
_texture
=
[[
GLTexture
alloc
]
init
];
}
return
self
;
}
-
(
void
)
dealloc
{
[
self
clearImage
];
if
(
_loading
)
_loading
();
_onload
=
nil
;
_loading
=
nil
;
_bridge
=
nil
;
_texture
=
nil
;
}
RCT_NOT_IMPLEMENTED
(
-
init
)
-
(
void
)
clearImage
{
_image
=
nil
;
_data
=
nil
;
}
-
(
GLTexture
*
)
getTexture
{
if
(
_image
)
{
if
(
!
_data
)
{
_data
=
[
GLImageData
genPixelsWithImage
:
_image
];
}
[
_texture
setPixels
:
_data
];
}
else
{
[
_texture
setPixels
:
nil
];
}
return
_texture
;
}
-
(
void
)
setSource
:(
RCTImageSource
*
)
source
{
if
(
!
[
source
isEqual
:
_source
])
{
_source
=
source
;
[
self
reloadImage
];
}
}
-
(
void
)
reloadImage
{
RCTImageSource
*
source
=
_source
;
if
(
_loading
)
_loading
();
_loading
=
nil
;
if
(
!
source
)
{
[
self
clearImage
];
}
else
{
// Load the image (without resizing it)
__weak
GLImage
*
weakSelf
=
self
;
_loading
=
[
_bridge
.
imageLoader
loadImageWithURLRequest
:
source
.
request
size:
CGSizeZero
scale:
0
clipped:
YES
resizeMode:
RCTResizeModeStretch
progressBlock:
nil
partialLoadBlock:
nil
completionBlock:
^
(
NSError
*
error
,
UIImage
*
loadedImage
)
{
GLImage
*
strongSelf
=
weakSelf
;
void
(
^
setImageBlock
)(
UIImage
*
)
=
^
(
UIImage
*
image
)
{
if
(
!
[
source
isEqual
:
strongSelf
.
source
])
{
// Bail out if source has changed since we started loading
return
;
}
strongSelf
.
image
=
[
UIImage
imageWithCGImage
:
image
.
CGImage
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
_onload
)
_onload
();
});
};
_loading
=
nil
;
[
self
clearImage
];
if
(
error
)
{
NSLog
(
@"Image failed to load: %@"
,
error
);
}
else
{
if
([
NSThread
isMainThread
])
{
setImageBlock
(
loadedImage
);
}
else
{
RCTUnsafeExecuteOnMainQueueSync
(
^
{
setImageBlock
(
loadedImage
);
});
}
}
}];
}
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment