aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMatrix.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-04-14 14:07:02 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-14 14:07:02 -0700
commit567118fbe69f9d0e245ddc0a6c312b6b9b70233f (patch)
treef6438ba9245ef21aca0efbdae3051f4111e7429d /src/core/SkMatrix.cpp
parent149b47fec73ce945ef26463a3092bad5569b6a53 (diff)
Graduate matrix map-point procs out of SkOpts.
These are implemented generically with Sk4s and don't benefit from anything fancier than vanilla SSE/NEON. This means there's no need to hide this code away in another file or behind a function pointer... it's readable and we have compile-time support for all the instructions it needs. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1872193002 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Review URL: https://codereview.chromium.org/1872193002
Diffstat (limited to 'src/core/SkMatrix.cpp')
-rw-r--r--src/core/SkMatrix.cpp89
1 files changed, 82 insertions, 7 deletions
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index f60ce85a6c..5711bd9aef 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -5,13 +5,12 @@
* found in the LICENSE file.
*/
-#include "SkMatrix.h"
#include "SkFloatBits.h"
+#include "SkMatrix.h"
+#include "SkNx.h"
+#include "SkPaint.h"
#include "SkRSXform.h"
#include "SkString.h"
-#include "SkNx.h"
-#include "SkOpts.h"
-
#include <stddef.h>
static void normalize_perspective(SkScalar mat[9]) {
@@ -917,11 +916,62 @@ void SkMatrix::Identity_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[
}
void SkMatrix::Trans_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], int count) {
- return SkOpts::matrix_translate(m,dst,src,count);
+ SkASSERT(m.getType() <= SkMatrix::kTranslate_Mask);
+ if (count > 0) {
+ SkScalar tx = m.getTranslateX();
+ SkScalar ty = m.getTranslateY();
+ if (count & 1) {
+ dst->fX = src->fX + tx;
+ dst->fY = src->fY + ty;
+ src += 1;
+ dst += 1;
+ }
+ Sk4s trans4(tx, ty, tx, ty);
+ count >>= 1;
+ if (count & 1) {
+ (Sk4s::Load(src) + trans4).store(dst);
+ src += 2;
+ dst += 2;
+ }
+ count >>= 1;
+ for (int i = 0; i < count; ++i) {
+ (Sk4s::Load(src+0) + trans4).store(dst+0);
+ (Sk4s::Load(src+2) + trans4).store(dst+2);
+ src += 4;
+ dst += 4;
+ }
+ }
}
void SkMatrix::Scale_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], int count) {
- return SkOpts::matrix_scale_translate(m,dst,src,count);
+ SkASSERT(m.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask));
+ if (count > 0) {
+ SkScalar tx = m.getTranslateX();
+ SkScalar ty = m.getTranslateY();
+ SkScalar sx = m.getScaleX();
+ SkScalar sy = m.getScaleY();
+ if (count & 1) {
+ dst->fX = src->fX * sx + tx;
+ dst->fY = src->fY * sy + ty;
+ src += 1;
+ dst += 1;
+ }
+ Sk4s trans4(tx, ty, tx, ty);
+ Sk4s scale4(sx, sy, sx, sy);
+ count >>= 1;
+ if (count & 1) {
+ (Sk4s::Load(src) * scale4 + trans4).store(dst);
+ src += 2;
+ dst += 2;
+ }
+ count >>= 1;
+ for (int i = 0; i < count; ++i) {
+ (Sk4s::Load(src+0) * scale4 + trans4).store(dst+0);
+ (Sk4s::Load(src+2) * scale4 + trans4).store(dst+2);
+ src += 4;
+ dst += 4;
+ }
+ }
}
void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[],
@@ -953,7 +1003,32 @@ void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[],
}
void SkMatrix::Affine_vpts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], int count) {
- return SkOpts::matrix_affine(m,dst,src,count);
+ SkASSERT(m.getType() != SkMatrix::kPerspective_Mask);
+ if (count > 0) {
+ SkScalar tx = m.getTranslateX();
+ SkScalar ty = m.getTranslateY();
+ SkScalar sx = m.getScaleX();
+ SkScalar sy = m.getScaleY();
+ SkScalar kx = m.getSkewX();
+ SkScalar ky = m.getSkewY();
+ if (count & 1) {
+ dst->set(src->fX * sx + src->fY * kx + tx,
+ src->fX * ky + src->fY * sy + ty);
+ src += 1;
+ dst += 1;
+ }
+ Sk4s trans4(tx, ty, tx, ty);
+ Sk4s scale4(sx, sy, sx, sy);
+ Sk4s skew4(kx, ky, kx, ky); // applied to swizzle of src4
+ count >>= 1;
+ for (int i = 0; i < count; ++i) {
+ Sk4s src4 = Sk4s::Load(src);
+ Sk4s swz4 = SkNx_shuffle<1,0,3,2>(src4); // y0 x0, y1 x1
+ (src4 * scale4 + swz4 * skew4 + trans4).store(dst);
+ src += 2;
+ dst += 2;
+ }
+ }
}
const SkMatrix::MapPtsProc SkMatrix::gMapPtsProcs[] = {