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
ca1d7889
Commit
ca1d7889
authored
Nov 13, 2015
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
216d445a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
17 deletions
+39
-17
android/src/main/java/com/projectseptember/RNGL/GLCanvas.java
...oid/src/main/java/com/projectseptember/RNGL/GLCanvas.java
+10
-11
android/src/main/java/com/projectseptember/RNGL/GLFBO.java
android/src/main/java/com/projectseptember/RNGL/GLFBO.java
+1
-1
android/src/main/java/com/projectseptember/RNGL/GLImage.java
android/src/main/java/com/projectseptember/RNGL/GLImage.java
+10
-4
android/src/main/java/com/projectseptember/RNGL/GLShader.java
...oid/src/main/java/com/projectseptember/RNGL/GLShader.java
+0
-1
android/src/main/java/com/projectseptember/RNGL/GLShaderData.java
...src/main/java/com/projectseptember/RNGL/GLShaderData.java
+13
-0
android/src/main/java/com/projectseptember/RNGL/RunInGLThread.java
...rc/main/java/com/projectseptember/RNGL/RunInGLThread.java
+5
-0
No files found.
android/src/main/java/com/projectseptember/RNGL/GLCanvas.java
View file @
ca1d7889
...
@@ -32,7 +32,7 @@ import java.util.logging.Logger;
...
@@ -32,7 +32,7 @@ import java.util.logging.Logger;
import
javax.microedition.khronos.egl.EGLConfig
;
import
javax.microedition.khronos.egl.EGLConfig
;
import
javax.microedition.khronos.opengles.GL10
;
import
javax.microedition.khronos.opengles.GL10
;
public
class
GLCanvas
extends
GLSurfaceView
implements
GLSurfaceView
.
Renderer
{
public
class
GLCanvas
extends
GLSurfaceView
implements
GLSurfaceView
.
Renderer
,
RunInGLThread
{
private
static
final
Logger
logger
=
Logger
.
getLogger
(
GLCanvas
.
class
.
getName
());
private
static
final
Logger
logger
=
Logger
.
getLogger
(
GLCanvas
.
class
.
getName
());
...
@@ -58,6 +58,9 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
...
@@ -58,6 +58,9 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
private
Map
<
String
,
GLImage
>
images
=
new
HashMap
<>();
private
Map
<
String
,
GLImage
>
images
=
new
HashMap
<>();
private
List
<
GLTexture
>
contentTextures
=
new
ArrayList
<>();
private
List
<
GLTexture
>
contentTextures
=
new
ArrayList
<>();
private
Map
<
Integer
,
GLShader
>
shaders
=
new
HashMap
<>();
private
Map
<
Integer
,
GLFBO
>
fbos
=
new
HashMap
<>();
public
GLCanvas
(
ThemedReactContext
context
)
{
public
GLCanvas
(
ThemedReactContext
context
)
{
super
(
context
);
super
(
context
);
reactContext
=
context
;
reactContext
=
context
;
...
@@ -113,8 +116,8 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
...
@@ -113,8 +116,8 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
}
}
public
void
setNbContentTextures
(
int
nbContentTextures
)
{
public
void
setNbContentTextures
(
int
nbContentTextures
)
{
resizeUniformContentTextures
(
nbContentTextures
);
this
.
nbContentTextures
=
nbContentTextures
;
this
.
nbContentTextures
=
nbContentTextures
;
// TODO: resize uniform content textures
}
}
public
void
setRenderId
(
int
renderId
)
{
public
void
setRenderId
(
int
renderId
)
{
...
@@ -195,7 +198,7 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
...
@@ -195,7 +198,7 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
// Sync methods
// Sync methods
private
final
Queue
<
Runnable
>
mRunOnDraw
=
new
LinkedList
<>();
private
final
Queue
<
Runnable
>
mRunOnDraw
=
new
LinkedList
<>();
p
rotected
void
runOnDraw
(
final
Runnable
runnable
)
{
p
ublic
void
runInGLThread
(
final
Runnable
runnable
)
{
synchronized
(
mRunOnDraw
)
{
synchronized
(
mRunOnDraw
)
{
mRunOnDraw
.
add
(
runnable
);
mRunOnDraw
.
add
(
runnable
);
requestRender
();
requestRender
();
...
@@ -210,7 +213,7 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
...
@@ -210,7 +213,7 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
}
}
public
void
requestSyncData
()
{
public
void
requestSyncData
()
{
run
OnDraw
(
new
Runnable
()
{
run
InGLThread
(
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
if
(
ensureCompiledShader
(
data
))
if
(
ensureCompiledShader
(
data
))
syncData
();
syncData
();
...
@@ -349,16 +352,11 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
...
@@ -349,16 +352,11 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
images
.
put
(
src
,
image
);
images
.
put
(
src
,
image
);
}
}
if
(
image
==
null
)
{
if
(
image
==
null
)
{
image
=
new
GLImage
(
reactContext
.
getApplicationContext
(),
new
Runnable
()
{
image
=
new
GLImage
(
reactContext
.
getApplicationContext
(),
this
,
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
onImageLoad
(
src
);
onImageLoad
(
src
);
}
}
});
// TODO bind on load
});
/*
[[GLImage alloc] initWithBridge:_bridge withOnLoad:^{
if (weakSelf) [weakSelf onImageLoad:src];
}];
*/
image
.
setSrc
(
src
);
image
.
setSrc
(
src
);
images
.
put
(
src
,
image
);
images
.
put
(
src
,
image
);
}
}
...
@@ -576,6 +574,7 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
...
@@ -576,6 +574,7 @@ public class GLCanvas extends GLSurfaceView implements GLSurfaceView.Renderer {
public
void
syncEventsThrough
()
{
public
void
syncEventsThrough
()
{
// TODO: figure out how to do this (Obj C code below)
// TODO: figure out how to do this (Obj C code below)
// FIXME: probably we should just define {style} on JS side. check if there is support for touchEvents:"none"
//self.userInteractionEnabled = !(_eventsThrough);
//self.userInteractionEnabled = !(_eventsThrough);
//self.superview.userInteractionEnabled = !(_eventsThrough && !_visibleContent);
//self.superview.userInteractionEnabled = !(_eventsThrough && !_visibleContent);
}
}
...
...
android/src/main/java/com/projectseptember/RNGL/GLFBO.java
View file @
ca1d7889
...
@@ -6,7 +6,7 @@ import java.util.logging.Logger;
...
@@ -6,7 +6,7 @@ import java.util.logging.Logger;
import
static
android
.
opengl
.
GLES20
.*;
import
static
android
.
opengl
.
GLES20
.*;
public
class
GLFBO
{
// TODO
public
class
GLFBO
{
private
static
final
Logger
logger
=
Logger
.
getLogger
(
GLFBO
.
class
.
getName
());
private
static
final
Logger
logger
=
Logger
.
getLogger
(
GLFBO
.
class
.
getName
());
public
final
List
<
GLTexture
>
color
=
new
ArrayList
<>();
public
final
List
<
GLTexture
>
color
=
new
ArrayList
<>();
...
...
android/src/main/java/com/projectseptember/RNGL/GLImage.java
View file @
ca1d7889
...
@@ -37,10 +37,12 @@ public class GLImage {
...
@@ -37,10 +37,12 @@ public class GLImage {
private
boolean
isDirty
;
private
boolean
isDirty
;
private
AsyncTask
<
Void
,
Void
,
Bitmap
>
task
;
private
AsyncTask
<
Void
,
Void
,
Bitmap
>
task
;
private
Runnable
onload
;
private
Runnable
onload
;
private
RunInGLThread
glScheduler
;
public
GLImage
(
Context
context
,
Runnable
onload
)
{
public
GLImage
(
Context
context
,
Run
InGLThread
glScheduler
,
Run
nable
onload
)
{
this
.
context
=
context
;
this
.
context
=
context
;
this
.
onload
=
onload
;
this
.
onload
=
onload
;
this
.
glScheduler
=
glScheduler
;
this
.
texture
=
new
GLTexture
();
this
.
texture
=
new
GLTexture
();
}
}
...
@@ -72,9 +74,13 @@ public class GLImage {
...
@@ -72,9 +74,13 @@ public class GLImage {
isDirty
=
true
;
isDirty
=
true
;
}
}
public
void
onLoad
(
Bitmap
bitmap
)
{
public
void
onLoad
(
final
Bitmap
bitmap
)
{
texture
.
setPixels
(
bitmap
);
glScheduler
.
runInGLThread
(
new
Runnable
()
{
this
.
onload
.
run
();
public
void
run
()
{
texture
.
setPixels
(
bitmap
);
onload
.
run
();
}
});
}
}
public
GLTexture
getTexture
()
{
public
GLTexture
getTexture
()
{
...
...
android/src/main/java/com/projectseptember/RNGL/GLShader.java
View file @
ca1d7889
...
@@ -27,7 +27,6 @@ public class GLShader {
...
@@ -27,7 +27,6 @@ public class GLShader {
this
.
name
=
name
;
this
.
name
=
name
;
this
.
vert
=
vert
;
this
.
vert
=
vert
;
this
.
frag
=
frag
;
this
.
frag
=
frag
;
makeProgram
();
}
}
@Override
@Override
...
...
android/src/main/java/com/projectseptember/RNGL/GLShaderData.java
0 → 100644
View file @
ca1d7889
package
com.projectseptember.RNGL
;
public
class
GLShaderData
{
public
final
String
name
;
public
final
String
vert
;
public
final
String
frag
;
public
GLShaderData
(
String
name
,
String
vert
,
String
frag
)
{
this
.
name
=
name
;
this
.
vert
=
vert
;
this
.
frag
=
frag
;
}
}
android/src/main/java/com/projectseptember/RNGL/RunInGLThread.java
0 → 100644
View file @
ca1d7889
package
com.projectseptember.RNGL
;
public
interface
RunInGLThread
{
public
void
runInGLThread
(
final
Runnable
runnable
);
}
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