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
|
// disable color management
|
||||||
pref("gfx.color_management.mode", 0);
|
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
|
// don't allow JS to move and resize existing windows
|
||||||
pref("dom.disable_window_move_resize", true);
|
pref("dom.disable_window_move_resize", true);
|
||||||
|
@ -7,6 +7,7 @@ package org.mozilla.gecko.gfx;
|
|||||||
|
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.util.Log;
|
||||||
import org.mozilla.gecko.FloatUtils;
|
import org.mozilla.gecko.FloatUtils;
|
||||||
import org.mozilla.gecko.GeckoAppShell;
|
import org.mozilla.gecko.GeckoAppShell;
|
||||||
|
|
||||||
@ -27,6 +28,30 @@ final class DisplayPortCalculator {
|
|||||||
return sStrategy.aboutToCheckerboard(metrics, (velocity == null ? ZERO_VELOCITY : velocity), displayPort);
|
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 {
|
private interface DisplayPortStrategy {
|
||||||
/** Calculates a displayport given a viewport and panning velocity. */
|
/** Calculates a displayport given a viewport and panning velocity. */
|
||||||
public DisplayPortMetrics calculate(ImmutableViewportMetrics metrics, PointF 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.GeckoAppShell;
|
||||||
import org.mozilla.gecko.GeckoEvent;
|
import org.mozilla.gecko.GeckoEvent;
|
||||||
import org.mozilla.gecko.GeckoEventResponder;
|
import org.mozilla.gecko.GeckoEventResponder;
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -59,6 +60,7 @@ import android.view.View;
|
|||||||
public class GeckoLayerClient implements GeckoEventResponder,
|
public class GeckoLayerClient implements GeckoEventResponder,
|
||||||
FlexibleGLSurfaceView.Listener {
|
FlexibleGLSurfaceView.Listener {
|
||||||
private static final String LOGTAG = "GeckoLayerClient";
|
private static final String LOGTAG = "GeckoLayerClient";
|
||||||
|
private static final String PREF_DISPLAYPORT_STRATEGY = "gfx.displayport.strategy";
|
||||||
|
|
||||||
private LayerController mLayerController;
|
private LayerController mLayerController;
|
||||||
private LayerRenderer mLayerRenderer;
|
private LayerRenderer mLayerRenderer;
|
||||||
@ -110,12 +112,14 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
|||||||
GeckoAppShell.registerGeckoEventListener("Viewport:PageSize", this);
|
GeckoAppShell.registerGeckoEventListener("Viewport:PageSize", this);
|
||||||
GeckoAppShell.registerGeckoEventListener("Viewport:CalculateDisplayPort", this);
|
GeckoAppShell.registerGeckoEventListener("Viewport:CalculateDisplayPort", this);
|
||||||
GeckoAppShell.registerGeckoEventListener("Checkerboard:Toggle", this);
|
GeckoAppShell.registerGeckoEventListener("Checkerboard:Toggle", this);
|
||||||
|
GeckoAppShell.registerGeckoEventListener("Preferences:Data", this);
|
||||||
|
|
||||||
view.setListener(this);
|
view.setListener(this);
|
||||||
view.setLayerRenderer(mLayerRenderer);
|
view.setLayerRenderer(mLayerRenderer);
|
||||||
layerController.setRoot(mRootLayer);
|
layerController.setRoot(mRootLayer);
|
||||||
|
|
||||||
sendResizeEventIfNecessary(true);
|
sendResizeEventIfNecessary(true);
|
||||||
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Preferences:Get", "[ \"" + PREF_DISPLAYPORT_STRATEGY + "\" ]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayPortMetrics getDisplayPort() {
|
DisplayPortMetrics getDisplayPort() {
|
||||||
@ -234,16 +238,21 @@ public class GeckoLayerClient implements GeckoEventResponder,
|
|||||||
ImmutableViewportMetrics newMetrics = new ImmutableViewportMetrics(new ViewportMetrics(message));
|
ImmutableViewportMetrics newMetrics = new ImmutableViewportMetrics(new ViewportMetrics(message));
|
||||||
mReturnDisplayPort = DisplayPortCalculator.calculate(newMetrics, null);
|
mReturnDisplayPort = DisplayPortCalculator.calculate(newMetrics, null);
|
||||||
} else if ("Checkerboard:Toggle".equals(event)) {
|
} else if ("Checkerboard:Toggle".equals(event)) {
|
||||||
try {
|
|
||||||
boolean showChecks = message.getBoolean("value");
|
boolean showChecks = message.getBoolean("value");
|
||||||
mLayerController.setCheckerboardShowChecks(showChecks);
|
mLayerController.setCheckerboardShowChecks(showChecks);
|
||||||
Log.i(LOGTAG, "Showing checks: " + showChecks);
|
Log.i(LOGTAG, "Showing checks: " + showChecks);
|
||||||
} catch(JSONException ex) {
|
} else if ("Preferences:Data".equals(event)) {
|
||||||
Log.e(LOGTAG, "Error decoding JSON", ex);
|
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) {
|
} 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