Unverified Commit 27e91231 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Revert "ImageDecoration.lerp" (#131347)

Reverts flutter/flutter#130533

Tree breakage.
parent bae1ac2f
......@@ -50,7 +50,7 @@ linter:
- avoid_field_initializers_in_const_classes
# - avoid_final_parameters # incompatible with prefer_final_parameters
- avoid_function_literals_in_foreach_calls
# - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558
- avoid_implementing_value_types
- avoid_init_to_null
- avoid_js_rounded_ints
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
......
......@@ -34,6 +34,7 @@ export 'src/foundation/diagnostics.dart';
export 'src/foundation/isolates.dart';
export 'src/foundation/key.dart';
export 'src/foundation/licenses.dart';
export 'src/foundation/math.dart';
export 'src/foundation/memory_allocations.dart';
export 'src/foundation/node.dart';
export 'src/foundation/object.dart';
......
......@@ -3,9 +3,9 @@ nothing but core Dart packages. They can't depend on `dart:ui`, they
can't depend on any `package:`, and they can't depend on anything
outside this directory.
Currently they do depend on dart:ui, but only for `VoidCallback` and
`clampDouble` (and maybe one day `lerpDouble`), which are all intended
to be moved out of `dart:ui` and into `dart:core`.
Currently they do depend on dart:ui, but only for `VoidCallback` (and
maybe one day `lerpDouble`), which are all intended to be moved out
of `dart:ui` and into `dart:core`.
There is currently also an unfortunate dependency on the platform
dispatcher logic (SingletonFlutterWindow, Brightness,
......@@ -14,4 +14,5 @@ PlatformDispatcher, window), though that should probably move to the
See also:
* https://github.com/dart-lang/sdk/issues/25217
* https://github.com/dart-lang/sdk/issues/27791 (`VoidCallback`)
* https://github.com/dart-lang/sdk/issues/25217 (`hashValues`, `hashList`, and `lerpDouble`)
......@@ -22,7 +22,7 @@ import 'print.dart';
import 'service_extensions.dart';
import 'timeline.dart';
export 'dart:ui' show PlatformDispatcher, SingletonFlutterWindow, clampDouble; // ignore: deprecated_member_use
export 'dart:ui' show PlatformDispatcher, SingletonFlutterWindow; // ignore: deprecated_member_use
export 'basic_types.dart' show AsyncCallback, AsyncValueGetter, AsyncValueSetter;
......
......@@ -3,13 +3,13 @@
// found in the LICENSE file.
import 'dart:math' as math;
import 'dart:ui' show clampDouble;
import 'package:meta/meta.dart';
import 'assertions.dart';
import 'constants.dart';
import 'debug.dart';
import 'math.dart' show clampDouble;
import 'object.dart';
// Examples can assume:
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Same as [num.clamp] but optimized for non-null [double].
///
/// This is faster because it avoids polymorphism, boxing, and special cases for
/// floating point numbers.
//
// See also: //dev/benchmarks/microbenchmarks/lib/foundation/clamp.dart
double clampDouble(double x, double min, double max) {
assert(min <= max && !max.isNaN && !min.isNaN);
if (x < min) {
return min;
}
if (x > max) {
return max;
}
if (x.isNaN) {
return max;
}
return x;
}
......@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show clampDouble, lerpDouble;
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show clampDouble;
import 'color_scheme.dart';
import 'colors.dart';
......
......@@ -232,7 +232,7 @@ class BoxDecoration extends Decoration {
BoxDecoration scale(double factor) {
return BoxDecoration(
color: Color.lerp(null, color, factor),
image: DecorationImage.lerp(null, image, factor),
image: image, // TODO(ianh): fade the image from transparent
border: BoxBorder.lerp(null, border, factor),
borderRadius: BorderRadiusGeometry.lerp(null, borderRadius, factor),
boxShadow: BoxShadow.lerpList(null, boxShadow, factor),
......@@ -307,7 +307,7 @@ class BoxDecoration extends Decoration {
}
return BoxDecoration(
color: Color.lerp(a.color, b.color, t),
image: DecorationImage.lerp(a.image, b.image, t),
image: t < 0.5 ? a.image : b.image, // TODO(ianh): cross-fade the image
border: BoxBorder.lerp(a.border, b.border, t),
borderRadius: BorderRadiusGeometry.lerp(a.borderRadius, b.borderRadius, t),
boxShadow: BoxShadow.lerpList(a.boxShadow, b.boxShadow, t),
......
......@@ -237,7 +237,7 @@ class ShapeDecoration extends Decoration {
return ShapeDecoration(
color: Color.lerp(a?.color, b?.color, t),
gradient: Gradient.lerp(a?.gradient, b?.gradient, t),
image: DecorationImage.lerp(a?.image, b?.image, t),
image: t < 0.5 ? a?.image : b?.image, // TODO(ianh): cross-fade the image
shadows: BoxShadow.lerpList(a?.shadows, b?.shadows, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t)!,
);
......
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