mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 720144 - Allow listening for draw updates and obtaining a copy of the composited surface for robocop testing. r=Cwiiis
This commit is contained in:
parent
a5b4d73370
commit
de6b967c0a
@ -112,6 +112,9 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
|
||||
// inside a transaction, so no synchronization is needed.
|
||||
private boolean mUpdateViewportOnEndDraw;
|
||||
|
||||
/* Used by robocop for testing purposes */
|
||||
private DrawListener mDrawListener;
|
||||
|
||||
private static Pattern sColorPattern;
|
||||
|
||||
public GeckoSoftwareLayerClient(Context context) {
|
||||
@ -325,6 +328,11 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
|
||||
}
|
||||
}
|
||||
Log.i(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - endDrawing");
|
||||
|
||||
/* Used by robocop for testing purposes */
|
||||
if (mDrawListener != null) {
|
||||
mDrawListener.drawFinished(x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
public ViewportMetrics getGeckoViewportMetrics() {
|
||||
@ -536,5 +544,15 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
|
||||
int b = Integer.parseInt(matcher.group(3));
|
||||
return Color.rgb(r, g, b);
|
||||
}
|
||||
|
||||
/** Used by robocop for testing purposes. Not for production use! */
|
||||
public void setDrawListener(DrawListener listener) {
|
||||
mDrawListener = listener;
|
||||
}
|
||||
|
||||
/** Used by robocop for testing purposes. Not for production use! */
|
||||
public interface DrawListener {
|
||||
public void drawFinished(int x, int y, int width, int height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* The layer renderer implements the rendering logic for a layer view.
|
||||
@ -95,6 +95,9 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||
private int mCurrentFrame, mFrameTimingsSum, mDroppedFrames;
|
||||
private boolean mShowFrameRate;
|
||||
|
||||
/* Used by robocop for testing purposes */
|
||||
private IntBuffer mPixelBuffer;
|
||||
|
||||
public LayerRenderer(LayerView view) {
|
||||
mView = view;
|
||||
|
||||
@ -246,6 +249,31 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
||||
mView.requestRender();
|
||||
|
||||
PanningPerfAPI.recordFrameTime();
|
||||
|
||||
/* Used by robocop for testing purposes */
|
||||
IntBuffer pixelBuffer = mPixelBuffer;
|
||||
if (updated && pixelBuffer != null) {
|
||||
synchronized (pixelBuffer) {
|
||||
pixelBuffer.position(0);
|
||||
gl.glReadPixels(0, 0, (int)screenContext.viewport.width(), (int)screenContext.viewport.height(), GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
pixelBuffer.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Used by robocop for testing purposes. Not for production use! */
|
||||
IntBuffer getPixels() {
|
||||
IntBuffer pixelBuffer = IntBuffer.allocate(mView.getWidth() * mView.getHeight());
|
||||
synchronized (pixelBuffer) {
|
||||
mPixelBuffer = pixelBuffer;
|
||||
mView.requestRender();
|
||||
try {
|
||||
pixelBuffer.wait();
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
mPixelBuffer = null;
|
||||
}
|
||||
return pixelBuffer;
|
||||
}
|
||||
|
||||
private RenderContext createScreenContext() {
|
||||
|
@ -52,6 +52,7 @@ import android.view.MotionEvent;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.util.Log;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@ -237,5 +238,10 @@ public class LayerView extends GLSurfaceView
|
||||
public int getMaxTextureSize() {
|
||||
return mRenderer.getMaxTextureSize();
|
||||
}
|
||||
|
||||
/** Used by robocop for testing purposes. Not for production use! */
|
||||
public IntBuffer getPixels() {
|
||||
return mRenderer.getPixels();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user