| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2006 The Android Open Source Project | 2  * Copyright 2006 The Android Open Source Project | 
| 3  * | 3  * | 
| 4  * Use of this source code is governed by a BSD-style license that can be | 4  * Use of this source code is governed by a BSD-style license that can be | 
| 5  * found in the LICENSE file. | 5  * found in the LICENSE file. | 
| 6  */ | 6  */ | 
| 7 | 7 | 
|  | 8 #include "SkFloatBits.h" | 
| 8 #include "SkMatrix.h" | 9 #include "SkMatrix.h" | 
| 9 #include "SkFloatBits.h" | 10 #include "SkNx.h" | 
|  | 11 #include "SkPaint.h" | 
| 10 #include "SkRSXform.h" | 12 #include "SkRSXform.h" | 
| 11 #include "SkString.h" | 13 #include "SkString.h" | 
| 12 #include "SkNx.h" |  | 
| 13 #include "SkOpts.h" |  | 
| 14 |  | 
| 15 #include <stddef.h> | 14 #include <stddef.h> | 
| 16 | 15 | 
| 17 static void normalize_perspective(SkScalar mat[9]) { | 16 static void normalize_perspective(SkScalar mat[9]) { | 
| 18     // If it was interesting to never store the last element, we could divide al
      l 8 other | 17     // If it was interesting to never store the last element, we could divide al
      l 8 other | 
| 19     // elements here by the 9th, making it 1.0... | 18     // elements here by the 9th, making it 1.0... | 
| 20     // | 19     // | 
| 21     // When SkScalar was SkFixed, we would sometimes rescale the entire matrix t
      o keep its | 20     // When SkScalar was SkFixed, we would sometimes rescale the entire matrix t
      o keep its | 
| 22     // component values from getting too large. This is not a concern when using
       floats/doubles, | 21     // component values from getting too large. This is not a concern when using
       floats/doubles, | 
| 23     // so we do nothing now. | 22     // so we do nothing now. | 
| 24 | 23 | 
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 910 | 909 | 
| 911 void SkMatrix::Identity_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[
      ], int count) { | 910 void SkMatrix::Identity_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[
      ], int count) { | 
| 912     SkASSERT(m.getType() == 0); | 911     SkASSERT(m.getType() == 0); | 
| 913 | 912 | 
| 914     if (dst != src && count > 0) { | 913     if (dst != src && count > 0) { | 
| 915         memcpy(dst, src, count * sizeof(SkPoint)); | 914         memcpy(dst, src, count * sizeof(SkPoint)); | 
| 916     } | 915     } | 
| 917 } | 916 } | 
| 918 | 917 | 
| 919 void SkMatrix::Trans_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], 
      int count) { | 918 void SkMatrix::Trans_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], 
      int count) { | 
| 920     return SkOpts::matrix_translate(m,dst,src,count); | 919     SkASSERT(m.getType() <= SkMatrix::kTranslate_Mask); | 
|  | 920     if (count > 0) { | 
|  | 921         SkScalar tx = m.getTranslateX(); | 
|  | 922         SkScalar ty = m.getTranslateY(); | 
|  | 923         if (count & 1) { | 
|  | 924             dst->fX = src->fX + tx; | 
|  | 925             dst->fY = src->fY + ty; | 
|  | 926             src += 1; | 
|  | 927             dst += 1; | 
|  | 928         } | 
|  | 929         Sk4s trans4(tx, ty, tx, ty); | 
|  | 930         count >>= 1; | 
|  | 931         if (count & 1) { | 
|  | 932             (Sk4s::Load(src) + trans4).store(dst); | 
|  | 933             src += 2; | 
|  | 934             dst += 2; | 
|  | 935         } | 
|  | 936         count >>= 1; | 
|  | 937         for (int i = 0; i < count; ++i) { | 
|  | 938             (Sk4s::Load(src+0) + trans4).store(dst+0); | 
|  | 939             (Sk4s::Load(src+2) + trans4).store(dst+2); | 
|  | 940             src += 4; | 
|  | 941             dst += 4; | 
|  | 942         } | 
|  | 943     } | 
| 921 } | 944 } | 
| 922 | 945 | 
| 923 void SkMatrix::Scale_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], 
      int count) { | 946 void SkMatrix::Scale_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], 
      int count) { | 
| 924     return SkOpts::matrix_scale_translate(m,dst,src,count); | 947     SkASSERT(m.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask))
      ; | 
|  | 948     if (count > 0) { | 
|  | 949         SkScalar tx = m.getTranslateX(); | 
|  | 950         SkScalar ty = m.getTranslateY(); | 
|  | 951         SkScalar sx = m.getScaleX(); | 
|  | 952         SkScalar sy = m.getScaleY(); | 
|  | 953         if (count & 1) { | 
|  | 954             dst->fX = src->fX * sx + tx; | 
|  | 955             dst->fY = src->fY * sy + ty; | 
|  | 956             src += 1; | 
|  | 957             dst += 1; | 
|  | 958         } | 
|  | 959         Sk4s trans4(tx, ty, tx, ty); | 
|  | 960         Sk4s scale4(sx, sy, sx, sy); | 
|  | 961         count >>= 1; | 
|  | 962         if (count & 1) { | 
|  | 963             (Sk4s::Load(src) * scale4 + trans4).store(dst); | 
|  | 964             src += 2; | 
|  | 965             dst += 2; | 
|  | 966         } | 
|  | 967         count >>= 1; | 
|  | 968         for (int i = 0; i < count; ++i) { | 
|  | 969             (Sk4s::Load(src+0) * scale4 + trans4).store(dst+0); | 
|  | 970             (Sk4s::Load(src+2) * scale4 + trans4).store(dst+2); | 
|  | 971             src += 4; | 
|  | 972             dst += 4; | 
|  | 973         } | 
|  | 974     } | 
| 925 } | 975 } | 
| 926 | 976 | 
| 927 void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[], | 977 void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[], | 
| 928                          const SkPoint src[], int count) { | 978                          const SkPoint src[], int count) { | 
| 929     SkASSERT(m.hasPerspective()); | 979     SkASSERT(m.hasPerspective()); | 
| 930 | 980 | 
| 931     if (count > 0) { | 981     if (count > 0) { | 
| 932         do { | 982         do { | 
| 933             SkScalar sy = src->fY; | 983             SkScalar sy = src->fY; | 
| 934             SkScalar sx = src->fX; | 984             SkScalar sx = src->fX; | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 946             } | 996             } | 
| 947 | 997 | 
| 948             dst->fY = y * z; | 998             dst->fY = y * z; | 
| 949             dst->fX = x * z; | 999             dst->fX = x * z; | 
| 950             dst += 1; | 1000             dst += 1; | 
| 951         } while (--count); | 1001         } while (--count); | 
| 952     } | 1002     } | 
| 953 } | 1003 } | 
| 954 | 1004 | 
| 955 void SkMatrix::Affine_vpts(const SkMatrix& m, SkPoint dst[], const SkPoint src[]
      , int count) { | 1005 void SkMatrix::Affine_vpts(const SkMatrix& m, SkPoint dst[], const SkPoint src[]
      , int count) { | 
| 956     return SkOpts::matrix_affine(m,dst,src,count); | 1006     SkASSERT(m.getType() != SkMatrix::kPerspective_Mask); | 
|  | 1007     if (count > 0) { | 
|  | 1008         SkScalar tx = m.getTranslateX(); | 
|  | 1009         SkScalar ty = m.getTranslateY(); | 
|  | 1010         SkScalar sx = m.getScaleX(); | 
|  | 1011         SkScalar sy = m.getScaleY(); | 
|  | 1012         SkScalar kx = m.getSkewX(); | 
|  | 1013         SkScalar ky = m.getSkewY(); | 
|  | 1014         if (count & 1) { | 
|  | 1015             dst->set(src->fX * sx + src->fY * kx + tx, | 
|  | 1016                      src->fX * ky + src->fY * sy + ty); | 
|  | 1017             src += 1; | 
|  | 1018             dst += 1; | 
|  | 1019         } | 
|  | 1020         Sk4s trans4(tx, ty, tx, ty); | 
|  | 1021         Sk4s scale4(sx, sy, sx, sy); | 
|  | 1022         Sk4s  skew4(kx, ky, kx, ky);    // applied to swizzle of src4 | 
|  | 1023         count >>= 1; | 
|  | 1024         for (int i = 0; i < count; ++i) { | 
|  | 1025             Sk4s src4 = Sk4s::Load(src); | 
|  | 1026             Sk4s swz4 = SkNx_shuffle<1,0,3,2>(src4);  // y0 x0, y1 x1 | 
|  | 1027             (src4 * scale4 + swz4 * skew4 + trans4).store(dst); | 
|  | 1028             src += 2; | 
|  | 1029             dst += 2; | 
|  | 1030         } | 
|  | 1031     } | 
| 957 } | 1032 } | 
| 958 | 1033 | 
| 959 const SkMatrix::MapPtsProc SkMatrix::gMapPtsProcs[] = { | 1034 const SkMatrix::MapPtsProc SkMatrix::gMapPtsProcs[] = { | 
| 960     SkMatrix::Identity_pts, SkMatrix::Trans_pts, | 1035     SkMatrix::Identity_pts, SkMatrix::Trans_pts, | 
| 961     SkMatrix::Scale_pts,   SkMatrix::Scale_pts, | 1036     SkMatrix::Scale_pts,   SkMatrix::Scale_pts, | 
| 962     SkMatrix::Affine_vpts,  SkMatrix::Affine_vpts, | 1037     SkMatrix::Affine_vpts,  SkMatrix::Affine_vpts, | 
| 963     SkMatrix::Affine_vpts,  SkMatrix::Affine_vpts, | 1038     SkMatrix::Affine_vpts,  SkMatrix::Affine_vpts, | 
| 964     // repeat the persp proc 8 times | 1039     // repeat the persp proc 8 times | 
| 965     SkMatrix::Persp_pts,    SkMatrix::Persp_pts, | 1040     SkMatrix::Persp_pts,    SkMatrix::Persp_pts, | 
| 966     SkMatrix::Persp_pts,    SkMatrix::Persp_pts, | 1041     SkMatrix::Persp_pts,    SkMatrix::Persp_pts, | 
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1782     const SkScalar m10 = -m01; | 1857     const SkScalar m10 = -m01; | 
| 1783     const SkScalar m11 = m00; | 1858     const SkScalar m11 = m00; | 
| 1784     const SkScalar m12 = fTy; | 1859     const SkScalar m12 = fTy; | 
| 1785 | 1860 | 
| 1786     quad[0].set(m02, m12); | 1861     quad[0].set(m02, m12); | 
| 1787     quad[1].set(m00 * width + m02, m10 * width + m12); | 1862     quad[1].set(m00 * width + m02, m10 * width + m12); | 
| 1788     quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
      12); | 1863     quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m
      12); | 
| 1789     quad[3].set(m01 * height + m02, m11 * height + m12); | 1864     quad[3].set(m01 * height + m02, m11 * height + m12); | 
| 1790 #endif | 1865 #endif | 
| 1791 } | 1866 } | 
| OLD | NEW | 
|---|