mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 740569 - Make the display port strategy preffable. r=Cwiiis
This commit is contained in:
parent
9fdc703bd0
commit
e9436816e4
@ -361,6 +361,10 @@ pref("places.frecency.unvisitedTypedBonus", 200);
|
||||
|
||||
// disable color management
|
||||
pref("gfx.color_management.mode", 0);
|
||||
#ifdef ANDROID
|
||||
// 0=fixed margin, 1=velocity bias, 2=dynamic resolution, 3=no margins
|
||||
pref("gfx.displayport.strategy", 0);
|
||||
#endif
|
||||
|
||||
// don't allow JS to move and resize existing windows
|
||||
pref("dom.disable_window_move_resize", true);
|
||||
|
@ -7,6 +7,7 @@ package org.mozilla.gecko.gfx;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.util.Log;
|
||||
import org.mozilla.gecko.FloatUtils;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
|
||||
@ -27,6 +28,30 @@ final class DisplayPortCalculator {
|
||||
return sStrategy.aboutToCheckerboard(metrics, (velocity == null ? ZERO_VELOCITY : velocity), displayPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the active strategy to use.
|
||||
* See the gfx.displayport.strategy pref in mobile/android/app/mobile.js to see the
|
||||
* mapping between ints and strategies.
|
||||
*/
|
||||
static void setStrategy(int strategy) {
|
||||
switch (strategy) {
|
||||
case 0:
|
||||
default:
|
||||
sStrategy = new FixedMarginStrategy();
|
||||
break;
|
||||
case 1:
|
||||
sStrategy = new VelocityBiasStrategy();
|
||||
break;
|
||||
case 2:
|
||||
sStrategy = new DynamicResolutionStrategy();
|
||||
break;
|
||||
case 3:
|
||||
sStrategy = new NoMarginStrategy();
|
||||
break;
|
||||
}
|
||||
Log.i(LOGTAG, "Set strategy " + sStrategy.getClass().getName());
|
||||
}
|
||||
|
||||
private interface DisplayPortStrategy {
|
||||
/** Calculates a displayport given a viewport and panning velocity. */
|
||||
public DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF velocity);
|
||||
|
@ -43,6 +43,7 @@ import org.mozilla.gecko.GeckoApp;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.GeckoEventResponder;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import android.content.Context;
|
||||
@ -59,6 +60,7 @@ import android.view.View;
|
||||
public class GeckoLayerClient implements GeckoEventResponder,
|
||||
FlexibleGLSurfaceView.Listener {
|
||||
private static final String LOGTAG = "GeckoLayerClient";
|
||||
private static final String PREF_DISPLAYPORT_STRATEGY = "gfx.displayport.strategy";
|
||||
|
||||
private LayerController mLayerController;
|
||||
private LayerRenderer mLayerRenderer;
|
||||
@ -110,12 +112,14 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
||||
GeckoAppShell.registerGeckoEventListener("Viewport:PageSize", this);
|
||||
GeckoAppShell.registerGeckoEventListener("Viewport:CalculateDisplayPort", this);
|
||||
GeckoAppShell.registerGeckoEventListener("Checkerboard:Toggle", this);
|
||||
GeckoAppShell.registerGeckoEventListener("Preferences:Data", this);
|
||||
|
||||
view.setListener(this);
|
||||
view.setLayerRenderer(mLayerRenderer);
|
||||
layerController.setRoot(mRootLayer);
|
||||
|
||||
sendResizeEventIfNecessary(true);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Preferences:Get", "[ \"" + PREF_DISPLAYPORT_STRATEGY + "\" ]"));
|
||||
}
|
||||
|
||||
DisplayPortMetrics getDisplayPort() {
|
||||
@ -234,16 +238,21 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
||||
ImmutableViewportMetrics newMetrics = new ImmutableViewportMetrics(new ViewportMetrics(message));
|
||||
mReturnDisplayPort = DisplayPortCalculator.calculate(newMetrics, null);
|
||||
} else if ("Checkerboard:Toggle".equals(event)) {
|
||||
try {
|
||||
boolean showChecks = message.getBoolean("value");
|
||||
mLayerController.setCheckerboardShowChecks(showChecks);
|
||||
Log.i(LOGTAG, "Showing checks: " + showChecks);
|
||||
} catch(JSONException ex) {
|
||||
Log.e(LOGTAG, "Error decoding JSON", ex);
|
||||
boolean showChecks = message.getBoolean("value");
|
||||
mLayerController.setCheckerboardShowChecks(showChecks);
|
||||
Log.i(LOGTAG, "Showing checks: " + showChecks);
|
||||
} else if ("Preferences:Data".equals(event)) {
|
||||
JSONArray jsonPrefs = message.getJSONArray("preferences");
|
||||
for (int i = jsonPrefs.length() - 1; i >= 0; i--) {
|
||||
JSONObject pref = jsonPrefs.getJSONObject(i);
|
||||
if (pref.getString("name").equals(PREF_DISPLAYPORT_STRATEGY)) {
|
||||
DisplayPortCalculator.setStrategy(pref.getInt("value"));
|
||||
GeckoAppShell.unregisterGeckoEventListener("Preferences:Data", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOGTAG, "Unable to create viewport metrics in " + event + " handler", e);
|
||||
Log.e(LOGTAG, "Error decoding JSON in " + event + " handler", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user