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
3467ef10
Commit
3467ef10
authored
Feb 16, 2016
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for
https://github.com/ProjectSeptemberInc/gl-react/issues/33
parent
333e382a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
90 deletions
+69
-90
example/src/Tests/NativeLayer.js
example/src/Tests/NativeLayer.js
+1
-1
example/src/Tests/index.js
example/src/Tests/index.js
+8
-85
example/src/index.js
example/src/index.js
+24
-1
src/GLCanvas.js
src/GLCanvas.js
+36
-3
No files found.
example/src/Tests/NativeLayer.js
View file @
3467ef10
...
@@ -6,7 +6,7 @@ const {
...
@@ -6,7 +6,7 @@ const {
class
NativeLayer
extends
React
.
Component
{
class
NativeLayer
extends
React
.
Component
{
render
()
{
render
()
{
const
{
width
,
height
,
children
,
...
rest
}
=
this
.
props
;
const
{
width
,
height
,
children
,
...
rest
}
=
this
.
props
;
return
<
View
style
=
{{
width
,
height
,
position
:
"
relative
"
}}
>
return
<
View
style
=
{{
width
,
height
,
position
:
"
relative
"
,
overflow
:
"
hidden
"
}}
>
{
React
.
Children
.
map
(
children
,
child
=>
{
React
.
Children
.
map
(
children
,
child
=>
<
View
style
=
{{
width
,
height
,
position
:
"
absolute
"
,
top
:
0
,
left
:
0
,
backgroundColor
:
"
transparent
"
}}
>
<
View
style
=
{{
width
,
height
,
position
:
"
absolute
"
,
top
:
0
,
left
:
0
,
backgroundColor
:
"
transparent
"
}}
>
{
child
}
{
child
}
...
...
example/src/Tests/index.js
View file @
3467ef10
...
@@ -31,14 +31,14 @@ class Tests extends React.Component {
...
@@ -31,14 +31,14 @@ class Tests extends React.Component {
console
.
log
(
"
PROGRESS
"
,
progress
,
loaded
,
total
);
console
.
log
(
"
PROGRESS
"
,
progress
,
loaded
,
total
);
}
}
render
()
{
render
()
{
const
debugSize
=
viewportW
/
2
;
const
debugSize
=
viewportW
/
4
;
const
helloGL
=
const
helloGL
=
<
HelloGL
width
=
{
64
}
height
=
{
64
}
/>
;
<
HelloGL
width
=
{
64
}
height
=
{
64
}
/>
;
const
txt
=
const
txt
=
<
View
style
=
{{
width
:
400
,
height
:
400
,
position
:
"
relative
"
,
backgroundColor
:
"
transparent
"
}}
>
<
View
style
=
{{
width
:
400
,
height
:
400
,
position
:
"
relative
"
,
backgroundColor
:
"
transparent
"
}}
>
{[
0
,
1
,
2
,
3
].
map
(
i
=>
<
Text
style
=
{{
{[
0
,
1
,
2
,
3
].
map
(
i
=>
<
Text
key
=
{
i
}
style
=
{{
position
:
"
absolute
"
,
position
:
"
absolute
"
,
top
:
20
+
100
*
i
,
top
:
20
+
100
*
i
,
left
:
0
,
left
:
0
,
...
@@ -87,44 +87,6 @@ class Tests extends React.Component {
...
@@ -87,44 +87,6 @@ class Tests extends React.Component {
<
View
style
=
{{
flexDirection
:
"
row
"
,
flexWrap
:
"
wrap
"
}}
>
<
View
style
=
{{
flexDirection
:
"
row
"
,
flexWrap
:
"
wrap
"
}}
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/mp79p5T.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
/NativeLayer
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
opaque
=
{
false
}
>
<
Copy
last
>
http
:
//i.imgur.com/mp79p5T.png
<
/Copy
>
<
/Surface
>
<
/NativeLayer
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
opaque
=
{
false
}
>
<
Copy
last
>
<
Copy
>
http
:
//i.imgur.com/mp79p5T.png
<
/Copy
>
<
/Copy
>
<
/Surface
>
<
/NativeLayer
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
opaque
=
{
false
}
>
<
Copy
last
>
<
Copy
>
<
Copy
>
http
:
//i.imgur.com/mp79p5T.png
<
/Copy
>
<
/Copy
>
<
/Copy
>
<
/Surface
>
<
/NativeLayer
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
opaque
=
{
false
}
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
opaque
=
{
false
}
>
...
@@ -142,52 +104,9 @@ class Tests extends React.Component {
...
@@ -142,52 +104,9 @@ class Tests extends React.Component {
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
opaque
=
{
false
}
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Copy
last
>
<
Copy
>
<
Copy
>
<
Copy
>
<
Copy
>
http
:
//i.imgur.com/mp79p5T.png
<
/Copy
>
<
/Copy
>
<
/Copy
>
<
/Copy
>
<
/Copy
>
<
/Surface
>
<
/NativeLayer
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
NativeLayer
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/mp79p5T.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/mp79p5T.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
opaque
=
{
false
}
>
<
TransparentNonPremultiplied
>
<
HelloGL
/>
<
/TransparentNonPremultiplied
>
<
/Surface
>
<
/NativeLayer
>
<
/NativeLayer
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
NativeLayer
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/mp79p5T.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
TransparentNonPremultiplied
>
<
TransparentNonPremultiplied
>
<
HelloGL
/>
<
/TransparentNonPremultiplied
>
<
/TransparentNonPremultiplied
>
<
/Surface
>
<
/NativeLayer
>
<
/NativeLayer
>
<
NativeLayer
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/S22HNaU.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
NativeLayer
>
<
Image
source
=
{{
uri
:
"
http://i.imgur.com/mp79p5T.png
"
}}
width
=
{
debugSize
}
height
=
{
debugSize
}
/
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
TransparentNonPremultiplied
>
<
TransparentNonPremultiplied
>
<
Copy
>
<
Copy
>
<
TransparentNonPremultiplied
>
<
TransparentNonPremultiplied
>
...
@@ -231,6 +150,10 @@ class Tests extends React.Component {
...
@@ -231,6 +150,10 @@ class Tests extends React.Component {
<
/Surface
>
<
/Surface
>
<
/NativeLayer
>
<
/NativeLayer
>
<
Surface
width
=
{
debugSize
}
height
=
{
debugSize
}
>
<
HelloGL
width
=
{
2
}
height
=
{
2
}
pixelRatio
=
{
1
}
/
>
<
/Surface
>
<
/View
>
<
/View
>
<
/ScrollView>
;
<
/ScrollView>
;
...
...
example/src/index.js
View file @
3467ef10
...
@@ -6,6 +6,7 @@ import React, {
...
@@ -6,6 +6,7 @@ import React, {
Text
,
Text
,
TouchableOpacity
,
TouchableOpacity
,
Navigator
,
Navigator
,
AsyncStorage
,
}
from
"
react-native
"
;
}
from
"
react-native
"
;
const
screens
=
{
const
screens
=
{
...
@@ -77,6 +78,26 @@ class Home extends Component {
...
@@ -77,6 +78,26 @@ class Home extends Component {
export
default
class
App
extends
Component
{
export
default
class
App
extends
Component
{
static
propTypes
=
{};
static
propTypes
=
{};
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
initialRoute
:
homeRoute
};
/*
new Promise((success, failure) =>
AsyncStorage.getItem("route", (error, result) => {
if (error) failure(error);
else success(result);
}))
.then(result => {
const route = JSON.parse(result);
if (!route) throw new Error("invalid route");
return route;
})
.catch(() => homeRoute)
.then(initialRoute => this.setState({ initialRoute }));
*/
}
renderScene
=
(
route
,
navigator
)
=>
{
renderScene
=
(
route
,
navigator
)
=>
{
if
(
route
.
id
===
homeRoute
.
id
)
{
if
(
route
.
id
===
homeRoute
.
id
)
{
return
<
Home
openScreen
=
{
route
=>
navigator
.
push
(
route
)}
/>
;
return
<
Home
openScreen
=
{
route
=>
navigator
.
push
(
route
)}
/>
;
...
@@ -85,12 +106,14 @@ export default class App extends Component {
...
@@ -85,12 +106,14 @@ export default class App extends Component {
return
<
Screen
/>
;
return
<
Screen
/>
;
};
};
render
()
{
render
()
{
const
{
initialRoute
}
=
this
.
state
;
if
(
!
initialRoute
)
return
<
View
/>
;
return
(
return
(
<
View
style
=
{
styles
.
root
}
>
<
View
style
=
{
styles
.
root
}
>
<
Navigator
<
Navigator
style
=
{
styles
.
navBar
}
style
=
{
styles
.
navBar
}
initialRoute
=
{
homeRoute
}
renderScene
=
{
this
.
renderScene
}
renderScene
=
{
this
.
renderScene
}
initialRoute
=
{
initialRoute
}
navigationBar
=
{
navigationBar
=
{
<
Navigator
.
NavigationBar
<
Navigator
.
NavigationBar
routeMapper
=
{{
routeMapper
=
{{
...
...
src/GLCanvas.js
View file @
3467ef10
...
@@ -2,7 +2,7 @@ const invariant = require("invariant");
...
@@ -2,7 +2,7 @@ const invariant = require("invariant");
const
React
=
require
(
"
react-native
"
);
const
React
=
require
(
"
react-native
"
);
const
{
const
{
Component
,
Component
,
requireNativeComponent
requireNativeComponent
,
}
=
React
;
}
=
React
;
const
defer
=
require
(
"
promise-defer
"
);
const
defer
=
require
(
"
promise-defer
"
);
const
captureFrame
=
require
(
"
./GLCanvas.captureFrame
"
);
const
captureFrame
=
require
(
"
./GLCanvas.captureFrame
"
);
...
@@ -18,6 +18,35 @@ const GLCanvasNative = requireNativeComponent("GLCanvas", GLCanvas, {
...
@@ -18,6 +18,35 @@ const GLCanvasNative = requireNativeComponent("GLCanvas", GLCanvas, {
}
}
});
});
const
getExtraProps
=
({
width
,
height
,
pixelRatio
,
data
})
=>
{
// If Surface size matches the root node size, pass-in the styles
if
(
!
data
||
width
*
pixelRatio
===
data
.
width
*
data
.
pixelRatio
&&
height
*
pixelRatio
===
data
.
height
*
data
.
pixelRatio
)
{
return
{
pixelRatio
,
style
:
{
width
,
height
}
};
}
// otherwise, stretch the canvas to the surface size
const
w
=
data
.
width
*
data
.
pixelRatio
;
const
h
=
data
.
height
*
data
.
pixelRatio
;
return
{
pixelRatio
:
1
,
// pixelRatio is hardcoded to 1 to normalize the transform
style
:
{
width
:
w
,
height
:
h
,
transform
:
[
{
translateX
:
-
w
/
2
},
{
translateY
:
-
h
/
2
},
{
scaleX
:
width
/
w
},
{
scaleY
:
height
/
h
},
{
translateX
:
w
/
2
},
{
translateY
:
h
/
2
},
]
}
};
};
class
GLCanvas
extends
Component
{
class
GLCanvas
extends
Component
{
componentWillMount
()
{
componentWillMount
()
{
...
@@ -103,15 +132,19 @@ class GLCanvas extends Component {
...
@@ -103,15 +132,19 @@ class GLCanvas extends Component {
};
};
render
()
{
render
()
{
const
{
width
,
height
,
onLoad
,
onProgress
,
eventsThrough
,
...
restProps
}
=
this
.
props
;
const
{
width
,
height
,
pixelRatio
,
data
,
onLoad
,
onProgress
,
eventsThrough
,
...
restProps
}
=
this
.
props
;
return
<
GLCanvasNative
return
<
GLCanvasNative
ref
=
"
native
"
ref
=
"
native
"
{...
restProps
}
{...
restProps
}
{...
getExtraProps
({
width
,
height
,
pixelRatio
,
data
})}
data
=
{
data
}
onGLLoad
=
{
onLoad
?
onLoad
:
null
}
onGLLoad
=
{
onLoad
?
onLoad
:
null
}
onGLProgress
=
{
onProgress
?
onProgress
:
null
}
onGLProgress
=
{
onProgress
?
onProgress
:
null
}
onGLCaptureFrame
=
{
this
.
onGLCaptureFrame
}
onGLCaptureFrame
=
{
this
.
onGLCaptureFrame
}
pointerEvents
=
{
eventsThrough
?
"
none
"
:
"
auto
"
}
pointerEvents
=
{
eventsThrough
?
"
none
"
:
"
auto
"
}
style
=
{{
width
,
height
}}
/>
;
/>
;
}
}
}
}
...
...
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