Search in sources :

Example 1 with Renderer

use of android.opengl.GLSurfaceView.Renderer in project robotium by RobotiumTech.

the class ScreenshotTaker method wrapAllGLViews.

/**
	 * Extract and wrap the all OpenGL ES Renderer.
	 */
private void wrapAllGLViews(View decorView) {
    ArrayList<GLSurfaceView> currentViews = viewFetcher.getCurrentViews(GLSurfaceView.class, true, decorView);
    final CountDownLatch latch = new CountDownLatch(currentViews.size());
    for (GLSurfaceView glView : currentViews) {
        Object renderContainer = new Reflect(glView).field("mGLThread").type(GLSurfaceView.class).out(Object.class);
        Renderer renderer = new Reflect(renderContainer).field("mRenderer").out(Renderer.class);
        if (renderer == null) {
            renderer = new Reflect(glView).field("mRenderer").out(Renderer.class);
            renderContainer = glView;
        }
        if (renderer == null) {
            latch.countDown();
            continue;
        }
        if (renderer instanceof GLRenderWrapper) {
            GLRenderWrapper wrapper = (GLRenderWrapper) renderer;
            wrapper.setTakeScreenshot();
            wrapper.setLatch(latch);
        } else {
            GLRenderWrapper wrapper = new GLRenderWrapper(glView, renderer, latch);
            new Reflect(renderContainer).field("mRenderer").in(wrapper);
        }
    }
    try {
        latch.await();
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
}
Also used : Renderer(android.opengl.GLSurfaceView.Renderer) CountDownLatch(java.util.concurrent.CountDownLatch) GLSurfaceView(android.opengl.GLSurfaceView)

Aggregations

GLSurfaceView (android.opengl.GLSurfaceView)1 Renderer (android.opengl.GLSurfaceView.Renderer)1 CountDownLatch (java.util.concurrent.CountDownLatch)1