Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: src/core/SkMatrix.cpp

Issue 1031443002: remove meaningless matrix benches, add mapPts() and add new benches (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkMatrix.h ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrix.cpp
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 753c4dc61e0c8c7f50032c7e2d6d9be613977b51..8f5740709c59d66074f73b4e919f17afa6677d4d 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1020,6 +1020,106 @@ void SkMatrix::mapPoints(SkPoint dst[], const SkPoint src[], int count) const {
this->getMapPtsProc()(*this, dst, src, count);
}
+#include "Sk4x.h"
+
+void SkMatrix::mapPts(SkPoint dst[], const SkPoint src[], int count) const {
+ if (count <= 0) {
+ return;
+ }
+
+ unsigned mask = this->getType() & 0xF;
+
+ if (SkMatrix::kIdentity_Mask == mask) {
+ if (src != dst) {
+ memcpy(dst, src, count * sizeof(SkPoint));
+ }
+ return;
+ }
+ if (SkMatrix::kTranslate_Mask == mask) {
+ SkScalar tx = this->getTranslateX();
+ SkScalar ty = this->getTranslateY();
+ if (count & 1) {
+ dst->fX = src->fX + tx;
+ dst->fY = src->fY + ty;
+ src += 1;
+ dst += 1;
+ }
+ Sk4f trans4(tx, ty, tx, ty);
+ if (count & 2) {
+ (Sk4f::Load(&src->fX) + trans4).store(&dst->fX);
+ src += 2;
+ dst += 2;
+ }
+ count >>= 2;
+ for (int i = 0; i < count; ++i) {
+ Sk4f s0 = Sk4f::Load(&src[0].fX);
+ Sk4f s1 = Sk4f::Load(&src[2].fX);
+ (s0 + trans4).store(&dst[0].fX);
+ (s1 + trans4).store(&dst[2].fX);
+ src += 4;
+ dst += 4;
+ }
+ return;
+ }
+ if (mask <= SkMatrix::kScale_Mask + SkMatrix::kTranslate_Mask) {
+ SkScalar tx = this->getTranslateX();
+ SkScalar ty = this->getTranslateY();
+ SkScalar sx = this->getScaleX();
+ SkScalar sy = this->getScaleY();
+ if (count & 1) {
+ dst->fX = src->fX * sx + tx;
+ dst->fY = src->fY * sy + ty;
+ src += 1;
+ dst += 1;
+ }
+ Sk4f trans4(tx, ty, tx, ty);
+ Sk4f scale4(sx, sy, sx, sy);
+ if (count & 2) {
+ (Sk4f::Load(&src->fX) * scale4 + trans4).store(&dst->fX);
+ src += 2;
+ dst += 2;
+ }
+ count >>= 2;
+ for (int i = 0; i < count; ++i) {
+ Sk4f s0 = Sk4f::Load(&src[0].fX);
+ Sk4f s1 = Sk4f::Load(&src[2].fX);
+ (s0 * scale4 + trans4).store(&dst[0].fX);
+ (s1 * scale4 + trans4).store(&dst[2].fX);
+ src += 4;
+ dst += 4;
+ }
+ return;
+ }
+ if (mask < SkMatrix::kPerspective_Mask) { // affine
+ SkScalar tx = this->getTranslateX();
+ SkScalar ty = this->getTranslateY();
+ SkScalar sx = this->getScaleX();
+ SkScalar sy = this->getScaleY();
+ SkScalar kx = this->getSkewX();
+ SkScalar ky = this->getSkewY();
+ if (count & 1) {
+ dst->set(src->fX * sx + src->fY * kx + tx,
+ src->fX * ky + src->fY * sy + ty);
+ src += 1;
+ dst += 1;
+ }
+ Sk4f trans4(tx, ty, tx, ty);
+ Sk4f scale4(sx, sy, sx, sy);
+ Sk4f skew4(kx, ky, kx, ky); // applied to swizzle of src4
+ count >>= 1;
+ for (int i = 0; i < count; ++i) {
+ Sk4f src4 = Sk4f::Load(&src->fX);
+ Sk4f swz4(src[0].fY, src[0].fX, src[1].fY, src[1].fX); // need ABCD -> BADC
+ (src4 * scale4 + swz4 * skew4 + trans4).store(&dst->fX);
+ src += 2;
+ dst += 2;
+ }
+ return;
+ }
+ // fall through for perspective
+ this->mapPoints(dst, src, count);
+}
+
///////////////////////////////////////////////////////////////////////////////
void SkMatrix::mapHomogeneousPoints(SkScalar dst[], const SkScalar src[], int count) const {
« no previous file with comments | « include/core/SkMatrix.h ('k') | tests/MatrixTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698