зеркало из https://github.com/mozilla/gecko-dev.git
Bug 719570 Provide option to change checkerboard to flat color on fennec for eideticker automation r=pcwalton
This commit is contained in:
Родитель
2a5eb51557
Коммит
b5cc7bd5be
|
@ -56,12 +56,13 @@ public class CheckerboardImage extends CairoImage {
|
|||
|
||||
private ByteBuffer mBuffer;
|
||||
private int mMainColor;
|
||||
private boolean mShowChecks;
|
||||
|
||||
/** Creates a new checkerboard image. */
|
||||
public CheckerboardImage() {
|
||||
int bpp = CairoUtils.bitsPerPixelForCairoFormat(FORMAT);
|
||||
mBuffer = GeckoAppShell.allocateDirectBuffer(SIZE * SIZE * bpp / 8);
|
||||
setColor(Color.WHITE);
|
||||
update(true, Color.WHITE);
|
||||
}
|
||||
|
||||
/** Returns the current color of the checkerboard. */
|
||||
|
@ -69,15 +70,36 @@ public class CheckerboardImage extends CairoImage {
|
|||
return mMainColor;
|
||||
}
|
||||
|
||||
/** Sets the color of the checkerboard image and regenerates it. */
|
||||
public void setColor(int color) {
|
||||
if (mMainColor == color) {
|
||||
/** Returns whether or not we are currently showing checks on the checkerboard. */
|
||||
public boolean getShowChecks() {
|
||||
return mShowChecks;
|
||||
}
|
||||
|
||||
/** Updates the checkerboard image. If showChecks is true, then create a
|
||||
checkerboard image that is tinted to the color. Otherwise just return a flat
|
||||
image of the color. */
|
||||
public void update(boolean showChecks, int color) {
|
||||
mMainColor = color;
|
||||
mShowChecks = showChecks;
|
||||
|
||||
short mainColor16 = convertTo16Bit(mMainColor);
|
||||
|
||||
mBuffer.rewind();
|
||||
ShortBuffer shortBuffer = mBuffer.asShortBuffer();
|
||||
|
||||
if (!mShowChecks) {
|
||||
short color16 = convertTo16Bit(mMainColor);
|
||||
short[] fillBuffer = new short[SIZE];
|
||||
Arrays.fill(fillBuffer, color16);
|
||||
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
shortBuffer.put(fillBuffer);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mMainColor = color;
|
||||
int tintColor = tint(mMainColor);
|
||||
short mainColor16 = convertTo16Bit(mMainColor), tintColor16 = convertTo16Bit(tintColor);
|
||||
short tintColor16 = convertTo16Bit(tint(mMainColor));
|
||||
|
||||
short[] mainPattern = new short[SIZE / 2], tintPattern = new short[SIZE / 2];
|
||||
Arrays.fill(mainPattern, mainColor16);
|
||||
|
@ -91,8 +113,6 @@ public class CheckerboardImage extends CairoImage {
|
|||
// | T | N |
|
||||
// +---+---+
|
||||
|
||||
mBuffer.rewind();
|
||||
ShortBuffer shortBuffer = mBuffer.asShortBuffer();
|
||||
for (int i = 0; i < SIZE / 2; i++) {
|
||||
shortBuffer.put(mainPattern);
|
||||
shortBuffer.put(tintPattern);
|
||||
|
|
|
@ -165,6 +165,7 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
|
|||
|
||||
GeckoAppShell.registerGeckoEventListener("Viewport:UpdateAndDraw", this);
|
||||
GeckoAppShell.registerGeckoEventListener("Viewport:UpdateLater", this);
|
||||
GeckoAppShell.registerGeckoEventListener("Checkerboard:Toggle", this);
|
||||
|
||||
sendResizeEventIfNecessary();
|
||||
}
|
||||
|
@ -530,6 +531,15 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
|
|||
GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.DRAW, rect));
|
||||
} else if ("Viewport:UpdateLater".equals(event)) {
|
||||
mUpdateViewportOnEndDraw = true;
|
||||
} else if ("Checkerboard:Toggle".equals(event)) {
|
||||
try {
|
||||
boolean showChecks = message.getBoolean("value");
|
||||
LayerController controller = getLayerController();
|
||||
controller.setCheckerboardShowChecks(showChecks);
|
||||
Log.i(LOGTAG, "Showing checks: " + showChecks);
|
||||
} catch(JSONException ex) {
|
||||
Log.e(LOGTAG, "Error decoding JSON", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ public class LayerController {
|
|||
|
||||
/* The new color for the checkerboard. */
|
||||
private int mCheckerboardColor;
|
||||
private boolean mCheckerboardShouldShowChecks;
|
||||
|
||||
private boolean mForceRedraw;
|
||||
|
||||
|
@ -452,11 +453,22 @@ public class LayerController {
|
|||
mWaitForTouchListeners = aValue;
|
||||
}
|
||||
|
||||
/** Retrieves whether we should show checkerboard checks or not. */
|
||||
public boolean checkerboardShouldShowChecks() {
|
||||
return mCheckerboardShouldShowChecks;
|
||||
}
|
||||
|
||||
/** Retrieves the color that the checkerboard should be. */
|
||||
public int getCheckerboardColor() {
|
||||
return mCheckerboardColor;
|
||||
}
|
||||
|
||||
/** Sets whether or not the checkerboard should show checkmarks. */
|
||||
public void setCheckerboardShowChecks(boolean showChecks) {
|
||||
mCheckerboardShouldShowChecks = showChecks;
|
||||
mView.requestRender();
|
||||
}
|
||||
|
||||
/** Sets a new color for the checkerboard. */
|
||||
public void setCheckerboardColor(int newColor) {
|
||||
mCheckerboardColor = newColor;
|
||||
|
|
|
@ -470,14 +470,16 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
|
|||
}
|
||||
|
||||
private void updateCheckerboardLayer(GL10 gl, RenderContext renderContext) {
|
||||
int newCheckerboardColor = mView.getController().getCheckerboardColor();
|
||||
if (newCheckerboardColor == mCheckerboardImage.getColor()) {
|
||||
int checkerboardColor = mView.getController().getCheckerboardColor();
|
||||
boolean showChecks = mView.getController().checkerboardShouldShowChecks();
|
||||
if (checkerboardColor == mCheckerboardImage.getColor() &&
|
||||
showChecks == mCheckerboardImage.getShowChecks()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCheckerboardLayer.beginTransaction();
|
||||
try {
|
||||
mCheckerboardImage.setColor(newCheckerboardColor);
|
||||
mCheckerboardImage.update(showChecks, checkerboardColor);
|
||||
mCheckerboardLayer.invalidate();
|
||||
} finally {
|
||||
mCheckerboardLayer.endTransaction();
|
||||
|
|
|
@ -341,6 +341,14 @@ var BrowserApp = {
|
|||
type: "Gecko:Ready"
|
||||
}
|
||||
});
|
||||
|
||||
// after gecko has loaded, set the checkerboarding pref once at startup (for testing only)
|
||||
sendMessageToJava({
|
||||
gecko: {
|
||||
"type": "Checkerboard:Toggle",
|
||||
"value": Services.prefs.getBoolPref("gfx.show_checkerboard_pattern")
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_showTelemetryPrompt: function _showTelemetryPrompt() {
|
||||
|
|
|
@ -286,6 +286,9 @@ pref("accessibility.typeaheadfind.prefillwithselection", true);
|
|||
// use Mac OS X Appearance panel text smoothing setting when rendering text, disabled by default
|
||||
pref("gfx.use_text_smoothing_setting", false);
|
||||
|
||||
// show checkerboard pattern on android, enabled by default (option exists for image analysis testing)
|
||||
pref("gfx.show_checkerboard_pattern", true);
|
||||
|
||||
// loading and rendering of framesets and iframes
|
||||
pref("browser.frames.enabled", true);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче