egdaniel | 2829bb7 | 2016-02-03 09:52:51 -0800 | [diff] [blame] | 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" |
brianosman | 5192475 | 2016-09-12 08:50:19 -0700 | [diff] [blame] | 11 | #include "SkMatrix44.h" |
egdaniel | 2829bb7 | 2016-02-03 09:52:51 -0800 | [diff] [blame] | 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 | } |
brianosman | 5192475 | 2016-09-12 08:50:19 -0700 | [diff] [blame] | 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 | } |