Bug 938827 - Part 1: Get LayerView in getSurfaceView. r=rnewman

This commit is contained in:
Michael Comella 2013-12-06 11:43:10 -08:00
Родитель d43c009f5e
Коммит 07be030844
3 изменённых файлов: 9 добавлений и 32 удалений

Просмотреть файл

@ -4,6 +4,8 @@
package org.mozilla.gecko;
import org.mozilla.gecko.gfx.LayerView;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
@ -51,7 +53,6 @@ public class FennecNativeDriver implements Driver {
private Class mApiClass;
private Class mEventListenerClass;
private Method mRegisterEventListener;
private Method mGetPixels;
private Method mStartFrameRecording;
private Method mStopFrameRecording;
private Method mStartCheckerboardRecording;
@ -92,7 +93,6 @@ public class FennecNativeDriver implements Driver {
mEventListenerClass = mClassLoader.loadClass("org.mozilla.gecko.util.GeckoEventListener");
mRegisterEventListener = mApiClass.getMethod("registerEventListener", String.class, mEventListenerClass);
mGetPixels = mApiClass.getMethod("getViewPixels", View.class);
mStartFrameRecording = mApiClass.getDeclaredMethod("startFrameTimeRecording");
mStopFrameRecording = mApiClass.getDeclaredMethod("stopFrameTimeRecording");
mStartCheckerboardRecording = mApiClass.getDeclaredMethod("startCheckerboardRecording");
@ -234,37 +234,17 @@ public class FennecNativeDriver implements Driver {
return 0.0f;
}
private View getSurfaceView() {
ArrayList<View> views = mSolo.getCurrentViews();
try {
Class c = Class.forName("org.mozilla.gecko.gfx.LayerView");
for (View v : views) {
if (c.isInstance(v)) {
return v;
}
}
} catch (ClassNotFoundException e) {
log(LogLevel.ERROR, e);
}
log(LogLevel.WARN, "getSurfaceView could not find LayerView");
for (View v : views) {
log(LogLevel.WARN, v.toString());
}
return null;
private LayerView getSurfaceView() {
return mSolo.getView(LayerView.class, 0);
}
public PaintedSurface getPaintedSurface() {
View view = getSurfaceView();
final LayerView view = getSurfaceView();
if (view == null) {
return null;
}
IntBuffer pixelBuffer;
try {
pixelBuffer = (IntBuffer)mGetPixels.invoke(mRobocopApi, view);
} catch (Exception e) {
log(LogLevel.ERROR, e);
return null;
}
final IntBuffer pixelBuffer = view.getPixels();
// now we need to (1) flip the image, because GL likes to do things up-side-down,
// and (2) rearrange the bits from AGBR-8888 to ARGB-8888.

Просмотреть файл

@ -5,7 +5,6 @@
package org.mozilla.gecko;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.gfx.PanningPerfAPI;
import org.mozilla.gecko.mozglue.GeckoLoader;
import org.mozilla.gecko.mozglue.RobocopTarget;
@ -78,10 +77,6 @@ public class RobocopAPI {
return new SQLiteBridge(dbPath).rawQuery(query, null);
}
public IntBuffer getViewPixels(View view) {
return ((LayerView)view).getPixels();
}
// PanningPerfAPI.
public static void startFrameTimeRecording() {
PanningPerfAPI.startFrameTimeRecording();

Просмотреть файл

@ -15,6 +15,7 @@ import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.TouchEventInterceptor;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
import org.mozilla.gecko.mozglue.RobocopTarget;
import org.mozilla.gecko.util.EventDispatcher;
import android.content.Context;
@ -456,6 +457,7 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
}
/** Used by robocop for testing purposes. Not for production use! */
@RobocopTarget
public IntBuffer getPixels() {
return mRenderer.getPixels();
}