• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright 2015 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 "include/core/SkMatrix.h"
9 #include "src/gpu/glsl/GrGLSLUtil.h"
10 
GrGLSLGetMatrix(float * dest,const SkMatrix & src)11 template<> void GrGLSLGetMatrix<3>(float* dest, const SkMatrix& src) {
12     // Col 0
13     dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]);
14     dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]);
15     dest[2] = SkScalarToFloat(src[SkMatrix::kMPersp0]);
16 
17     // Col 1
18     dest[3] = SkScalarToFloat(src[SkMatrix::kMSkewX]);
19     dest[4] = SkScalarToFloat(src[SkMatrix::kMScaleY]);
20     dest[5] = SkScalarToFloat(src[SkMatrix::kMPersp1]);
21 
22     // Col 2
23     dest[6] = SkScalarToFloat(src[SkMatrix::kMTransX]);
24     dest[7] = SkScalarToFloat(src[SkMatrix::kMTransY]);
25     dest[8] = SkScalarToFloat(src[SkMatrix::kMPersp2]);
26 }
27 
GrGLSLGetMatrix(float * dest,const SkMatrix & src)28 template<> void GrGLSLGetMatrix<4>(float* dest, const SkMatrix& src) {
29     // Col 0
30     dest[0] = SkScalarToFloat(src[SkMatrix::kMScaleX]);
31     dest[1] = SkScalarToFloat(src[SkMatrix::kMSkewY]);
32     dest[2] = 0;
33     dest[3] = SkScalarToFloat(src[SkMatrix::kMPersp0]);
34 
35     // Col 1
36     dest[4] = SkScalarToFloat(src[SkMatrix::kMSkewX]);
37     dest[5] = SkScalarToFloat(src[SkMatrix::kMScaleY]);
38     dest[6] = 0;
39     dest[7] = SkScalarToFloat(src[SkMatrix::kMPersp1]);
40 
41     // Col 2
42     dest[8] = 0;
43     dest[9] = 0;
44     dest[10] = 1;
45     dest[11] = 0;
46 
47     // Col 3
48     dest[12] = SkScalarToFloat(src[SkMatrix::kMTransX]);
49     dest[13] = SkScalarToFloat(src[SkMatrix::kMTransY]);
50     dest[14] = 0;
51     dest[15] = SkScalarToFloat(src[SkMatrix::kMPersp2]);
52 }
53