Dont use TypedData.fromList if you dont have a list already (flutter/engine#30293)

This commit is contained in:
Jonah Williams
2021-12-14 11:54:01 -08:00
committed by GitHub
parent a2d82caeab
commit 94ee03e40a
3 changed files with 31 additions and 22 deletions

View File

@@ -383,7 +383,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
assert(clipBehavior != Clip.none); assert(clipBehavior != Clip.none);
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushClipRRect')); assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushClipRRect'));
final EngineLayer engineLayer = EngineLayer._(); final EngineLayer engineLayer = EngineLayer._();
_pushClipRRect(engineLayer, rrect._value32, clipBehavior.index, oldLayer?._nativeLayer); _pushClipRRect(engineLayer, rrect._getValue32(), clipBehavior.index, oldLayer?._nativeLayer);
final ClipRRectEngineLayer layer = ClipRRectEngineLayer._(engineLayer); final ClipRRectEngineLayer layer = ClipRRectEngineLayer._(engineLayer);
assert(_debugPushLayer(layer)); assert(_debugPushLayer(layer));
return layer; return layer;

View File

@@ -672,7 +672,14 @@ class Rect {
math.max(a.dy, b.dy), math.max(a.dy, b.dy),
); );
Float32List get _value32 => Float32List.fromList(<double>[left, top, right, bottom]); Float32List _getValue32() {
final Float32List result = Float32List(4);
result[0] = left;
result[1] = top;
result[2] = right;
result[3] = bottom;
return result;
}
/// The offset of the left edge of this rectangle from the x axis. /// The offset of the left edge of this rectangle from the x axis.
final double left; final double left;
@@ -1192,20 +1199,22 @@ class RRect {
assert(blRadiusX != null), assert(blRadiusX != null),
assert(blRadiusY != null); assert(blRadiusY != null);
Float32List get _value32 => Float32List.fromList(<double>[ Float32List _getValue32() {
left, final Float32List result = Float32List(12);
top, result[0] = left;
right, result[1] = top;
bottom, result[2] = right;
tlRadiusX, result[3] = bottom;
tlRadiusY, result[4] = tlRadiusX;
trRadiusX, result[5] = tlRadiusY;
trRadiusY, result[6] = trRadiusX;
brRadiusX, result[7] = trRadiusY;
brRadiusY, result[8] = brRadiusX;
blRadiusX, result[9] = brRadiusY;
blRadiusY, result[10] = blRadiusX;
]); result[11] = blRadiusY;
return result;
}
/// The offset of the left edge of this rectangle from the x axis. /// The offset of the left edge of this rectangle from the x axis.
final double left; final double left;

View File

@@ -2495,7 +2495,7 @@ class Path extends NativeFieldWrapperClass1 {
/// argument. /// argument.
void addRRect(RRect rrect) { void addRRect(RRect rrect) {
assert(_rrectIsValid(rrect)); assert(_rrectIsValid(rrect));
_addRRect(rrect._value32); _addRRect(rrect._getValue32());
} }
void _addRRect(Float32List rrect) native 'Path_addRRect'; void _addRRect(Float32List rrect) native 'Path_addRRect';
@@ -4333,7 +4333,7 @@ class Canvas extends NativeFieldWrapperClass1 {
void clipRRect(RRect rrect, {bool doAntiAlias = true}) { void clipRRect(RRect rrect, {bool doAntiAlias = true}) {
assert(_rrectIsValid(rrect)); assert(_rrectIsValid(rrect));
assert(doAntiAlias != null); assert(doAntiAlias != null);
_clipRRect(rrect._value32, doAntiAlias); _clipRRect(rrect._getValue32(), doAntiAlias);
} }
void _clipRRect(Float32List rrect, bool doAntiAlias) native 'Canvas_clipRRect'; void _clipRRect(Float32List rrect, bool doAntiAlias) native 'Canvas_clipRRect';
@@ -4409,7 +4409,7 @@ class Canvas extends NativeFieldWrapperClass1 {
void drawRRect(RRect rrect, Paint paint) { void drawRRect(RRect rrect, Paint paint) {
assert(_rrectIsValid(rrect)); assert(_rrectIsValid(rrect));
assert(paint != null); assert(paint != null);
_drawRRect(rrect._value32, paint._objects, paint._data); _drawRRect(rrect._getValue32(), paint._objects, paint._data);
} }
void _drawRRect(Float32List rrect, void _drawRRect(Float32List rrect,
List<dynamic>? paintObjects, List<dynamic>? paintObjects,
@@ -4424,7 +4424,7 @@ class Canvas extends NativeFieldWrapperClass1 {
assert(_rrectIsValid(outer)); assert(_rrectIsValid(outer));
assert(_rrectIsValid(inner)); assert(_rrectIsValid(inner));
assert(paint != null); assert(paint != null);
_drawDRRect(outer._value32, inner._value32, paint._objects, paint._data); _drawDRRect(outer._getValue32(), inner._getValue32(), paint._objects, paint._data);
} }
void _drawDRRect(Float32List outer, void _drawDRRect(Float32List outer,
Float32List inner, Float32List inner,
@@ -4863,7 +4863,7 @@ class Canvas extends NativeFieldWrapperClass1 {
} }
final Int32List? colorBuffer = (colors == null || colors.isEmpty) ? null : _encodeColorList(colors); final Int32List? colorBuffer = (colors == null || colors.isEmpty) ? null : _encodeColorList(colors);
final Float32List? cullRectBuffer = cullRect?._value32; final Float32List? cullRectBuffer = cullRect?._getValue32();
final int qualityIndex = paint.filterQuality.index; final int qualityIndex = paint.filterQuality.index;
_drawAtlas( _drawAtlas(
@@ -5037,7 +5037,7 @@ class Canvas extends NativeFieldWrapperClass1 {
_drawAtlas( _drawAtlas(
paint._objects, paint._data, qualityIndex, atlas._image, rstTransforms, rects, paint._objects, paint._data, qualityIndex, atlas._image, rstTransforms, rects,
colors, (blendMode ?? BlendMode.src).index, cullRect?._value32 colors, (blendMode ?? BlendMode.src).index, cullRect?._getValue32()
); );
} }