@@ -101,13 +101,13 @@ void CanvasGradient::initRadial(double center_x,
101101
102102void CanvasGradient::initSweep (double center_x,
103103 double center_y,
104- const tonic::Int32List & colors,
104+ const tonic::Float32List & colors,
105105 const tonic::Float32List& color_stops,
106106 DlTileMode tile_mode,
107107 double start_angle,
108108 double end_angle,
109109 const tonic::Float64List& matrix4) {
110- FML_DCHECK (colors.num_elements () == color_stops.num_elements () ||
110+ FML_DCHECK (colors.num_elements () == ( color_stops.num_elements () * 4 ) ||
111111 color_stops.data () == nullptr );
112112
113113 static_assert (sizeof (SkColor) == sizeof (int32_t ),
@@ -121,16 +121,20 @@ void CanvasGradient::initSweep(double center_x,
121121
122122 std::vector<DlColor> dl_colors;
123123 dl_colors.reserve (colors.num_elements ());
124- for (int i = 0 ; i < colors.num_elements (); ++i) {
125- dl_colors.emplace_back (DlColor (colors[i]));
124+ for (int i = 0 ; i < colors.num_elements (); i += 4 ) {
125+ DlScalar a = colors[i + 0 ];
126+ DlScalar r = colors[i + 1 ];
127+ DlScalar g = colors[i + 2 ];
128+ DlScalar b = colors[i + 3 ];
129+ dl_colors.emplace_back (DlColor (a, r, g, b, DlColorSpace::kExtendedSRGB ));
126130 }
127131
128132 dl_shader_ = DlColorSource::MakeSweep (
129133 SkPoint::Make (SafeNarrow (center_x), SafeNarrow (center_y)),
130134 SafeNarrow (start_angle) * 180 .0f / static_cast <float >(M_PI),
131135 SafeNarrow (end_angle) * 180 .0f / static_cast <float >(M_PI),
132- colors .num_elements (), dl_colors.data (), color_stops.data (), tile_mode ,
133- has_matrix ? &sk_matrix : nullptr );
136+ color_stops .num_elements (), dl_colors.data (), color_stops.data (),
137+ tile_mode, has_matrix ? &sk_matrix : nullptr );
134138 // Just a sanity check, all gradient shaders should be thread-safe
135139 FML_DCHECK (dl_shader_->isUIThreadSafe ());
136140}
0 commit comments