1// Copyright 2013 The Flutter Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5part of engine; 6 7// Mappings from SkMatrix-index to input-index. 8const List<int> _skMatrixIndexToMatrix4Index = <int>[ 9 0, 4, 12, // Row 1 10 1, 5, 13, // Row 2 11 3, 7, 15, // Row 3 12]; 13 14/// Converts a 4x4 Flutter matrix (represented as a [Float64List]) to an 15/// SkMatrix, which is a 3x3 transform matrix. 16js.JsArray<double> toSkMatrix(Float64List matrix4) { 17 js.JsArray<double> skMatrix = new js.JsArray<double>(); 18 skMatrix.length = 9; 19 for (int i = 0; i < 9; ++i) { 20 int matrix4Index = _skMatrixIndexToMatrix4Index[i]; 21 if (matrix4Index < matrix4.length) 22 skMatrix[i] = matrix4[matrix4Index]; 23 else 24 skMatrix[i] = 0.0; 25 } 26 return skMatrix; 27} 28