diff options
-rw-r--r-- | docs/SkMatrix_Reference.bmh | 68 | ||||
-rw-r--r-- | include/core/SkMatrix.h | 26 | ||||
-rw-r--r-- | src/core/SkMatrixPriv.h | 19 | ||||
-rw-r--r-- | src/gpu/ops/GrAAFillRectOp.cpp | 2 | ||||
-rw-r--r-- | src/gpu/ops/GrAAHairLinePathRenderer.cpp | 9 | ||||
-rw-r--r-- | src/gpu/ops/GrAtlasTextOp.cpp | 5 | ||||
-rw-r--r-- | src/gpu/ops/GrDashOp.cpp | 3 | ||||
-rw-r--r-- | src/gpu/ops/GrLatticeOp.cpp | 5 |
8 files changed, 42 insertions, 95 deletions
diff --git a/docs/SkMatrix_Reference.bmh b/docs/SkMatrix_Reference.bmh index 5828790e61..cd49206454 100644 --- a/docs/SkMatrix_Reference.bmh +++ b/docs/SkMatrix_Reference.bmh @@ -82,7 +82,6 @@ improve performance. Matrix is not thread safe unless getType is called first. # isTranslate # Returns if transform is limited to translate. ## # mapHomogeneousPoints # Maps Point3 array. ## # mapPoints # Maps Point array. ## -# mapPointsWithStride # Maps Point array with padding. ## # mapRadius # Returns mean radius of mapped Circle. ## # mapRect # Returns bounds of mapped Rect. ## # mapRectScaleTranslate # Returns bounds of mapped Rect. ## @@ -3203,7 +3202,7 @@ src and dst may point to the same storage. } ## -#SeeAlso mapPointsWithStride mapXY mapHomogeneousPoints mapVectors +#SeeAlso mapXY mapHomogeneousPoints mapVectors ## @@ -3257,56 +3256,7 @@ Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- } ## -#SeeAlso mapPointsWithStride mapXY mapHomogeneousPoints mapVectors - -## - -# ------------------------------------------------------------------------------ - -#Method void mapPointsWithStride(SkPoint pts[], size_t stride, int count) const - -Maps count pts, skipping stride bytes to advance from one Point to the next. -Points are mapped by multiplying each Point by Matrix. Given: - -#Code -#Literal - | A B C | | x | -Matrix = | D E F |, pt = | y | - | G H I | | 1 | -## - -each resulting pts Point is computed as: - -#Code -#Literal - |A B C| |x| Ax+By+C Dx+Ey+F -Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- - |G H I| |1| Gx+Hy+I Gx+Hy+I -## - -#Param pts storage for mapped Points ## -#Param stride size of record starting with Point, in bytes ## -#Param count number of Points to transform ## - -#Example - SkMatrix matrix; - matrix.reset(); - struct PointZ { - SkPoint fPt; - SkPoint fStationary; - } pts[] = {{{40, 70}, {40, 70}}, {{180, 70}, {180, 70}}, {{180, 220}, {180, 220}}, - {{40, 220}, {40, 220}}}; - constexpr int count = SK_ARRAY_COUNT(pts); - SkPaint paint; - paint.setARGB(77, 23, 99, 154); - for (int i = 0; i < 5; ++i) { - matrix.preRotate(10, 128, 128); - matrix.mapPointsWithStride(&pts[0].fPt, sizeof(PointZ), count); - canvas->drawPoints(SkCanvas::kPolygon_PointMode, count * 2, &pts[0].fPt, paint); - } -## - -#SeeAlso mapPoints mapXY mapHomogeneousPoints mapVectors +#SeeAlso mapXY mapHomogeneousPoints mapVectors ## @@ -3363,7 +3313,7 @@ Matrix * src = |D E F| |y| = |Ax+By+Cz Dx+Ey+Fz Gx+Hy+Iz| debugster(src); ## -#SeeAlso mapPoints mapXY mapPointsWithStride mapVectors +#SeeAlso mapPoints mapXY mapVectors ## @@ -3408,7 +3358,7 @@ Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- canvas->drawPoints(SkCanvas::kPolygon_PointMode, SK_ARRAY_COUNT(lines), lines, paint); ## -#SeeAlso mapPoints mapPointsWithStride mapVectors +#SeeAlso mapPoints mapVectors ## @@ -3457,7 +3407,7 @@ canvas->concat(matrix); canvas->drawBitmap(source, 0, 0); ## -#SeeAlso mapPoints mapPointsWithStride mapVectors +#SeeAlso mapPoints mapVectors ## @@ -3519,7 +3469,7 @@ src and dst may point to the same storage. } ## -#SeeAlso mapVector mapPoints mapPointsWithStride mapXY +#SeeAlso mapVector mapPoints mapXY ## @@ -3575,7 +3525,7 @@ Matrix * vec = |D E 0| |y| = |Ax+By Dx+Ey Gx+Hy+I| = ------- , ------- } ## -#SeeAlso mapVector mapPoints mapPointsWithStride mapXY +#SeeAlso mapVector mapPoints mapXY ## @@ -3624,7 +3574,7 @@ Matrix * vec = |D E 0| |dy| = |A*dx+B*dy D*dx+E*dy G*dx+H*dy+I| = ----------- , } ## -#SeeAlso mapVectors mapPoints mapPointsWithStride mapXY +#SeeAlso mapVectors mapPoints mapXY ## @@ -3674,7 +3624,7 @@ Matrix * vec = |D E 0| |dy| = |A*dx+B*dy D*dx+E*dy G*dx+H*dy+I| = ----------- , } ## -#SeeAlso mapVectors mapPoints mapPointsWithStride mapXY +#SeeAlso mapVectors mapPoints mapXY ## diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h index d1202431d6..edbfedd5b0 100644 --- a/include/core/SkMatrix.h +++ b/include/core/SkMatrix.h @@ -1272,32 +1272,6 @@ public: this->mapPoints(pts, pts, count); } - /** Maps count pts, skipping stride bytes to advance from one SkPoint to the next. - Points are mapped by multiplying each SkPoint by SkMatrix. Given: - - | A B C | | x | - Matrix = | D E F |, pt = | y | - | G H I | | 1 | - - each resulting pts SkPoint is computed as: - - |A B C| |x| Ax+By+C Dx+Ey+F - Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- - |G H I| |1| Gx+Hy+I Gx+Hy+I - - @param pts storage for mapped points - @param stride size of record starting with SkPoint, in bytes - @param count number of points to transform - */ - void mapPointsWithStride(SkPoint pts[], size_t stride, int count) const { - SkASSERT(stride >= sizeof(SkPoint)); - SkASSERT(0 == stride % sizeof(SkScalar)); - for (int i = 0; i < count; ++i) { - this->mapPoints(pts, pts, 1); - pts = (SkPoint*)((intptr_t)pts + stride); - } - } - /** Maps src SkPoint3 array of length count to dst SkPoint3 array, which must of length count or greater. SkPoint3 array is mapped by multiplying each SkPoint3 by SkMatrix. Given: diff --git a/src/core/SkMatrixPriv.h b/src/core/SkMatrixPriv.h index 7c00c4eb52..d5fd243369 100644 --- a/src/core/SkMatrixPriv.h +++ b/src/core/SkMatrixPriv.h @@ -63,6 +63,24 @@ public: return false; } + /** Maps count pts, skipping stride bytes to advance from one SkPoint to the next. + Points are mapped by multiplying each SkPoint by SkMatrix. Given: + + | A B C | | x | + Matrix = | D E F |, pt = | y | + | G H I | | 1 | + + each resulting pts SkPoint is computed as: + + |A B C| |x| Ax+By+C Dx+Ey+F + Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- + |G H I| |1| Gx+Hy+I Gx+Hy+I + + @param mx matrix used to map the points + @param pts storage for mapped points + @param stride size of record starting with SkPoint, in bytes + @param count number of points to transform + */ static void MapPointsWithStride(const SkMatrix& mx, SkPoint pts[], size_t stride, int count) { SkASSERT(stride >= sizeof(SkPoint)); SkASSERT(0 == stride % sizeof(SkScalar)); @@ -106,6 +124,7 @@ public: Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- |G H I| |1| Gx+Hy+I Gx+Hy+I + @param mx matrix used to map the points @param dst storage for mapped points @param src points to transform @param stride size of record starting with SkPoint, in bytes diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp index 5f352ac12b..b1e89af7a8 100644 --- a/src/gpu/ops/GrAAFillRectOp.cpp +++ b/src/gpu/ops/GrAAFillRectOp.cpp @@ -88,7 +88,7 @@ static void generate_aa_fill_rect_geometry(intptr_t verts, // create the rotated rect SkPointPriv::SetRectFan(fan0Pos, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride); - viewMatrix.mapPointsWithStride(fan0Pos, vertexStride, 4); + SkMatrixPriv::MapPointsWithStride(viewMatrix, fan0Pos, vertexStride, 4); // Now create the inset points and then outset the original // rotated points diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp index 2dcee7a4c5..1502b80a50 100644 --- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp @@ -18,6 +18,7 @@ #include "GrResourceProvider.h" #include "GrSimpleMeshDrawOpHelper.h" #include "SkGeometry.h" +#include "SkMatrixPriv.h" #include "SkPoint3.h" #include "SkPointPriv.h" #include "SkStroke.h" @@ -581,7 +582,8 @@ static void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice, intersect_lines(a0.fPos, abN, c0.fPos, cbN, &b0.fPos); if (toSrc) { - toSrc->mapPointsWithStride(&verts[0].fPos, sizeof(BezierVertex), kQuadNumVertices); + SkMatrixPriv::MapPointsWithStride(*toSrc, &verts[0].fPos, sizeof(BezierVertex), + kQuadNumVertices); } } @@ -683,9 +685,8 @@ static void add_line(const SkPoint p[2], (*vert)[5].fCoverage = 0; if (toSrc) { - toSrc->mapPointsWithStride(&(*vert)->fPos, - sizeof(LineVertex), - kLineSegNumVertices); + SkMatrixPriv::MapPointsWithStride(*toSrc, &(*vert)->fPos, sizeof(LineVertex), + kLineSegNumVertices); } } else { // just make it degenerate and likely offscreen diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index 8285d60ee3..e33b67b411 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -286,8 +286,9 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) { pos, pos, vertexStride, result.fGlyphsRegenerated * kVerticesPerGlyph); } else { auto* pos = reinterpret_cast<SkPoint*>(currVertex); - args.fViewMatrix.mapPointsWithStride( - pos, vertexStride, result.fGlyphsRegenerated * kVerticesPerGlyph); + SkMatrixPriv::MapPointsWithStride( + args.fViewMatrix, pos, vertexStride, + result.fGlyphsRegenerated * kVerticesPerGlyph); } } flushInfo.fGlyphsToFlush += result.fGlyphsRegenerated; diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index 583f7b2caf..9728aa98b5 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -17,6 +17,7 @@ #include "GrProcessor.h" #include "GrStyle.h" #include "SkGr.h" +#include "SkMatrixPriv.h" #include "SkPointPriv.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLGeometryProcessor.h" @@ -181,7 +182,7 @@ void setup_dashed_rect_common(const SkRect& rect, const SkMatrix& matrix, T* ver vertices[idx + 2].fPos = SkPoint::Make(rect.fRight, rect.fTop); vertices[idx + 3].fPos = SkPoint::Make(rect.fRight, rect.fBottom); - matrix.mapPointsWithStride(&vertices[idx].fPos, sizeof(T), 4); + SkMatrixPriv::MapPointsWithStride(matrix, &vertices[idx].fPos, sizeof(T), 4); } static void setup_dashed_rect(const SkRect& rect, void* vertices, int idx, diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp index 7438eb2c0a..45081a02fd 100644 --- a/src/gpu/ops/GrLatticeOp.cpp +++ b/src/gpu/ops/GrLatticeOp.cpp @@ -14,6 +14,7 @@ #include "GrSimpleMeshDrawOpHelper.h" #include "SkBitmap.h" #include "SkLatticeIter.h" +#include "SkMatrixPriv.h" #include "SkPointPriv.h" #include "SkRect.h" @@ -152,8 +153,8 @@ private: // If we didn't handle it above, apply the matrix here. if (!isScaleTranslate) { SkPoint* positions = reinterpret_cast<SkPoint*>(patchVerts); - patch.fViewMatrix.mapPointsWithStride( - positions, vertexStride, kVertsPerRect * patch.fIter->numRectsToDraw()); + SkMatrixPriv::MapPointsWithStride(patch.fViewMatrix, positions, vertexStride, + kVertsPerRect * patch.fIter->numRectsToDraw()); } } helper.recordDraw(target, gp.get(), fHelper.makePipeline(target)); |