mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 797015 - [ARMv6] Add a pref to completely disable screenshot code (including memory allocation) r=mfinkle
This commit is contained in:
parent
e86bc6a536
commit
ce34880358
@ -152,7 +152,7 @@ class MemoryMonitor extends BroadcastReceiver {
|
|||||||
if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning)) {
|
if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning)) {
|
||||||
GeckoAppShell.onLowMemory();
|
GeckoAppShell.onLowMemory();
|
||||||
}
|
}
|
||||||
ScreenshotHandler.disableScreenshot();
|
ScreenshotHandler.disableScreenshot(false);
|
||||||
GeckoAppShell.geckoEventSync();
|
GeckoAppShell.geckoEventSync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ class MemoryMonitor extends BroadcastReceiver {
|
|||||||
Log.d(LOGTAG, "Decreased memory pressure to " + newLevel);
|
Log.d(LOGTAG, "Decreased memory pressure to " + newLevel);
|
||||||
|
|
||||||
if (newLevel == MEMORY_PRESSURE_NONE) {
|
if (newLevel == MEMORY_PRESSURE_NONE) {
|
||||||
ScreenshotHandler.enableScreenshot();
|
ScreenshotHandler.enableScreenshot(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -12,6 +12,7 @@ import org.mozilla.gecko.gfx.RectUtils;
|
|||||||
import org.mozilla.gecko.gfx.ScreenshotLayer;
|
import org.mozilla.gecko.gfx.ScreenshotLayer;
|
||||||
import org.mozilla.gecko.mozglue.DirectBufferAllocator;
|
import org.mozilla.gecko.mozglue.DirectBufferAllocator;
|
||||||
import org.mozilla.gecko.util.FloatUtils;
|
import org.mozilla.gecko.util.FloatUtils;
|
||||||
|
import org.mozilla.gecko.PrefsHelper;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
@ -28,11 +29,14 @@ public final class ScreenshotHandler implements Runnable {
|
|||||||
public static final int SCREENSHOT_THUMBNAIL = 0;
|
public static final int SCREENSHOT_THUMBNAIL = 0;
|
||||||
public static final int SCREENSHOT_CHECKERBOARD = 1;
|
public static final int SCREENSHOT_CHECKERBOARD = 1;
|
||||||
|
|
||||||
|
private static final String SCREENSHOT_DISABLED_PREF = "gfx.java.screenshot.enabled";
|
||||||
|
|
||||||
private static final String LOGTAG = "GeckoScreenshotHandler";
|
private static final String LOGTAG = "GeckoScreenshotHandler";
|
||||||
private static final int BYTES_FOR_16BPP = 2;
|
private static final int BYTES_FOR_16BPP = 2;
|
||||||
private static final int MAX_PIXELS_PER_SLICE = 100000;
|
private static final int MAX_PIXELS_PER_SLICE = 100000;
|
||||||
|
|
||||||
private static boolean sDisableScreenshot;
|
private static boolean sDisableScreenshot;
|
||||||
|
private static boolean sForceDisabled;
|
||||||
private static ScreenshotHandler sInstance;
|
private static ScreenshotHandler sInstance;
|
||||||
|
|
||||||
private final int mMaxTextureSize;
|
private final int mMaxTextureSize;
|
||||||
@ -80,6 +84,14 @@ public final class ScreenshotHandler implements Runnable {
|
|||||||
mBuffer = DirectBufferAllocator.allocate(mMaxPixels * BYTES_FOR_16BPP);
|
mBuffer = DirectBufferAllocator.allocate(mMaxPixels * BYTES_FOR_16BPP);
|
||||||
mDirtyRect = new RectF();
|
mDirtyRect = new RectF();
|
||||||
clearDirtyRect();
|
clearDirtyRect();
|
||||||
|
PrefsHelper.getPref(SCREENSHOT_DISABLED_PREF,
|
||||||
|
new PrefsHelper.PrefHandlerBase() {
|
||||||
|
@Override public void prefValue(String pref, boolean value) {
|
||||||
|
if (SCREENSHOT_DISABLED_PREF.equals(pref) && !value)
|
||||||
|
disableScreenshot(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
@ -96,9 +108,19 @@ public final class ScreenshotHandler implements Runnable {
|
|||||||
|
|
||||||
// Invoked via reflection from robocop test
|
// Invoked via reflection from robocop test
|
||||||
public static synchronized void disableScreenshot() {
|
public static synchronized void disableScreenshot() {
|
||||||
|
disableScreenshot(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoked via reflection from robocop test
|
||||||
|
public static synchronized void disableScreenshot(boolean forced) {
|
||||||
if (sDisableScreenshot) {
|
if (sDisableScreenshot) {
|
||||||
|
if (!sForceDisabled)
|
||||||
|
sForceDisabled = forced;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sForceDisabled = forced;
|
||||||
|
|
||||||
sDisableScreenshot = true;
|
sDisableScreenshot = true;
|
||||||
if (sInstance != null) {
|
if (sInstance != null) {
|
||||||
sInstance.cleanup();
|
sInstance.cleanup();
|
||||||
@ -107,11 +129,12 @@ public final class ScreenshotHandler implements Runnable {
|
|||||||
Log.i(LOGTAG, "Screenshotting disabled");
|
Log.i(LOGTAG, "Screenshotting disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void enableScreenshot() {
|
public static synchronized void enableScreenshot(boolean forced) {
|
||||||
if (!sDisableScreenshot) {
|
if (!sDisableScreenshot || (sForceDisabled && !forced)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sDisableScreenshot = false;
|
sDisableScreenshot = false;
|
||||||
|
sForceDisabled = false;
|
||||||
Log.i(LOGTAG, "Screenshotting enabled");
|
Log.i(LOGTAG, "Screenshotting enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user