Unverified Commit e143ac2d authored by Devon Carew's avatar Devon Carew Committed by GitHub

increase the value of debugImageOverheadAllowance from 104 bytes to 128kb (#73720)

parent f7dc19eb
......@@ -157,11 +157,13 @@ PaintImageCallback? debugOnPaintImage;
/// This has no effect unless asserts are enabled.
bool debugInvertOversizedImages = false;
const int _imageOverheadAllowanceDefault = 128 * 1024;
/// The number of bytes an image must use before it triggers inversion when
/// [debugInvertOversizedImages] is true.
///
/// Default is 1024 (1kb).
int debugImageOverheadAllowance = 1024;
/// Default is 128kb.
int debugImageOverheadAllowance = _imageOverheadAllowanceDefault;
/// Returns true if none of the painting library debug variables have been changed.
///
......@@ -180,7 +182,7 @@ bool debugAssertAllPaintingVarsUnset(String reason, { bool debugDisableShadowsOv
debugNetworkImageHttpClientProvider != null ||
debugOnPaintImage != null ||
debugInvertOversizedImages == true ||
debugImageOverheadAllowance != 1024) {
debugImageOverheadAllowance != _imageOverheadAllowanceDefault) {
throw FlutterError(reason);
}
return true;
......
......@@ -20,6 +20,7 @@ class TestCanvas implements Canvas {
void main() {
late ui.Image image300x300;
late ui.Image image300x200;
setUpAll(() async {
image300x300 = await createTestImage(width: 300, height: 300, cache: false);
image300x200 = await createTestImage(width: 300, height: 200, cache: false);
......@@ -108,6 +109,36 @@ void main() {
FlutterError.onError = oldFlutterError;
});
test('debugInvertOversizedImages smaller than overhead allowance', () async {
debugInvertOversizedImages = true;
final FlutterExceptionHandler? oldFlutterError = FlutterError.onError;
final List<String> messages = <String>[];
FlutterError.onError = (FlutterErrorDetails details) {
messages.add(details.exceptionAsString());
};
try {
// Create a 290x290 sized image, which is ~24kb less than the allocated size,
// and below the default debugImageOverheadAllowance size of 128kb.
const Rect rect = Rect.fromLTWH(50.0, 50.0, 290.0, 290.0);
final TestCanvas canvas = TestCanvas();
paintImage(
canvas: canvas,
rect: rect,
image: image300x300,
debugImageLabel: 'TestImage',
fit: BoxFit.fill,
);
expect(messages, isEmpty);
} finally {
debugInvertOversizedImages = false;
FlutterError.onError = oldFlutterError;
}
});
test('centerSlice with scale ≠ 1', () async {
final TestCanvas canvas = TestCanvas();
paintImage(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment