Commit ca1d7889 authored by Gaëtan Renaudeau's avatar Gaëtan Renaudeau

wip

parent 216d445a
...@@ -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<>();
protected void runOnDraw (final Runnable runnable) { public 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 () {
runOnDraw(new Runnable() { runInGLThread(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);
} }
......
...@@ -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<>();
......
...@@ -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, RunInGLThread glScheduler, Runnable 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) {
glScheduler.runInGLThread(new Runnable() {
public void run() {
texture.setPixels(bitmap); texture.setPixels(bitmap);
this.onload.run(); onload.run();
}
});
} }
public GLTexture getTexture() { public GLTexture getTexture() {
......
...@@ -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
......
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;
}
}
package com.projectseptember.RNGL;
public interface RunInGLThread {
public void runInGLThread(final Runnable runnable);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment