GrGLSLUtil.cpp 1.5 KB

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