Apply the buffer offset when converting a vertex color Int32List to a Uint32List (flutter/engine#40066)

Apply the buffer offset when converting a vertex color Int32List to a Uint32List
This commit is contained in:
Jason Simmons
2023-03-09 11:56:59 -08:00
committed by GitHub
parent b8ecad0c34
commit d55465069a
2 changed files with 12 additions and 2 deletions

View File

@@ -389,8 +389,13 @@ class CanvasKitCanvas implements ui.Canvas {
'If non-null, "colors" length must be one fourth the length of "rstTransforms" and "rects".');
}
Uint32List? unsignedColors;
if (colors != null) {
unsignedColors = colors.buffer.asUint32List(colors.offsetInBytes, colors.length);
}
_drawAtlas(paint, atlas, rstTransforms, rects,
colors?.buffer.asUint32List(), blendMode ?? ui.BlendMode.src);
unsignedColors, blendMode ?? ui.BlendMode.src);
}
// TODO(hterkelsen): Pass a cull_rect once CanvasKit supports that.

View File

@@ -62,11 +62,16 @@ class CkVertices extends ManagedSkiaObject<SkVertices> implements ui.Vertices {
'"indices" values must be valid indices in the positions list.');
}
Uint32List? unsignedColors;
if (colors != null) {
unsignedColors = colors.buffer.asUint32List(colors.offsetInBytes, colors.length);
}
return CkVertices._(
toSkVertexMode(mode),
positions,
textureCoordinates,
colors?.buffer.asUint32List(),
unsignedColors,
indices,
);
}