1 /* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "glsl/GrGLSLProgramDataManager.h" 9 10 #include "SkMatrix.h" 11 #include "SkMatrix44.h" 12 13 void GrGLSLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) const { 14 float mt[] = { 15 matrix.get(SkMatrix::kMScaleX), 16 matrix.get(SkMatrix::kMSkewY), 17 matrix.get(SkMatrix::kMPersp0), 18 matrix.get(SkMatrix::kMSkewX), 19 matrix.get(SkMatrix::kMScaleY), 20 matrix.get(SkMatrix::kMPersp1), 21 matrix.get(SkMatrix::kMTransX), 22 matrix.get(SkMatrix::kMTransY), 23 matrix.get(SkMatrix::kMPersp2), 24 }; 25 this->setMatrix3f(u, mt); 26 } 27 28 void GrGLSLProgramDataManager::setSkMatrix44(UniformHandle u, const SkMatrix44& matrix) const { 29 // TODO: We could skip this temporary buffer if we had direct access to the matrix storage 30 float m[16]; 31 matrix.asColMajorf(m); 32 this->setMatrix4f(u, m); 33 } 34