mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Execute callbacks in proper threads
This commit is contained in:
parent
927704b8a3
commit
b16b0b4a15
3 changed files with 13 additions and 8 deletions
|
@ -126,15 +126,17 @@ public class Servo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() {
|
public void flush() {
|
||||||
mRunCallback.inUIThread(() -> mGfxCb.flushGLBuffers());
|
// Up to the callback to execute this in the right thread
|
||||||
|
mGfxCb.flushGLBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void makeCurrent() {
|
public void makeCurrent() {
|
||||||
mRunCallback.inUIThread(() -> mGfxCb.makeCurrent());
|
// Up to the callback to execute this in the right thread
|
||||||
|
mGfxCb.makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAnimatingChanged(boolean animating) {
|
public void onAnimatingChanged(boolean animating) {
|
||||||
mRunCallback.inUIThread(() -> mGfxCb.animationStateChanged(animating));
|
mRunCallback.inGLThread(() -> mGfxCb.animationStateChanged(animating));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadStarted() {
|
public void onLoadStarted() {
|
||||||
|
@ -165,7 +167,7 @@ public class Servo {
|
||||||
stream.close();
|
stream.close();
|
||||||
return bytes;
|
return bytes;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(LOGTAG, e.getMessage());
|
Log.e(LOGTAG, "readfile error: " + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import static android.opengl.EGL14.EGL_CONTEXT_CLIENT_VERSION;
|
||||||
import static android.opengl.EGL14.EGL_OPENGL_ES2_BIT;
|
import static android.opengl.EGL14.EGL_OPENGL_ES2_BIT;
|
||||||
|
|
||||||
public class ServoSurface {
|
public class ServoSurface {
|
||||||
|
private static final String LOGTAG = "ServoSurface";
|
||||||
private final GLThread mGLThread;
|
private final GLThread mGLThread;
|
||||||
private final Handler mMainLooperHandler;
|
private final Handler mMainLooperHandler;
|
||||||
private Handler mGLLooperHandler;
|
private Handler mGLLooperHandler;
|
||||||
|
@ -113,8 +114,6 @@ public class ServoSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class GLSurface implements GfxCallbacks {
|
static class GLSurface implements GfxCallbacks {
|
||||||
private static final String LOGTAG = "ServoSurface";
|
|
||||||
|
|
||||||
private EGLConfig[] mEGLConfigs;
|
private EGLConfig[] mEGLConfigs;
|
||||||
private EGLDisplay mEglDisplay;
|
private EGLDisplay mEglDisplay;
|
||||||
private EGLContext mEglContext;
|
private EGLContext mEglContext;
|
||||||
|
@ -160,7 +159,7 @@ public class ServoSurface {
|
||||||
throw new RuntimeException("Error: createWindowSurface() Failed " + GLUtils.getEGLErrorString(glError));
|
throw new RuntimeException("Error: createWindowSurface() Failed " + GLUtils.getEGLErrorString(glError));
|
||||||
}
|
}
|
||||||
|
|
||||||
flushGLBuffers();
|
makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,7 +204,9 @@ public class ServoSurface {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mServo = new Servo(this, surface, mClient, mActivity, mServoArgs, uri, mWidth, mHeight, showLogs);
|
inUIThread(() -> {
|
||||||
|
mServo = new Servo(this, surface, mClient, mActivity, mServoArgs, uri, mWidth, mHeight, showLogs);
|
||||||
|
});
|
||||||
|
|
||||||
Looper.loop();
|
Looper.loop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,9 @@ public class ServoView extends GLSurfaceView
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flushGLBuffers() {
|
public void flushGLBuffers() {
|
||||||
|
inUIThread(() -> {
|
||||||
requestRender();
|
requestRender();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll and click
|
// Scroll and click
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue