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