Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4a79400

Browse files
authored
Revert "Support for TwoPointConical gradients (#5275)" (#5293)
This reverts commit 919e8c2 as it breaks flutter gradient_test.
1 parent 45ebf1d commit 4a79400

File tree

3 files changed

+4
-64
lines changed

3 files changed

+4
-64
lines changed

lib/ui/painting.dart

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,44 +2310,25 @@ class Gradient extends Shader {
23102310
/// If `matrix4` is provided, the gradient fill will be transformed by the
23112311
/// specified 4x4 matrix relative to the local coordinate system. `matrix4` must
23122312
/// be a column-major matrix packed into a list of 16 values.
2313-
///
2314-
/// If `focal` is provided and not equal to `center` or `focalRadius` is
2315-
/// provided and not equal to 0.0, the generated shader will be a two point
2316-
/// conical radial gradient, with `focal` being the center of the focal
2317-
/// circle and `focalRadius` being the radius of that circle. If `focal` is
2318-
/// provided and not equal to `center`, at least one of the two offsets must
2319-
/// not be equal to [Offset.zero].
23202313
Gradient.radial(
23212314
Offset center,
23222315
double radius,
23232316
List<Color> colors, [
23242317
List<double> colorStops,
23252318
TileMode tileMode = TileMode.clamp,
2326-
Float64List matrix4,
2327-
Offset focal,
2328-
double focalRadius
2319+
Float64List matrix4
23292320
]) : assert(_offsetIsValid(center)),
23302321
assert(colors != null),
23312322
assert(tileMode != null),
23322323
assert(matrix4 == null || _matrix4IsValid(matrix4)),
23332324
super._() {
2334-
focal ??= center;
2335-
focalRadius ??= 0.0;
23362325
_validateColorStops(colors, colorStops);
23372326
final Int32List colorsBuffer = _encodeColorList(colors);
23382327
final Float32List colorStopsBuffer = colorStops == null ? null : new Float32List.fromList(colorStops);
2339-
2340-
if (center == focal && focalRadius != 0.0) {
2341-
_constructor();
2342-
_initRadial(center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
2343-
} else {
2344-
assert(center != Offset.zero || focal != Offset.zero); // will result in nullptr in Skia side
2345-
_constructor();
2346-
_initConical(focal.dx, focal.dy, focalRadius, center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
2347-
}
2328+
_constructor();
2329+
_initRadial(center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
23482330
}
23492331
void _initRadial(double centerX, double centerY, double radius, Int32List colors, Float32List colorStops, int tileMode, Float64List matrix4) native 'Gradient_initRadial';
2350-
void _initConical(double startX, double startY, double startRadius, double endX, double endY, double endRadius, Int32List colors, Float32List colorStops, int tileMode, Float64List matrix4) native 'Gradient_initTwoPointConical';
23512332

23522333
/// Creates a sweep gradient centered at `center` that starts at `startAngle`
23532334
/// and ends at `endAngle`.

lib/ui/painting/gradient.cc

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Gradient);
2525
#define FOR_EACH_BINDING(V) \
2626
V(Gradient, initLinear) \
2727
V(Gradient, initRadial) \
28-
V(Gradient, initSweep) \
29-
V(Gradient, initTwoPointConical)
28+
V(Gradient, initSweep)
3029

3130
FOR_EACH_BINDING(DART_NATIVE_CALLBACK)
3231

@@ -110,35 +109,6 @@ void CanvasGradient::initSweep(double center_x,
110109
has_matrix ? &sk_matrix : nullptr)));
111110
}
112111

113-
void CanvasGradient::initTwoPointConical(double start_x,
114-
double start_y,
115-
double start_radius,
116-
double end_x,
117-
double end_y,
118-
double end_radius,
119-
const tonic::Int32List& colors,
120-
const tonic::Float32List& color_stops,
121-
SkShader::TileMode tile_mode,
122-
const tonic::Float64List& matrix4) {
123-
FXL_DCHECK(colors.num_elements() == color_stops.num_elements() ||
124-
color_stops.data() == nullptr);
125-
126-
static_assert(sizeof(SkColor) == sizeof(int32_t),
127-
"SkColor doesn't use int32_t.");
128-
129-
SkMatrix sk_matrix;
130-
bool has_matrix = matrix4.data() != nullptr;
131-
if (has_matrix) {
132-
sk_matrix = ToSkMatrix(matrix4);
133-
}
134-
135-
set_shader(UIDartState::CreateGPUObject(SkGradientShader::MakeTwoPointConical(
136-
SkPoint::Make(start_x, start_y), start_radius,
137-
SkPoint::Make(end_x, end_y), end_radius,
138-
reinterpret_cast<const SkColor*>(colors.data()), color_stops.data(),
139-
colors.num_elements(), tile_mode, 0, has_matrix ? &sk_matrix : nullptr)));
140-
}
141-
142112
CanvasGradient::CanvasGradient() = default;
143113

144114
CanvasGradient::~CanvasGradient() = default;

lib/ui/painting/gradient.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,6 @@ class CanvasGradient : public Shader {
5252
double end_angle,
5353
const tonic::Float64List& matrix4);
5454

55-
void initTwoPointConical(double start_x,
56-
double start_y,
57-
double start_radius,
58-
double end_x,
59-
double end_y,
60-
double end_radius,
61-
const tonic::Int32List& colors,
62-
const tonic::Float32List& color_stops,
63-
SkShader::TileMode tile_mode,
64-
const tonic::Float64List& matrix4);
65-
6655
static void RegisterNatives(tonic::DartLibraryNatives* natives);
6756

6857
private:

0 commit comments

Comments
 (0)