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
6ccfab2c
"Examples/VideoBlur/ios/VideoBlur.xcodeproj/project.pbxproj" did not exist on "23fbee5e1c00d6000d6d8ff9aeb2511614f8758d"
Commit
6ccfab2c
authored
Sep 14, 2015
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add onLoad and onProgress events
parent
66ea4f47
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
11 deletions
+59
-11
Examples/Tests/index.ios.js
Examples/Tests/index.ios.js
+16
-4
RNGL/GLCanvas.h
RNGL/GLCanvas.h
+3
-1
RNGL/GLCanvas.m
RNGL/GLCanvas.m
+38
-6
RNGL/GLCanvasManager.m
RNGL/GLCanvasManager.m
+2
-0
No files found.
Examples/Tests/index.ios.js
View file @
6ccfab2c
...
@@ -13,8 +13,20 @@ const HelloGL = require("./HelloGL");
...
@@ -13,8 +13,20 @@ const HelloGL = require("./HelloGL");
const
Display2
=
require
(
"
./Display2
"
);
const
Display2
=
require
(
"
./Display2
"
);
const
{
width
:
viewportW
,
height
:
viewportH
}
=
require
(
"
Dimensions
"
).
get
(
"
window
"
);
const
{
width
:
viewportW
,
height
:
viewportH
}
=
require
(
"
Dimensions
"
).
get
(
"
window
"
);
const
Tests
=
React
.
createClass
({
class
Tests
extends
React
.
Component
{
render
:
function
()
{
constructor
(
props
)
{
super
(
props
);
this
.
onLoad
=
this
.
onLoad
.
bind
(
this
);
this
.
onProgress
=
this
.
onProgress
.
bind
(
this
);
}
onLoad
()
{
console
.
log
(
"
LOADED
"
);
}
onProgress
({
nativeEvent
:
{
progress
,
loaded
,
total
}})
{
console
.
log
(
"
PROGRESS
"
,
progress
,
loaded
,
total
);
}
render
()
{
const
helloGL
=
const
helloGL
=
<
HelloGL
width
=
{
64
}
height
=
{
64
}
/>
;
<
HelloGL
width
=
{
64
}
height
=
{
64
}
/>
;
...
@@ -48,7 +60,7 @@ const Tests = React.createClass({
...
@@ -48,7 +60,7 @@ const Tests = React.createClass({
<
/Layer>
;
<
/Layer>
;
return
<
View
style
=
{{
backgroundColor
:
"
#000
"
}}
>
return
<
View
style
=
{{
backgroundColor
:
"
#000
"
}}
>
<
Display2
width
=
{
viewportW
}
height
=
{
viewportH
}
vertical
preload
>
<
Display2
width
=
{
viewportW
}
height
=
{
viewportH
}
vertical
preload
onLoad
=
{
this
.
onLoad
}
onProgress
=
{
this
.
onProgress
}
>
<
Display2
width
=
{
viewportW
}
height
=
{
viewportH
/
2
}
>
<
Display2
width
=
{
viewportW
}
height
=
{
viewportH
/
2
}
>
<
Add
width
=
{
viewportW
/
2
}
height
=
{
viewportH
/
2
}
>
<
Add
width
=
{
viewportW
/
2
}
height
=
{
viewportH
/
2
}
>
{
txt
}
{
txt
}
...
@@ -68,6 +80,6 @@ const Tests = React.createClass({
...
@@ -68,6 +80,6 @@ const Tests = React.createClass({
<
/Display2
>
<
/Display2
>
<
/View>
;
<
/View>
;
}
}
}
);
}
AppRegistry
.
registerComponent
(
"
Tests
"
,
()
=>
Tests
);
AppRegistry
.
registerComponent
(
"
Tests
"
,
()
=>
Tests
);
RNGL/GLCanvas.h
View file @
6ccfab2c
...
@@ -8,8 +8,10 @@
...
@@ -8,8 +8,10 @@
@property
(
nonatomic
)
NSNumber
*
nbContentTextures
;
@property
(
nonatomic
)
NSNumber
*
nbContentTextures
;
@property
(
nonatomic
)
NSNumber
*
renderId
;
@property
(
nonatomic
)
NSNumber
*
renderId
;
@property
(
nonatomic
)
NSArray
*
imagesToPreload
;
@property
(
nonatomic
)
NSArray
*
imagesToPreload
;
@property
(
nonatomic
,
assign
)
BOOL
onProgress
;
@property
(
nonatomic
,
assign
)
BOOL
onLoad
;
-
(
instancetype
)
initWithBridge
:(
RCTBridge
*
)
bridge
-
(
instancetype
)
initWithBridge
:(
RCTBridge
*
)
bridge
withContext
:(
EAGLContext
*
)
context
;
withContext
:(
EAGLContext
*
)
context
;
@end
@end
RNGL/GLCanvas.m
View file @
6ccfab2c
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#import "RCTBridge.h"
#import "RCTBridge.h"
#import "RCTUtils.h"
#import "RCTUtils.h"
#import "RCTConvert.h"
#import "RCTConvert.h"
#import "RCTEventDispatcher.h"
#import "RCTLog.h"
#import "RCTLog.h"
#import "GLCanvas.h"
#import "GLCanvas.h"
#import "GLShader.h"
#import "GLShader.h"
...
@@ -9,6 +10,7 @@
...
@@ -9,6 +10,7 @@
#import "GLTexture.h"
#import "GLTexture.h"
#import "GLImage.h"
#import "GLImage.h"
#import "GLRenderData.h"
#import "GLRenderData.h"
#import "UIView+React.h"
// For reference, see implementation of gl-shader's GLCanvas
// For reference, see implementation of gl-shader's GLCanvas
...
@@ -32,7 +34,7 @@
...
@@ -32,7 +34,7 @@
}
}
-
(
instancetype
)
initWithBridge
:(
RCTBridge
*
)
bridge
-
(
instancetype
)
initWithBridge
:(
RCTBridge
*
)
bridge
withContext
:(
EAGLContext
*
)
context
withContext
:(
EAGLContext
*
)
context
{
{
if
((
self
=
[
super
init
]))
{
if
((
self
=
[
super
init
]))
{
_bridge
=
bridge
;
_bridge
=
bridge
;
...
@@ -50,11 +52,35 @@ RCT_NOT_IMPLEMENTED(-init)
...
@@ -50,11 +52,35 @@ RCT_NOT_IMPLEMENTED(-init)
{
{
if
(
_preloadingDone
)
return
;
if
(
_preloadingDone
)
return
;
if
([
imagesToPreload
count
]
==
0
)
{
if
([
imagesToPreload
count
]
==
0
)
{
[
self
dispatchOnLoad
];
_preloadingDone
=
true
;
_preloadingDone
=
true
;
}
}
else
{
_preloadingDone
=
false
;
}
_imagesToPreload
=
imagesToPreload
;
_imagesToPreload
=
imagesToPreload
;
}
}
-
(
void
)
dispatchOnLoad
{
if
(
_onLoad
)
{
[
_bridge
.
eventDispatcher
sendInputEventWithName
:
@"load"
body
:@{
@"target"
:
self
.
reactTag
}];
}
}
-
(
void
)
dispatchOnProgress
:
(
double
)
progress
withLoaded
:(
int
)
loaded
withTotal
:(
int
)
total
{
if
(
_onProgress
)
{
NSDictionary
*
event
=
@{
@"target"
:
self
.
reactTag
,
@"progress"
:
@
(
progress
),
@"loaded"
:
@
(
loaded
),
@"total"
:
@
(
total
)
};
[
_bridge
.
eventDispatcher
sendInputEventWithName
:
@"progress"
body
:
event
];
}
}
-
(
void
)
setOpaque
:(
BOOL
)
opaque
-
(
void
)
setOpaque
:(
BOOL
)
opaque
{
{
_opaque
=
opaque
;
_opaque
=
opaque
;
...
@@ -203,20 +229,26 @@ NSString* srcResource (id res)
...
@@ -203,20 +229,26 @@ NSString* srcResource (id res)
}
}
}
}
-
(
bool
)
all
Preloaded
-
(
int
)
count
Preloaded
{
{
int
nb
=
0
;
for
(
id
toload
in
_imagesToPreload
)
{
for
(
id
toload
in
_imagesToPreload
)
{
if
(
!
[
_preloaded
containsObject
:
srcResource
(
toload
)])
if
([
_preloaded
containsObject
:
srcResource
(
toload
)])
return
false
;
nb
++
;
}
}
return
true
;
return
nb
;
}
}
-
(
void
)
onImageLoad
:(
NSString
*
)
loaded
-
(
void
)
onImageLoad
:(
NSString
*
)
loaded
{
{
if
(
!
_preloadingDone
)
{
if
(
!
_preloadingDone
)
{
[
_preloaded
addObject
:
loaded
];
[
_preloaded
addObject
:
loaded
];
if
([
self
allPreloaded
])
{
int
count
=
[
self
countPreloaded
];
int
total
=
(
int
)
[
_imagesToPreload
count
];
double
progress
=
((
double
)
count
)
/
((
double
)
total
);
[
self
dispatchOnProgress
:
progress
withLoaded
:
count
withTotal
:
total
];
if
(
count
==
total
)
{
[
self
dispatchOnLoad
];
_preloadingDone
=
true
;
_preloadingDone
=
true
;
[
self
requestSyncData
];
[
self
requestSyncData
];
}
}
...
...
RNGL/GLCanvasManager.m
View file @
6ccfab2c
...
@@ -23,6 +23,8 @@ RCT_EXPORT_VIEW_PROPERTY(opaque, BOOL);
...
@@ -23,6 +23,8 @@ RCT_EXPORT_VIEW_PROPERTY(opaque, BOOL);
RCT_EXPORT_VIEW_PROPERTY
(
data
,
GLData
);
RCT_EXPORT_VIEW_PROPERTY
(
data
,
GLData
);
RCT_EXPORT_VIEW_PROPERTY
(
renderId
,
NSNumber
);
RCT_EXPORT_VIEW_PROPERTY
(
renderId
,
NSNumber
);
RCT_EXPORT_VIEW_PROPERTY
(
imagesToPreload
,
NSArray
);
RCT_EXPORT_VIEW_PROPERTY
(
imagesToPreload
,
NSArray
);
RCT_EXPORT_VIEW_PROPERTY
(
onLoad
,
BOOL
);
RCT_EXPORT_VIEW_PROPERTY
(
onProgress
,
BOOL
);
-
(
UIView
*
)
view
-
(
UIView
*
)
view
{
{
...
...
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