Revert "move onto new factories for SkMatrix"

This reverts commit 046c2b7d90.

Reason for revert: need to update/guard flutter

Original change's description:
> move onto new factories for SkMatrix
> 
> Just rename, no functional changes expected.
> 
> Change-Id: Id77ab1cf6b1cab35087a7c56000750912cf47383
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290831
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>

TBR=fmalita@chromium.org,reed@google.com

Change-Id: Ic74f177128913374b8c60b4df88f04cf72fbacb3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291359
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2020-05-21 16:05:02 +00:00 committed by Skia Commit-Bot
parent c7e35b2bfc
commit c80ee456ad
111 changed files with 179 additions and 182 deletions

View File

@ -151,7 +151,7 @@ static void make_unit_star(SkPath* path, int n) {
static void make_poly(SkPath* path) {
make_unit_star(path, 9);
const SkMatrix matrix = SkMatrix::Scale(100, 100);
const SkMatrix matrix = SkMatrix::MakeScale(SkIntToScalar(100), SkIntToScalar(100));
path->transform(matrix);
}

View File

@ -54,11 +54,11 @@ private:
typedef Benchmark INHERITED;
};
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::I(), "ident"); )
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeScale(1), "ident"); )
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::Scale(1.17f, 1.17f), "scale"); )
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeScale(1.17f), "scale"); )
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::Translate(17.5f, 17.5f), "translate"); )
DEF_BENCH( return new DrawBitmapAABench(false, SkMatrix::MakeTrans(17.5f, 17.5f), "translate"); )
DEF_BENCH(
SkMatrix m;
@ -67,11 +67,11 @@ DEF_BENCH(
return new DrawBitmapAABench(false, m, "rotate");
)
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::I(), "ident"); )
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeScale(1), "ident"); )
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::Scale(1.17f, 1.17f), "scale"); )
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeScale(1.17f), "scale"); )
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::Translate(17.5f, 17.5f), "translate"); )
DEF_BENCH( return new DrawBitmapAABench(true, SkMatrix::MakeTrans(17.5f, 17.5f), "translate"); )
DEF_BENCH(
SkMatrix m;

View File

@ -60,7 +60,7 @@ protected:
SkPath path;
this->makePath(&path);
if (fFlags & kBig_Flag) {
const SkMatrix m = SkMatrix::Scale(3, 3);
const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(3), SkIntToScalar(3));
path.transform(m);
}

View File

@ -266,7 +266,7 @@ DEF_BENCH( return new InvertMapRectMatrixBench(
///////////////////////////////////////////////////////////////////////////////
static SkMatrix make_trans() { return SkMatrix::Translate(2, 3); }
static SkMatrix make_trans() { return SkMatrix::MakeTrans(2, 3); }
static SkMatrix make_scale() { SkMatrix m(make_trans()); m.postScale(1.5f, 0.5f); return m; }
static SkMatrix make_afine() { SkMatrix m(make_trans()); m.postRotate(15); return m; }

View File

@ -58,7 +58,7 @@ protected:
SkPath path;
this->makePath(&path);
if (fFlags & kBig_Flag) {
const SkMatrix m = SkMatrix::Scale(10, 10);
const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(10), SkIntToScalar(10));
path.transform(m);
}

View File

@ -53,7 +53,7 @@ class ConcatBench : public Benchmark {
void onDraw(int loops, SkCanvas* canvas) override {
while (loops --> 0) {
canvas->setMatrix(SkMatrix::Scale(3, 3));
canvas->setMatrix(SkMatrix::MakeScale(3.0f));
canvas->concat(fMatrix);
}
}

View File

@ -28,7 +28,7 @@ void SKPAnimationBench::onPerCanvasPreDraw(SkCanvas* canvas) {
void SKPAnimationBench::drawPicture() {
for (int j = 0; j < this->tileRects().count(); ++j) {
SkMatrix trans = SkMatrix::Translate(-1.f * this->tileRects()[j].fLeft,
SkMatrix trans = SkMatrix::MakeTrans(-1.f * this->tileRects()[j].fLeft,
-1.f * this->tileRects()[j].fTop);
fAnimation->preConcatFrameMatrix(fAnimationTime.nextRangeF(0, 1000), fDevBounds, &trans);
this->surfaces()[j]->getCanvas()->drawPicture(this->picture(), &trans, nullptr);

View File

@ -129,7 +129,7 @@ void SKPBench::drawMPDPicture() {
void SKPBench::drawPicture() {
for (int j = 0; j < fTileRects.count(); ++j) {
const SkMatrix trans = SkMatrix::Translate(-fTileRects[j].fLeft / fScale,
const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale,
-fTileRects[j].fTop / fScale);
fSurfaces[j]->getCanvas()->drawPicture(fPic.get(), &trans, nullptr);
}

View File

@ -194,7 +194,7 @@ DEF_BENCH(
);
DEF_BENCH(
return new GrTessellatePathOp::TestingOnly_Benchmark::WangsFormulaBench(
"_scale", SkMatrix::Scale(1.1f, 0.9f));
"_scale", SkMatrix::MakeScale(1.1f, 0.9f));
);
DEF_BENCH(
return new GrTessellatePathOp::TestingOnly_Benchmark::WangsFormulaBench(

View File

@ -62,8 +62,7 @@ SkPath GetBorderPath(float scale,
SkPathDirection::kCCW, right, bottom - 1);
path.close();
if (unscale_at_end && (scale != 1)) path.transform(SkMatrix::Scale(1.f / scale,
1.f / scale));
if (unscale_at_end && (scale != 1)) path.transform(SkMatrix::MakeScale(1.f / scale));
return path;
}
@ -143,12 +142,12 @@ void draw(SkCanvas* canvas) {
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(1);
SkPath path = GetInteriorPath(1.f, SkISize::Make(250, 36), 16);
path.transform(SkMatrix::Translate(0, 30));
path.transform(SkMatrix::MakeTrans(0, 30));
canvas->drawPath(path, p);
p.setColor(SK_ColorBLUE);
SkPath border_path = GetBorderPath(1.f, false, false, 16, SkISize::Make(250, 36));
border_path.transform(SkMatrix::Translate(0, 30));
border_path.transform(SkMatrix::MakeTrans(0, 30));
canvas->drawPath(border_path, p);
// canvas->drawLine(20, 20, 100, 100, p);

View File

@ -4,7 +4,7 @@
// HASH=7ff17718111df6d6f95381d8a8f1b389
REG_FIDDLE(Matrix_MakeScale, 256, 256, false, 4) {
void draw(SkCanvas* canvas) {
canvas->concat(SkMatrix::Scale(4, 3));
canvas->concat(SkMatrix::MakeScale(4, 3));
canvas->drawBitmap(source, 0, 0);
}
} // END FIDDLE

View File

@ -4,7 +4,7 @@
// HASH=2956aeb50fa862cdb13995e1e56a4bc8
REG_FIDDLE(Matrix_MakeScale_2, 256, 256, false, 4) {
void draw(SkCanvas* canvas) {
canvas->concat(SkMatrix::Scale(4, 4));
canvas->concat(SkMatrix::MakeScale(4));
canvas->drawBitmap(source, 0, 0);
}
} // END FIDDLE

View File

@ -4,7 +4,7 @@
// HASH=b2479df0d9cf296ff64ac31e36684557
REG_FIDDLE(Matrix_MakeTrans, 256, 256, false, 4) {
void draw(SkCanvas* canvas) {
SkMatrix matrix = SkMatrix::Translate(64, 48);
SkMatrix matrix = SkMatrix::MakeTrans(64, 48);
for (int i = 0; i < 4; ++i) {
canvas->drawBitmap(source, 0, 0);
canvas->concat(matrix);

View File

@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) {
SkDebugf("success: %s ", success ? "true" : "false");
SkDebugf("scale: %g, %g\n", scale.width(), scale.height());
remaining.dump();
SkMatrix scaleMatrix = SkMatrix::Scale(scale.width(), scale.height());
SkMatrix scaleMatrix = SkMatrix::MakeScale(scale.width(), scale.height());
SkMatrix combined = SkMatrix::Concat(scaleMatrix, remaining);
combined.dump();
}

View File

@ -4,7 +4,7 @@
// HASH=bc6c6f6a5df770287120d87f81b922eb
REG_FIDDLE(Matrix_isFinite, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
SkMatrix matrix = SkMatrix::Translate(SK_ScalarNaN, 0);
SkMatrix matrix = SkMatrix::MakeTrans(SK_ScalarNaN, 0);
matrix.dump();
SkDebugf("matrix is finite: %s\n", matrix.isFinite() ? "true" : "false");
SkDebugf("matrix %c= matrix\n", matrix == matrix ? '=' : '!');

View File

@ -14,7 +14,7 @@ void draw(SkCanvas* canvas) {
SkPath fillPath;
SkPaint outlinePaint(strokePaint);
outlinePaint.setStrokeWidth(2);
SkMatrix scale = SkMatrix::Scale(300, 300);
SkMatrix scale = SkMatrix::MakeScale(300, 300);
for (SkScalar precision : { 0.01f, .1f, 1.f, 10.f, 100.f } ) {
strokePaint.getFillPath(strokePath, &fillPath, nullptr, precision);
fillPath.transform(scale);

View File

@ -13,7 +13,7 @@ sk_sp<SkImage> foo() {
path.lineTo(pts[i] * scale, pts[i + 1] * scale);
}
path.close();
SkMatrix matrix = SkMatrix::Scale(4 * scale, 4 * scale);
SkMatrix matrix = SkMatrix::MakeScale(4 * scale);
SkPaint paint;
paint.setPathEffect(SkPath2DPathEffect::Make(matrix, path));
paint.setAntiAlias(true);

View File

@ -8,7 +8,7 @@ void checkerboard(SkCanvas* canvas) {
SkScalar scale = 10.0f;
SkPath path;
path.addRect(0, 0, scale, scale);
SkMatrix matrix = SkMatrix::Scale(2 * scale, scale);
SkMatrix matrix = SkMatrix::MakeScale(2 * scale, scale);
matrix.preSkew(0.5f, 0);
SkPaint paint;
paint.setPathEffect(SkPath2DPathEffect::Make(matrix, path));

View File

@ -17,7 +17,7 @@ void draw(SkCanvas* canvas) {
SkPath star;
SkParsePath::FromSVGString("M 0 -150 L 88 121 L -143 -46 L 143 -46 L -88 121 Z", &star);
for (int i = 0; i < 13; ++i) {
SkMatrix matrix = SkMatrix::Translate(1482, 1050);
SkMatrix matrix = SkMatrix::MakeTrans(1482, 1050);
matrix.preRotate((360.0 / 13) * i);
matrix.preTranslate(0, -785);
SkAutoCanvasRestore autoCanvasRestore(canvas, true);

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
path.lineTo(pts[i] * scale, pts[i + 1] * scale);
}
path.close();
SkMatrix matrix = SkMatrix::Scale(4 * scale, 4 * scale);
SkMatrix matrix = SkMatrix::MakeScale(4 * scale);
SkPaint paint;
paint.setPathEffect(SkPath2DPathEffect::Make(matrix, path));
paint.setAntiAlias(true);

View File

@ -14,7 +14,7 @@ SkSVGSVG::SkSVGSVG() : INHERITED(SkSVGTag::kSvg) { }
bool SkSVGSVG::onPrepareToRender(SkSVGRenderContext* ctx) const {
auto viewPortRect = ctx->lengthContext().resolveRect(fX, fY, fWidth, fHeight);
auto contentMatrix = SkMatrix::Translate(viewPortRect.x(), viewPortRect.y());
auto contentMatrix = SkMatrix::MakeTrans(viewPortRect.x(), viewPortRect.y());
auto viewPort = SkSize::Make(viewPortRect.width(), viewPortRect.height());
if (fViewBox.isValid()) {

View File

@ -297,14 +297,14 @@ void FuzzNiceMatrix(Fuzz* fuzz, SkMatrix* m) {
case 1: // translate
fuzz->nextRange(&buffer[0], -4000.0f, 4000.0f);
fuzz->nextRange(&buffer[1], -4000.0f, 4000.0f);
*m = SkMatrix::Translate(buffer[0], buffer[1]);
*m = SkMatrix::MakeTrans(buffer[0], buffer[1]);
return;
case 2: // translate + scale
fuzz->nextRange(&buffer[0], -400.0f, 400.0f);
fuzz->nextRange(&buffer[1], -400.0f, 400.0f);
fuzz->nextRange(&buffer[2], -4000.0f, 4000.0f);
fuzz->nextRange(&buffer[3], -4000.0f, 4000.0f);
*m = SkMatrix::Scale(buffer[0], buffer[1]);
*m = SkMatrix::MakeScale(buffer[0], buffer[1]);
m->postTranslate(buffer[2], buffer[3]);
return;
case 3: // affine

View File

@ -121,7 +121,7 @@ static sk_sp<SkShader> make_bg_shader() {
*bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCE,
0xCF, 0xCE);
const SkMatrix m = SkMatrix::Scale(SkIntToScalar(6), SkIntToScalar(6));
const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(6), SkIntToScalar(6));
return bm.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, &m);
}

View File

@ -44,7 +44,8 @@ DEF_SIMPLE_GM(bug6783, canvas, 500, 500) {
sk_sp<SkImage> img = surface->makeImageSnapshot();
SkMatrix m = SkMatrix::Translate(25, 214) * SkMatrix::Scale(2, 2);
SkMatrix m = SkMatrix::Concat(SkMatrix::MakeTrans(25, 214),
SkMatrix::MakeScale(2, 2));
m.preSkew(0.5f, 0.5f);
// The bug was present at all filter levels, but you might not notice it at kNone.

View File

@ -239,7 +239,7 @@ DEF_SIMPLE_GM(clip_shader, canvas, 840, 650) {
canvas->translate(img->width() + 10, img->height() + 10);
canvas->clipShader(sh, SkClipOp::kIntersect);
canvas->save();
SkMatrix lm = SkMatrix::Scale(1.0f/5, 1.0f/5);
SkMatrix lm = SkMatrix::MakeScale(1.0f / 5);
canvas->clipShader(img->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, &lm));
canvas->drawImage(img, 0, 0, nullptr);

View File

@ -192,7 +192,7 @@ protected:
void onDraw(SkCanvas* canvas) override {
SkBlendMode mode = SkBlendMode::kDstOver;
SkMatrix lm = SkMatrix::Translate(0, squareLength * 0.5f);
SkMatrix lm = SkMatrix::MakeTrans(0, squareLength * 0.5f);
sk_sp<SkShader> shaders[] = {
// gradient should appear over color bitmap

View File

@ -101,7 +101,7 @@ protected:
// translate by x,y for the canvas draws and the test target draws.
canvas->save();
canvas->translate(x, y);
const SkMatrix viewMatrix = SkMatrix::Translate(x, y);
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
SkSimpleMatrixProvider matrixProvider(viewMatrix);
// rect to draw

View File

@ -121,7 +121,7 @@ protected:
SkScalar x = 0;
for (int et = 0; et < kGrClipEdgeTypeCnt; ++et) {
const SkMatrix m = SkMatrix::Translate(x, y);
const SkMatrix m = SkMatrix::MakeTrans(x, y);
SkPath p;
path->transform(m, &p);

View File

@ -175,10 +175,10 @@ protected:
rotate.setRotate(25.f);
static const SkMatrix kMatrices[]{
SkMatrix::I(),
SkMatrix::Scale(1.2f, 1.2f),
SkMatrix::MakeScale(1.2f),
SkMatrix::MakeAll(1, 0, 0, 0, -1, 0, 0, 0, 1), // y flipper
SkMatrix::MakeAll(-1, 0, 0, 0, 1, 0, 0, 0, 1), // x flipper
SkMatrix::Scale(0.7f, 0.7f),
SkMatrix::MakeScale(0.7f),
rotate,
SkMatrix::Concat(
SkMatrix::Concat(SkMatrix::MakeAll(-1, 0, 0, 0, 1, 0, 0, 0, 1), rotate),

View File

@ -131,8 +131,8 @@ private:
persp.setPerspY(-0.0015f);
break;
}
persp = SkMatrix::Concat(persp, SkMatrix::Translate(-x, -y));
persp = SkMatrix::Concat(SkMatrix::Translate(x, y), persp);
persp = SkMatrix::Concat(persp, SkMatrix::MakeTrans(-x, -y));
persp = SkMatrix::Concat(SkMatrix::MakeTrans(x, y), persp);
canvas->concat(persp);
if (TranslateWithMatrix::kYes == translateWithMatrix) {
canvas->translate(x, y);

View File

@ -19,7 +19,7 @@ DEF_SIMPLE_GM(draw_bitmap_rect_skbug4734, canvas, 64, 64) {
SkRect rect = SkRect::Make(source.bounds());
rect.inset(0.5, 1.5);
SkRect dst;
SkMatrix::Scale(8, 8).mapRect(&dst, rect);
SkMatrix::MakeScale(8.0f).mapRect(&dst, rect);
canvas->drawBitmapRect(source, rect, dst, nullptr);
}
}

View File

@ -43,7 +43,7 @@ DEF_SIMPLE_GM(drawable, canvas, 180, 275) {
canvas->drawDrawable(drawable.get());
canvas->drawDrawable(drawable.get(), 0, 150);
SkMatrix m = SkMatrix::Scale(1.5f, 0.8f);
SkMatrix m = SkMatrix::MakeScale(1.5f, 0.8f);
m.postTranslate(70, 0);
canvas->drawDrawable(drawable.get(), &m);

View File

@ -143,7 +143,7 @@ static void run(GrContext* ctx, GrRenderTargetContext* rtc, bool subsetSrc, bool
for (int t = 0; t < kSkTileModeCount; ++t) {
auto mode = static_cast<SkTileMode>(t);
GrSamplerState sampler(SkTileModeToWrapMode(mode), GrSamplerState::Filter::kNearest);
SkMatrix m = SkMatrix::Translate(trans.x() - testArea.x(), trans.y() - testArea.y());
SkMatrix m = SkMatrix::MakeTrans(trans.x() - testArea.x(), trans.y() - testArea.y());
// Draw the src subset in the tile mode faded as a reference before drawing the blur
// on top.
{
@ -169,7 +169,7 @@ static void run(GrContext* ctx, GrRenderTargetContext* rtc, bool subsetSrc, bool
refSrc->clear(SK_PMColor4fWHITE);
// Setup an effect to put the original src rect at the correct logical place
// in the temp where the temp's origin is at the top left of refRect.
SkMatrix tm = SkMatrix::Translate(refRect.left(), refRect.top());
SkMatrix tm = SkMatrix::MakeTrans(refRect.left(), refRect.top());
auto fp = GrTextureEffect::MakeSubset(src, kPremul_SkAlphaType, tm, sampler,
SkRect::Make(srcRect), caps);
GrPaint paint;

View File

@ -94,7 +94,7 @@ protected:
}
void drawSet(SkCanvas* canvas) const {
SkMatrix matrix = SkMatrix::Translate(-100, -100);
SkMatrix matrix = SkMatrix::MakeTrans(-100, -100);
canvas->drawPicture(fPicture, &matrix, nullptr);
canvas->drawImage(fImage0.get(), 150, 0);
canvas->drawImage(fImage1.get(), 300, 0);
@ -294,7 +294,7 @@ protected:
}
void drawSet(SkCanvas* canvas) const {
SkMatrix matrix = SkMatrix::Translate(-100, -100);
SkMatrix matrix = SkMatrix::MakeTrans(-100, -100);
canvas->drawPicture(fPicture, &matrix, nullptr);
// Draw the tex first, so it doesn't hit a lucky cache from the raster version. This

View File

@ -122,7 +122,7 @@ protected:
canvas->translate(0, 120);
const SkTileMode tile = SkTileMode::kRepeat;
const SkMatrix localM = SkMatrix::Translate(-50, -50);
const SkMatrix localM = SkMatrix::MakeTrans(-50, -50);
SkPaint paint;
paint.setShader(image->makeShader(tile, tile, &localM));
paint.setAntiAlias(true);

View File

@ -59,9 +59,9 @@ DEF_SIMPLE_GM(localmatriximagefilter, canvas, 640, 640) {
};
const SkMatrix matrices[] = {
SkMatrix::Scale(SK_ScalarHalf, SK_ScalarHalf),
SkMatrix::Scale(2, 2),
SkMatrix::Translate(10, 10)
SkMatrix::MakeScale(SK_ScalarHalf, SK_ScalarHalf),
SkMatrix::MakeScale(2, 2),
SkMatrix::MakeTrans(10, 10)
};
const SkScalar spacer = image0->width() * 3.0f / 2;

View File

@ -34,7 +34,7 @@ static sk_sp<SkImage> make_image(SkCanvas* rootCanvas, SkColor color) {
DEF_SIMPLE_GM(localmatriximageshader, canvas, 250, 250) {
sk_sp<SkImage> redImage = make_image(canvas, SK_ColorRED);
SkMatrix translate = SkMatrix::Translate(100.0f, 0.0f);
SkMatrix translate = SkMatrix::MakeTrans(100.0f, 0.0f);
SkMatrix rotate;
rotate.setRotate(45.0f);
sk_sp<SkShader> redImageShader = redImage->makeShader(&translate);
@ -72,7 +72,7 @@ DEF_SIMPLE_GM(localmatriximageshader_filtering, canvas, 256, 256) {
auto image = GetResourceAsImage("images/mandrill_256.png");
SkPaint p;
p.setFilterQuality(kHigh_SkFilterQuality);
SkMatrix m = SkMatrix::Scale(2, 2);
SkMatrix m = SkMatrix::MakeScale(2.0f);
p.setShader(image->makeShader()->makeWithLocalMatrix(m));
canvas->drawRect(SkRect::MakeXYWH(0, 0, 256, 256), p);

View File

@ -74,8 +74,8 @@ DEF_SIMPLE_GM(localmatrixshader_nested, canvas, 450, 1200) {
},
};
static const auto inner = SkMatrix::Scale(2, 2),
outer = SkMatrix::Translate(20, 20);
static const auto inner = SkMatrix::MakeScale(2, 2),
outer = SkMatrix::MakeTrans(20, 20);
SkPaint border;
border.setAntiAlias(true);

View File

@ -86,7 +86,7 @@ private:
// Draw a boundary rect around the intersection of the clip rect and crop rect.
SkRect cropRectFloat;
SkMatrix::Scale(scale, scale).mapRect(&cropRectFloat, SkRect::Make(cropRect));
SkMatrix::MakeScale(scale, scale).mapRect(&cropRectFloat, SkRect::Make(cropRect));
if (clipRect.intersect(cropRectFloat)) {
SkPaint strokePaint;
strokePaint.setStyle(SkPaint::kStroke_Style);

View File

@ -209,7 +209,7 @@ static SkPath make_path() {
DEF_SIMPLE_GM(perspective_clip, canvas, 800, 800) {
SkPath path = make_path();
auto shader = GetResourceAsImage("images/mandrill_128.png")
->makeShader(SkMatrix::Scale(3, 3));
->makeShader(SkMatrix::MakeScale(3, 3));
SkPaint paint;
paint.setColor({0.75, 0.75, 0.75, 1});

View File

@ -170,7 +170,7 @@ protected:
SkPaint p;
p.setAlphaf(configs[i].opacity);
SkMatrix m = SkMatrix::Scale(configs[i].scaleX, configs[i].scaleY);
SkMatrix m = SkMatrix::MakeScale(configs[i].scaleX, configs[i].scaleY);
if (configs[i].scaleX < 0) {
m.postTranslate(SkIntToScalar(configs[i].size.width()), 0);
}

View File

@ -85,15 +85,15 @@ private:
star7_winding.setFillType(SkPathFillType::kWinding);
SkPath star7_evenOdd = star7_winding;
star7_evenOdd.transform(SkMatrix::Translate(0, fStarSize));
star7_evenOdd.transform(SkMatrix::MakeTrans(0, fStarSize));
star7_evenOdd.setFillType(SkPathFillType::kEvenOdd);
SkPath star5_winding = ToolUtils::make_star(starRect, 5);
star5_winding.transform(SkMatrix::Translate(fStarSize, 0));
star5_winding.transform(SkMatrix::MakeTrans(fStarSize, 0));
star5_winding.setFillType(SkPathFillType::kWinding);
SkPath star5_evenOdd = star5_winding;
star5_evenOdd.transform(SkMatrix::Translate(0, fStarSize));
star5_evenOdd.transform(SkMatrix::MakeTrans(0, fStarSize));
star5_evenOdd.setFillType(SkPathFillType::kEvenOdd);
SkPaint paint;

View File

@ -48,8 +48,8 @@ class RuntimeShader : public skiagm::GM {
DEF_GM(return new RuntimeShader;)
static sk_sp<SkShader> make_shader(sk_sp<SkImage> img, SkISize size) {
SkMatrix scale = SkMatrix::Scale(size.width() / (float)img->width(),
size.height() / (float)img->height());
SkMatrix scale = SkMatrix::MakeScale(size.width() / (float)img->width(),
size.height() / (float)img->height());
return img->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, &scale);
}

View File

@ -121,7 +121,7 @@ protected:
path.close();
}
SkScalar scale = kBoxSize / std::max(path.getBounds().height(), path.getBounds().width());
path.transform(SkMatrix::Scale(scale, scale));
path.transform(SkMatrix::MakeScale(scale, scale));
this->drawRow(canvas, path);
canvas->translate(0, kBoxSize + kPadSize);

View File

@ -154,7 +154,7 @@ protected:
std::move(fp1),
drawRect,
localRect.makeOffset(kT),
SkMatrix::Translate(-kT))) {
SkMatrix::MakeTrans(-kT))) {
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
}
@ -164,7 +164,7 @@ protected:
// rather than a texture subset as a comparison.
drawRect = localRect.makeOffset(x, y);
SkMatrix subsetTextureMatrix = SkMatrix::Concat(
SkMatrix::Translate(-texelSubset.topLeft()), textureMatrices[tm]);
SkMatrix::MakeTrans(-texelSubset.topLeft()), textureMatrices[tm]);
auto fp2 = GrTextureEffect::Make(subsetView, fBitmap.alphaType(),
subsetTextureMatrix,

View File

@ -27,7 +27,7 @@ DEF_SIMPLE_GM(tilemodes_alpha, canvas, 512, 512) {
for (int y = 0; y < 4; ++y) {
for (int x = 0; x < 4; ++x) {
SkRect rect = SkRect::MakeXYWH(128 * x + 1, 128 * y + 1, 126, 126);
SkMatrix matrix = SkMatrix::Translate(rect.x(), rect.y());
SkMatrix matrix = SkMatrix::MakeTrans(rect.x(), rect.y());
SkPaint paint(SkColor4f{0, 0, 0, 0.5f});
paint.setShader(image->makeShader(kModes[x], kModes[y], &matrix));
canvas->drawRect(rect, paint);

View File

@ -41,7 +41,7 @@ static sk_sp<SkShader> make_shader1(SkScalar shaderScale) {
SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW,
};
const SkPoint pts[] = {{kShaderSize / 4, 0}, {3 * kShaderSize / 4, kShaderSize}};
const SkMatrix localMatrix = SkMatrix::Scale(shaderScale, shaderScale);
const SkMatrix localMatrix = SkMatrix::MakeScale(shaderScale, shaderScale);
sk_sp<SkShader> grad = SkGradientShader::MakeLinear(pts, colors, nullptr,
SK_ARRAY_COUNT(colors),
@ -51,8 +51,8 @@ static sk_sp<SkShader> make_shader1(SkScalar shaderScale) {
return shaderScale == 1
? grad
: sk_make_sp<SkLocalMatrixShader>(
sk_make_sp<SkLocalMatrixShader>(std::move(grad), SkMatrix::Translate(-10, 0)),
SkMatrix::Translate(10, 0));
sk_make_sp<SkLocalMatrixShader>(std::move(grad), SkMatrix::MakeTrans(-10, 0)),
SkMatrix::MakeTrans(10, 0));
}
static sk_sp<SkShader> make_shader2() {
@ -384,7 +384,7 @@ DEF_SIMPLE_GM(vertices_data_lerp, canvas, 256, 256) {
}
)";
auto [effect, errorText] = SkRuntimeEffect::Make(SkString(gProg));
SkMatrix scale = SkMatrix::Scale(2, 2);
SkMatrix scale = SkMatrix::MakeScale(2);
sk_sp<SkShader> children[] = {
GetResourceAsImage("images/mandrill_256.png")->makeShader(),
GetResourceAsImage("images/color_wheel.png")->makeShader(scale),

View File

@ -176,7 +176,7 @@ private:
SkRect* bounds) const override {
GrSamplerState samplerState(GrSamplerState::WrapMode::kClampToBorder,
GrSamplerState::Filter::kNearest);
auto m = SkMatrix::Translate(-fX, -fY);
auto m = SkMatrix::MakeTrans(-fX, -fY);
auto subset = SkRect::Make(fMask.dimensions());
auto domain = bounds->makeOffset(-fX, -fY).makeInset(0.5, 0.5);
auto fp = GrTextureEffect::MakeSubset(fMask, kPremul_SkAlphaType, m, samplerState, subset,

View File

@ -342,7 +342,7 @@ protected:
SkScalar x = kTestPad;
// Columns are non-subsetted followed by subsetted with each WrapMode in a row
for (uint32_t j = 0; j < GrSamplerState::kWrapModeCount + 1; ++j) {
SkMatrix ctm = SkMatrix::Translate(x, y);
SkMatrix ctm = SkMatrix::MakeTrans(x, y);
ctm.postScale(10.f, 10.f);
const SkRect* subset = j > 0 ? &kColorRect : nullptr;

View File

@ -87,7 +87,6 @@ public:
static SkMatrix SK_WARN_UNUSED_RESULT Translate(SkVector t) { return Translate(t.x(), t.y()); }
static SkMatrix SK_WARN_UNUSED_RESULT Translate(SkIVector t) { return Translate(t.x(), t.y()); }
#ifdef SK_SUPPORT_LEGACY_MATRIX_FACTORIES
// DEPRECATED
static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkScalar dx, SkScalar dy) {
return Translate(dx, dy);
@ -101,7 +100,6 @@ public:
static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkVector t) { return MakeTrans(t.x(), t.y()); }
static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkIVector t) { return MakeTrans(t.x(), t.y()); }
// end DEPRECATED
#endif
/** Sets SkMatrix to:
@ -1668,10 +1666,6 @@ public:
return result;
}
friend SkMatrix operator*(const SkMatrix& a, const SkMatrix& b) {
return Concat(a, b);
}
/** Sets internal cache to unknown state. Use to force update after repeated
modifications to SkMatrix element reference returned by operator[](int index).
*/

View File

@ -38,7 +38,7 @@ void TransformAdapter2D::onSync() {
}
SkMatrix TransformAdapter2D::totalMatrix() const {
SkMatrix t = SkMatrix::Translate(-fAnchorPoint.x, -fAnchorPoint.y);
SkMatrix t = SkMatrix::MakeTrans(-fAnchorPoint.x, -fAnchorPoint.y);
t.postScale(fScale.x / 100, fScale.y / 100); // 100% based
t.postRotate(fRotation);

View File

@ -95,7 +95,7 @@ protected:
const auto phase_shift = SkVector::Make(phase_vec.fX / layerShaderMatrix.getScaleX(),
phase_vec.fY / layerShaderMatrix.getScaleY())
* std::fmod(fPhase * (1/360.0f), 1);
const auto phase_shader_matrix = SkMatrix::Translate(phase_shift.x(), phase_shift.y());
const auto phase_shader_matrix = SkMatrix::MakeTrans(phase_shift.x(), phase_shift.y());
// The mask is generated using a step gradient shader, spanning 2 x tile width/height,
// and perpendicular to the phase vector.

View File

@ -366,7 +366,7 @@ bool AnimationBuilder::resolveEmbeddedTypefaces(const skjson::ArrayValue& jchars
static constexpr float kPtScale = 0.01f;
// Normalize the path and advance for 1pt.
path.transform(SkMatrix::Scale(kPtScale, kPtScale));
path.transform(SkMatrix::MakeScale(kPtScale, kPtScale));
current_font->fCustomBuilder.setGlyph(glyph_id, advance * kPtScale, path);
}

View File

@ -49,7 +49,7 @@ private:
const auto t = fOffset + index;
// Position, scale & rotation are "scaled" by index/offset.
SkMatrix m = SkMatrix::Translate(-fAnchorPoint.x,
SkMatrix m = SkMatrix::MakeTrans(-fAnchorPoint.x,
-fAnchorPoint.y);
m.postScale(std::pow(fScale.x * .01f, fOffset),
std::pow(fScale.y * .01f, fOffset));

View File

@ -234,7 +234,7 @@ void ParagraphImpl::paint(SkCanvas* canvas, SkScalar x, SkScalar y) {
fState = kDrawn;
}
SkMatrix matrix = SkMatrix::Translate(x + fOrigin.fLeft, y + fOrigin.fTop);
SkMatrix matrix = SkMatrix::MakeTrans(x + fOrigin.fLeft, y + fOrigin.fTop);
canvas->drawPicture(fPicture, &matrix, nullptr);
}

View File

@ -49,7 +49,7 @@ private:
*
* auto m33 = Matrix<SkMatrix>::Make(SkMatrix::I());
* ...
* m33->setMatrix(SkMatrix::Translate(10, 10));
* m33->setMatrix(SkMatrix::MakeTrans(10, 10));
*
*/
template <typename T>

View File

@ -167,7 +167,7 @@ static void inval_test1(skiatest::Reporter* reporter) {
{
// Update transform.
matrix->setMatrix(SkMatrix::Scale(2, 2));
matrix->setMatrix(SkMatrix::MakeScale(2, 2));
std::vector<SkRect> damage = { {0, 0, 300, 200}, { 0, 0, 600, 400} };
check_inval(reporter, root,
SkRect::MakeWH(600, 400),
@ -250,7 +250,7 @@ static void inval_test2(skiatest::Reporter* reporter) {
{
// Update m2.
m2->setMatrix(SkMatrix::Scale(2, 2));
m2->setMatrix(SkMatrix::MakeScale(2, 2));
std::vector<SkRect> damage = { {0, 0, 100, 100}, { 0, 0, 200, 200} };
check_inval(reporter, root,
SkRect::MakeWH(200, 200),
@ -260,7 +260,7 @@ static void inval_test2(skiatest::Reporter* reporter) {
{
// Update shared m1.
m1->setMatrix(SkMatrix::Translate(100, 100));
m1->setMatrix(SkMatrix::MakeTrans(100, 100));
std::vector<SkRect> damage = { { 0, 0, 200, 200}, // draw1 prev bounds
{ 100, 100, 300, 300}, // draw1 new bounds
{ 0, 0, 100, 100}, // draw2 prev bounds

View File

@ -363,9 +363,9 @@ public:
void onOnceBeforeDraw() override {
fRR = SkRRect::MakeRectXY({20, 20, 380, 380}, 50, 50);
auto img = GetResourceAsImage("images/brickwork-texture.jpg");
fImgShader = img->makeShader(SkMatrix::Scale(2, 2));
fImgShader = img->makeShader(SkMatrix::MakeScale(2, 2));
img = GetResourceAsImage("images/brickwork_normal-map.jpg");
fBmpShader = img->makeShader(SkMatrix::Scale(2, 2));
fBmpShader = img->makeShader(SkMatrix::MakeScale(2, 2));
const char code[] = R"(
in shader color_map;

View File

@ -76,7 +76,7 @@ public:
toGlobal = SkMatrix::I();
layerMatrix = ctm;
} else if (ctm.decomposeScale(&scale, &toGlobal)) {
layerMatrix = SkMatrix::Scale(scale.fWidth, scale.fHeight);
layerMatrix = SkMatrix::MakeScale(scale.fWidth, scale.fHeight);
} else {
toGlobal = ctm;
layerMatrix = SkMatrix::I();

View File

@ -505,7 +505,7 @@ class HalfPlaneView3 : public SampleCameraView {
void onOnceBeforeDraw() override {
fPath = make_path();
fShader = GetResourceAsImage("images/mandrill_128.png")
->makeShader(SkMatrix::Scale(3, 3));
->makeShader(SkMatrix::MakeScale(3, 3));
}
bool onChar(SkUnichar uni) override {

View File

@ -61,12 +61,12 @@ private:
void onDrawContent(SkCanvas* canvas) override {
if (fDom) {
canvas->setMatrix(SkMatrix::Scale(3, 3));
canvas->setMatrix(SkMatrix::MakeScale(3));
canvas->clipRect(SkRect::MakeLTRB(0, 0, 400, 400));
switch (fState) {
case kZoomIn:
fDelta += 0.2f;
canvas->scale(fDelta, fDelta);
canvas->concat(SkMatrix::MakeScale(fDelta));
break;
case kScroll:
if (fAnimationLoop > kAnimationIterations/2) {
@ -74,12 +74,12 @@ private:
} else {
fDelta -= 80.f;
}
canvas->scale(fDelta, fDelta);
canvas->concat(SkMatrix::MakeScale(fDelta));
canvas->translate(fDelta, 0);
break;
case kZoomOut:
fDelta += 0.2f;
canvas->scale(fDelta, fDelta);
canvas->concat(SkMatrix::MakeScale(fDelta));
break;
}

View File

@ -382,7 +382,7 @@ public:
fPts[0].set(1, 1);
fPts[1].set(5, 4);
fPts[2].set(2, 6);
SkMatrix::Scale(fZoom, fZoom).mapPoints(fPts, 3);
SkMatrix::MakeScale(SkIntToScalar(fZoom)).mapPoints(fPts, 3);
fIsRect = false;
}

View File

@ -67,7 +67,7 @@ public:
void onDrawContent(SkCanvas* canvas) override {
if (fDoClip) {
SkPath deviceSpaceClipPath = fClipPath;
deviceSpaceClipPath.transform(SkMatrix::Scale(this->width(), this->height()));
deviceSpaceClipPath.transform(SkMatrix::MakeScale(this->width(), this->height()));
canvas->save();
canvas->clipPath(deviceSpaceClipPath, SkClipOp::kDifference, true);
canvas->clear(SK_ColorBLACK);

View File

@ -32,8 +32,8 @@ public:
float theta = 2*3.1415926535897932384626433832785 * i / numSides;
fPath.lineTo(std::cos(theta), std::sin(theta));
}
fPath.transform(SkMatrix::Scale(200, 200));
fPath.transform(SkMatrix::Translate(300, 300));
fPath.transform(SkMatrix::MakeScale(200, 200));
fPath.transform(SkMatrix::MakeTrans(300, 300));
#else
fPath.moveTo(100, 200);
fPath.cubicTo(100, 100, 400, 100, 400, 200);
@ -120,7 +120,7 @@ public:
SkPathPriv::UpdatePathPoint(path, fPtIdx, pt + fCurr - fPrev);
} else {
path->transform(
SkMatrix::Translate(fCurr.x() - fPrev.x(), fCurr.y() - fPrev.y()), path);
SkMatrix::MakeTrans(fCurr.x() - fPrev.x(), fCurr.y() - fPrev.y()), path);
}
}

View File

@ -92,10 +92,10 @@ SkAnimatedImage::SkAnimatedImage(std::unique_ptr<SkAndroidCodec> codec, SkISize
}
if (!fSimple) {
fMatrix = SkMatrix::Translate(-fCropRect.fLeft, -fCropRect.fTop);
fMatrix = SkMatrix::MakeTrans(-fCropRect.fLeft, -fCropRect.fTop);
float scaleX = (float) fScaledSize.width() / fDecodeInfo.width();
float scaleY = (float) fScaledSize.height() / fDecodeInfo.height();
fMatrix.preConcat(SkMatrix::Scale(scaleX, scaleY));
fMatrix.preConcat(SkMatrix::MakeScale(scaleX, scaleY));
}
this->decodeNextFrame();
}

View File

@ -755,7 +755,7 @@ SkCodec::Result SkWuffsCodec::onIncrementalDecodeTwoPass() {
SkRasterClip rc(SkIRect::MakeSize(this->dstInfo().dimensions()));
draw.fRC = &rc;
SkMatrix translate = SkMatrix::Translate(dirty_rect.min_incl_x, dirty_rect.min_incl_y);
SkMatrix translate = SkMatrix::MakeTrans(dirty_rect.min_incl_x, dirty_rect.min_incl_y);
draw.drawBitmap(src, translate, nullptr, paint);
}

View File

@ -574,7 +574,7 @@ void SkBitmapDevice::drawDevice(SkBaseDevice* device, int x, int y, const SkPain
draw.fRC = &fRCStack.rc();
paint.writable()->setShader(src->fBitmap.makeShader());
draw.drawBitmap(*src->fCoverage.get(),
SkMatrix::Translate(SkIntToScalar(x),SkIntToScalar(y)), nullptr, *paint);
SkMatrix::MakeTrans(SkIntToScalar(x),SkIntToScalar(y)), nullptr, *paint);
} else {
BDDraw(this).drawSprite(src->fBitmap, x, y, *paint);
}
@ -628,7 +628,7 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
if (SkImageFilter* filter = paint->getImageFilter()) {
SkIPoint offset = SkIPoint::Make(0, 0);
const SkMatrix matrix = SkMatrix::Concat(
SkMatrix::Translate(SkIntToScalar(-x), SkIntToScalar(-y)), this->localToDevice());
SkMatrix::MakeTrans(SkIntToScalar(-x), SkIntToScalar(-y)), this->localToDevice());
const SkIRect clipBounds = fRCStack.rc().getBounds().makeOffset(-x, -y);
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), fBitmap.colorType(),
@ -679,7 +679,7 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
// (while compensating in the shader matrix).
mask = sk_ref_sp(clipImage);
maskMatrix = totalMatrix;
shaderMatrix = totalInverse * SkMatrix::Translate(x, y);
shaderMatrix = SkMatrix::Concat(totalInverse, SkMatrix::MakeTrans(x, y));
// If the mask is not fully contained within the src layer, we must clip.
if (!srcBounds.contains(clipBounds)) {
@ -698,7 +698,7 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
mask = surf->makeImageSnapshot();
maskMatrix = SkMatrix::I();
shaderMatrix = SkMatrix::Translate(x - maskBounds.x(), y - maskBounds.y());
shaderMatrix = SkMatrix::MakeTrans(x - maskBounds.x(), y - maskBounds.y());
}
SkAutoDeviceTransformRestore adr(this, maskMatrix);

View File

@ -931,7 +931,7 @@ void SkCanvas::DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* filt
toRoot = SkMatrix::I();
layerMatrix = ctm;
} else if (ctm.decomposeScale(&scale, &toRoot)) {
layerMatrix = SkMatrix::Scale(scale.fWidth, scale.fHeight);
layerMatrix = SkMatrix::MakeScale(scale.fWidth, scale.fHeight);
} else {
// Perspective, for now, do no scaling of the layer itself.
// TODO (michaelludwig) - perhaps it'd be better to explore a heuristic scale pulled from
@ -2681,7 +2681,7 @@ void SkCanvas::drawDrawable(SkDrawable* dr, SkScalar x, SkScalar y) {
#endif
RETURN_ON_NULL(dr);
if (x || y) {
SkMatrix matrix = SkMatrix::Translate(x, y);
SkMatrix matrix = SkMatrix::MakeTrans(x, y);
this->onDrawDrawable(dr, &matrix);
} else {
this->onDrawDrawable(dr, nullptr);

View File

@ -44,7 +44,7 @@ void SkClipStackDevice::onClipRegion(const SkRegion& rgn, SkClipOp op) {
SkRegion tmp;
SkPath path;
rgn.getBoundaryPath(&path);
path.transform(SkMatrix::Translate(-origin));
path.transform(SkMatrix::MakeTrans(-origin));
fClipStack.clipPath(path, SkMatrix::I(), op, false);
}

View File

@ -43,7 +43,7 @@ void SkDrawable::draw(SkCanvas* canvas, const SkMatrix* matrix) {
}
void SkDrawable::draw(SkCanvas* canvas, SkScalar x, SkScalar y) {
SkMatrix matrix = SkMatrix::Translate(x, y);
SkMatrix matrix = SkMatrix::MakeTrans(x, y);
this->draw(canvas, &matrix);
}

View File

@ -270,7 +270,7 @@ void SkFont::getWidthsBounds(const SkGlyphID glyphIDs[],
SkScalar scale = strikeSpec.strikeToSourceRatio();
if (bounds) {
SkMatrix scaleMat = SkMatrix::Scale(scale, scale);
SkMatrix scaleMat = SkMatrix::MakeScale(scale);
SkRect* cursor = bounds;
for (auto glyph : glyphs) {
scaleMat.mapRectScaleTranslate(cursor++, glyph->rect());
@ -316,7 +316,7 @@ void SkFont::getPaths(const SkGlyphID glyphIDs[], int count,
void (*proc)(const SkPath*, const SkMatrix&, void*), void* ctx) const {
SkFont font(*this);
SkScalar scale = font.setupForAsPaths(nullptr);
const SkMatrix mx = SkMatrix::Scale(scale, scale);
const SkMatrix mx = SkMatrix::MakeScale(scale);
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeWithNoDevice(font);
SkBulkGlyphMetricsAndPaths paths{strikeSpec};

View File

@ -37,7 +37,7 @@ public:
* Return a matrix that applies the paint's text values: size, scale, skew
*/
static SkMatrix MakeTextMatrix(SkScalar size, SkScalar scaleX, SkScalar skewX) {
SkMatrix m = SkMatrix::Scale(size * scaleX, size);
SkMatrix m = SkMatrix::MakeScale(size * scaleX, size);
if (skewX) {
m.postSkew(skewX, 0);
}

View File

@ -37,7 +37,7 @@ Mapping Mapping::Make(const SkMatrix& ctm, const SkImageFilter* filter) {
// TODO (michaelludwig) - Should maybe strip out any fractional part of the translation in
// 'ctm' so that can be incorporated during regular drawing, instead of by resampling the
// filtered image.
layer = SkMatrix::Scale(scale.fWidth, scale.fHeight);
layer = SkMatrix::MakeScale(scale.fWidth, scale.fHeight);
} else {
// Perspective
// TODO (michaelludwig) - Should investigate choosing a scale factor for the layer matrix

View File

@ -241,11 +241,11 @@ void SkPictureRecord::didConcat44(const SkM44& m) {
}
void SkPictureRecord::didScale(SkScalar x, SkScalar y) {
this->didConcat(SkMatrix::Scale(x, y));
this->didConcat(SkMatrix::MakeScale(x, y));
}
void SkPictureRecord::didTranslate(SkScalar x, SkScalar y) {
this->didConcat(SkMatrix::Translate(x, y));
this->didConcat(SkMatrix::MakeTrans(x, y));
}
void SkPictureRecord::didConcat(const SkMatrix& matrix) {

View File

@ -57,7 +57,7 @@ sk_sp<SkPathEffect> SkMatrixPathEffect::MakeTranslate(SkScalar dx, SkScalar dy)
if (!SkScalarsAreFinite(dx, dy)) {
return nullptr;
}
return sk_sp<SkPathEffect>(new SkMatrixPE(SkMatrix::Translate(dx, dy)));
return sk_sp<SkPathEffect>(new SkMatrixPE(SkMatrix::MakeTrans(dx, dy)));
}
sk_sp<SkPathEffect> SkMatrixPathEffect::Make(const SkMatrix& matrix) {

View File

@ -168,7 +168,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(const Context& c
auto textureFP = GrTextureEffect::Make(
std::move(inputView), input->alphaType(),
SkMatrix::Translate(input->subset().x(), input->subset().y()));
SkMatrix::MakeTrans(input->subset().x(), input->subset().y()));
textureFP = GrColorSpaceXformEffect::Make(std::move(textureFP), input->getColorSpace(),
input->alphaType(), ctx.colorSpace());
if (!textureFP) {

View File

@ -354,7 +354,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
if (background) {
SkRect bgSubset = SkRect::Make(background->subset());
SkMatrix backgroundMatrix = SkMatrix::Translate(
SkMatrix backgroundMatrix = SkMatrix::MakeTrans(
SkIntToScalar(bgSubset.left() - backgroundOffset.fX),
SkIntToScalar(bgSubset.top() - backgroundOffset.fY));
bgFP = GrTextureEffect::MakeSubset(std::move(backgroundView), background->alphaType(),
@ -369,7 +369,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
if (foreground) {
SkRect fgSubset = SkRect::Make(foreground->subset());
SkMatrix foregroundMatrix = SkMatrix::Translate(
SkMatrix foregroundMatrix = SkMatrix::MakeTrans(
SkIntToScalar(fgSubset.left() - foregroundOffset.fX),
SkIntToScalar(fgSubset.top() - foregroundOffset.fY));
auto fgFP = GrTextureEffect::MakeSubset(std::move(foregroundView), foreground->alphaType(),

View File

@ -338,7 +338,7 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(const Context&
}
const auto isProtected = colorView.proxy()->isProtected();
SkMatrix offsetMatrix = SkMatrix::Translate(SkIntToScalar(colorOffset.fX - displOffset.fX),
SkMatrix offsetMatrix = SkMatrix::MakeTrans(SkIntToScalar(colorOffset.fX - displOffset.fX),
SkIntToScalar(colorOffset.fY - displOffset.fY));
std::unique_ptr<GrFragmentProcessor> fp =
@ -472,12 +472,12 @@ std::unique_ptr<GrFragmentProcessor> GrDisplacementMapEffect::Make(SkColorChanne
GrSamplerState::Filter::kNearest);
auto colorEffect = GrTextureEffect::MakeSubset(std::move(color),
kPremul_SkAlphaType,
SkMatrix::Translate(colorSubset.topLeft()),
SkMatrix::MakeTrans(colorSubset.topLeft()),
kColorSampler,
SkRect::Make(colorSubset),
caps);
auto dispM = SkMatrix::Concat(SkMatrix::Translate(displSubset.topLeft()), offsetMatrix);
auto dispM = SkMatrix::Concat(SkMatrix::MakeTrans(displSubset.topLeft()), offsetMatrix);
auto dispEffect = GrTextureEffect::Make(std::move(displacement),
kPremul_SkAlphaType,
dispM,

View File

@ -264,7 +264,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
if (backgroundView.asTextureProxy()) {
SkRect bgSubset = SkRect::Make(background->subset());
SkMatrix bgMatrix = SkMatrix::Translate(
SkMatrix bgMatrix = SkMatrix::MakeTrans(
SkIntToScalar(bgSubset.left() - backgroundOffset.fX),
SkIntToScalar(bgSubset.top() - backgroundOffset.fY));
bgFP = GrTextureEffect::MakeSubset(std::move(backgroundView), background->alphaType(),
@ -279,7 +279,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
if (foregroundView.asTextureProxy()) {
SkRect fgSubset = SkRect::Make(foreground->subset());
SkMatrix fgMatrix = SkMatrix::Translate(
SkMatrix fgMatrix = SkMatrix::MakeTrans(
SkIntToScalar(fgSubset.left() - foregroundOffset.fX),
SkIntToScalar(fgSubset.top() - foregroundOffset.fY));
auto fgFP = GrTextureEffect::MakeSubset(std::move(foregroundView), foreground->alphaType(),

View File

@ -53,7 +53,7 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext,
return false;
}
SkMatrix matrix = SkMatrix::Translate(-SkIntToScalar(maskRect.fLeft),
SkMatrix matrix = SkMatrix::MakeTrans(-SkIntToScalar(maskRect.fLeft),
-SkIntToScalar(maskRect.fTop));
matrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(

View File

@ -79,7 +79,7 @@ static std::unique_ptr<GrFragmentProcessor> create_fp_for_mask(GrSurfaceProxyVie
const GrCaps& caps) {
GrSamplerState samplerState(GrSamplerState::WrapMode::kClampToBorder,
GrSamplerState::Filter::kNearest);
auto m = SkMatrix::Translate(-devBound.fLeft, -devBound.fTop);
auto m = SkMatrix::MakeTrans(-devBound.fLeft, -devBound.fTop);
auto subset = SkRect::Make(devBound.size());
// We scissor to devBounds. The mask's texel centers are aligned to device space
// pixel centers. Hence this domain of texture coordinates.

View File

@ -2011,7 +2011,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
// TODO: Use one transfer buffer for all three planes to reduce map/unmap cost?
auto texMatrix = SkMatrix::Translate(x, y);
auto texMatrix = SkMatrix::MakeTrans(x, y);
SkRect dstRectY = SkRect::Make(dstSize);
SkRect dstRectUV = SkRect::MakeWH(halfW, halfH);

View File

@ -161,7 +161,7 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
// We use device coords to compute the texture coordinates. We take the device coords and apply
// a translation so that the top-left of the device bounds maps to 0,0, and then a scaling
// matrix to normalized coords.
SkMatrix maskMatrix = SkMatrix::Translate(SkIntToScalar(-textureOriginInDeviceSpace.fX),
SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX),
SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);

View File

@ -28,7 +28,7 @@ in uniform half outerThreshold;
}
@coordTransform(mask) {
SkMatrix::Translate(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y()))
SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y()))
}
@cpp {

View File

@ -74,7 +74,7 @@ std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(GrSurfaceProxyView v
dimensions.height() == yDimensions.height() / 2 + 1) {
sy = 0.5f;
}
*planeMatrix.writable() = SkMatrix::Scale(sx, sy);
*planeMatrix.writable() = SkMatrix::MakeScale(sx, sy);
planeMatrix.writable()->preConcat(localMatrix);
planeFilter = subsampledPlaneFilterMode;
if (subset) {

View File

@ -41,7 +41,7 @@ private:
const SkIRect& bounds)
: INHERITED(kGrAlphaThresholdFragmentProcessor_ClassID, kNone_OptimizationFlags)
, maskCoordTransform(
SkMatrix::Translate(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())),
SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())),
mask.proxy(),
mask.origin())
, mask(std::move(mask))

View File

@ -520,8 +520,8 @@ void GrTextBlob::addOp(GrTextTarget* target,
// Calculate the matrix that maps the path glyphs from their size in the strike to
// the graphics source space.
SkScalar scale = subRun->fStrikeSpec.strikeToSourceRatio();
SkMatrix strikeToSource = SkMatrix::Scale(scale, scale);
SkMatrix strikeToSource = SkMatrix::MakeScale(
subRun->fStrikeSpec.strikeToSourceRatio());
strikeToSource.postTranslate(drawOrigin.x(), drawOrigin.y());
if (!needsExactCTM) {
for (const auto& pathPos : subRun->fPaths) {

View File

@ -284,7 +284,7 @@ sk_sp<SkImage> SkImage::makeWithFilter(GrContext* grContext,
// subset's top left corner. But the clip bounds and any crop rects on the filters are in the
// original coordinate system, so configure the CTM to correct crop rects and explicitly adjust
// the clip bounds (since it is assumed to already be in image space).
SkImageFilter_Base::Context context(SkMatrix::Translate(-subset.x(), -subset.y()),
SkImageFilter_Base::Context context(SkMatrix::MakeTrans(-subset.x(), -subset.y()),
clipBounds.makeOffset(-subset.topLeft()),
cache.get(), fInfo.colorType(), fInfo.colorSpace(),
srcSpecialImage.get());

View File

@ -740,7 +740,7 @@ struct PositionedGlyph {
static SkRect get_glyph_bounds_device_space(const SkGlyph* glyph,
SkScalar xScale, SkScalar yScale,
SkPoint xy, const SkMatrix& ctm) {
SkRect glyphBounds = SkMatrix::Scale(xScale, yScale).mapRect(glyph->rect());
SkRect glyphBounds = SkMatrix::MakeScale(xScale, yScale).mapRect(glyph->rect());
glyphBounds.offset(xy);
ctm.mapRect(&glyphBounds); // now in dev space.
return glyphBounds;
@ -1000,7 +1000,7 @@ void SkPDFDevice::drawDevice(SkBaseDevice* device, int x, int y, const SkPaint&
return;
}
SkMatrix matrix = SkMatrix::Translate(SkIntToScalar(x), SkIntToScalar(y));
SkMatrix matrix = SkMatrix::MakeTrans(SkIntToScalar(x), SkIntToScalar(y));
ScopedContentEntry content(this, &this->cs(), matrix, paint);
if (!content) {
return;

View File

@ -13,7 +13,7 @@
SkSweepGradient::SkSweepGradient(const SkPoint& center, SkScalar t0, SkScalar t1,
const Descriptor& desc)
: SkGradientShaderBase(desc, SkMatrix::Translate(-center.x(), -center.y()))
: SkGradientShaderBase(desc, SkMatrix::MakeTrans(-center.x(), -center.y()))
, fCenter(center)
, fTBias(-t0)
, fTScale(1 / (t1 - t0))
@ -64,7 +64,8 @@ void SkSweepGradient::flatten(SkWriteBuffer& buffer) const {
void SkSweepGradient::appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* p,
SkRasterPipeline*) const {
p->append(SkRasterPipeline::xy_to_unit_angle);
p->append_matrix(alloc, SkMatrix::Scale(fTScale, 1) * SkMatrix::Translate(fTBias, 0));
p->append_matrix(alloc, SkMatrix::Concat(SkMatrix::MakeScale(fTScale, 1),
SkMatrix::MakeTrans(fTBias , 0)));
}
skvm::F32 SkSweepGradient::transformT(skvm::Builder* p, skvm::Uniforms* uniforms,

View File

@ -62,7 +62,7 @@ sk_sp<SkShader> SkTwoPointConicalGradient::Create(const SkPoint& c0, SkScalar r0
}
// Concentric case: we can pretend we're radial (with a tiny twist).
const SkScalar scale = sk_ieee_float_divide(1, std::max(r0, r1));
gradientMatrix = SkMatrix::Translate(-c1.x(), -c1.y());
gradientMatrix = SkMatrix::MakeTrans(-c1.x(), -c1.y());
gradientMatrix.postScale(scale, scale);
gradientType = Type::kRadial;
@ -188,7 +188,8 @@ void SkTwoPointConicalGradient::appendGradientStages(SkArenaAlloc* alloc, SkRast
auto scale = std::max(fRadius1, fRadius2) / dRadius;
auto bias = -fRadius1 / dRadius;
p->append_matrix(alloc, SkMatrix::Translate(bias, 0) * SkMatrix::Scale(scale, 1));
p->append_matrix(alloc, SkMatrix::Concat(SkMatrix::MakeTrans(bias, 0),
SkMatrix::MakeScale(scale, 1)));
return;
}

View File

@ -176,7 +176,7 @@ static const std::vector<UniformCTypeMapper>& get_mappers() {
REGISTER(Layout::CType::kSkMatrix, { "half3x3", "float3x3", "double3x3" },
"${pdman}.setSkMatrix(${uniform}, ${var})", // to gpu
"SkMatrix::Scale(SK_FloatNaN, SK_FloatNaN)", // default value
"SkMatrix::MakeScale(SK_FloatNaN)", // default value
"!${oldVar}.cheapEqualTo(${newVar})"), // dirty check
REGISTER(Layout::CType::kSkM44, { "half4x4", "float4x4", "double4x4" },

View File

@ -114,10 +114,10 @@ void SkLuaCanvas::didConcat44(const SkM44&) {
// TODO
}
void SkLuaCanvas::didScale(SkScalar x, SkScalar y) {
this->didConcat(SkMatrix::Scale(x, y));
this->didConcat(SkMatrix::MakeScale(x, y));
}
void SkLuaCanvas::didTranslate(SkScalar x, SkScalar y) {
this->didConcat(SkMatrix::Translate(x, y));
this->didConcat(SkMatrix::MakeTrans(x, y));
}
void SkLuaCanvas::didConcat(const SkMatrix& matrix) {
switch (matrix.getType()) {

View File

@ -594,7 +594,8 @@ void SkBaseDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
SkAutoDeviceTransformRestore adr(
this,
hasPerspective ? SkMatrix::I()
: this->localToDevice() * SkMatrix::Translate(tx, ty));
: SkMatrix::Concat(this->localToDevice(),
SkMatrix::MakeTrans(tx, ty)));
this->drawVertices(vertices, mode, paint);
}
};

View File

@ -245,10 +245,10 @@ static CanvasTest kCanvasTests[] = {
c->skew(SkIntToScalar(1), SkIntToScalar(2));
},
[](SkCanvas* c, skiatest::Reporter* r) {
c->concat(SkMatrix::Scale(2, 3));
c->concat(SkMatrix::MakeScale(2, 3));
},
[](SkCanvas* c, skiatest::Reporter* r) {
c->setMatrix(SkMatrix::Scale(2, 3));
c->setMatrix(SkMatrix::MakeScale(2, 3));
},
[](SkCanvas* c, skiatest::Reporter* r) {
c->clipRect(kRect);

View File

@ -1385,7 +1385,7 @@ static void test_reduced_clip_stack_aa(skiatest::Reporter* reporter) {
SkScalar tx = SkScalarRoundToScalar(sx * alignedRect.x()) - sx * alignedRect.x();
SkScalar ty = SkScalarRoundToScalar(sy * alignedRect.y()) - sy * alignedRect.y();
SkMatrix xform = SkMatrix::Scale(sx, sy);
SkMatrix xform = SkMatrix::MakeScale(sx, sy);
xform.postTranslate(tx, ty);
xform.mapRect(&alignedRect);
xform.mapRect(&rect);

View File

@ -409,7 +409,7 @@ protected:
class CCPR_cache_animationAtlasReuse : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix m = SkMatrix::Translate(kCanvasSize/2, kCanvasSize/2);
SkMatrix m = SkMatrix::MakeTrans(kCanvasSize/2, kCanvasSize/2);
m.preScale(80, 80);
m.preTranslate(-.5,-.5);
this->drawPathsAndFlush(ccpr, m);
@ -454,7 +454,7 @@ DEF_CCPR_TEST(CCPR_cache_animationAtlasReuse)
class CCPR_cache_recycleEntries : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix m = SkMatrix::Translate(kCanvasSize/2, kCanvasSize/2);
SkMatrix m = SkMatrix::MakeTrans(kCanvasSize/2, kCanvasSize/2);
m.preScale(80, 80);
m.preTranslate(-.5,-.5);
@ -499,9 +499,9 @@ class CCPR_cache_mostlyVisible : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix matrices[3] = {
SkMatrix::Scale(kCanvasSize/2, kCanvasSize/2), // Fully visible.
SkMatrix::Scale(kCanvasSize * 1.25, kCanvasSize * 1.25), // Mostly visible.
SkMatrix::Scale(kCanvasSize * 1.5, kCanvasSize * 1.5), // Mostly NOT visible.
SkMatrix::MakeScale(kCanvasSize/2, kCanvasSize/2), // Fully visible.
SkMatrix::MakeScale(kCanvasSize * 1.25, kCanvasSize * 1.25), // Mostly visible.
SkMatrix::MakeScale(kCanvasSize * 1.5, kCanvasSize * 1.5), // Mostly NOT visible.
};
for (int i = 0; i < 10; ++i) {
@ -553,7 +553,7 @@ DEF_CCPR_TEST(CCPR_cache_mostlyVisible)
class CCPR_cache_deferredCleanup : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix m = SkMatrix::Scale(20, 20);
SkMatrix m = SkMatrix::MakeScale(20, 20);
int lastRenderedAtlasID = 0;
for (int i = 0; i < 5; ++i) {
@ -590,7 +590,7 @@ class CCPR_cache_hashTable : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
using CoverageType = GrCCAtlas::CoverageType;
SkMatrix m = SkMatrix::Scale(20, 20);
SkMatrix m = SkMatrix::MakeScale(20, 20);
for (int i = 0; i < 5; ++i) {
this->drawPathsAndFlush(ccpr, m);
@ -688,7 +688,7 @@ class CCPR_cache_multiTileCache : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
// Make sure a path drawn over 9 tiles gets cached (1 tile out of 9 is >10% visibility).
const SkMatrix m0 = SkMatrix::Scale(kCanvasSize*3, kCanvasSize*3);
const SkMatrix m0 = SkMatrix::MakeScale(kCanvasSize*3, kCanvasSize*3);
const SkPath p0 = fPaths[0];
for (int i = 0; i < 9; ++i) {
static constexpr int kRowOrder[9] = {0,1,1,0,2,2,2,1,0};
@ -711,7 +711,7 @@ class CCPR_cache_multiTileCache : public CCPRCacheTest {
}
// Now make sure paths don't get cached when visibility is <10% for every draw (12 tiles).
const SkMatrix m1 = SkMatrix::Scale(kCanvasSize*4, kCanvasSize*3);
const SkMatrix m1 = SkMatrix::MakeScale(kCanvasSize*4, kCanvasSize*3);
const SkPath p1 = fPaths[1];
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 4; ++col) {
@ -751,8 +751,8 @@ class CCPR_cache_partialInvalidate : public CCPRCacheTest {
void onRun(skiatest::Reporter* reporter, CCPRPathDrawer& ccpr,
const RecordLastMockAtlasIDs& atlasIDRecorder) override {
SkMatrix matrices[2] = {
SkMatrix::Translate(5, 5),
SkMatrix::Translate(kCanvasSize - kPathSize - 5, kCanvasSize - kPathSize - 5)
SkMatrix::MakeTrans(5, 5),
SkMatrix::MakeTrans(kCanvasSize - kPathSize - 5, kCanvasSize - kPathSize - 5)
};
matrices[0].preScale(kPathSize, kPathSize);
matrices[1].preScale(kPathSize, kPathSize);

View File

@ -232,8 +232,8 @@ static void test_crop_fully_covered(skiatest::Reporter* r, const SkMatrix& viewM
TEST(AxisAligned) {
test_axis_aligned(r, SkMatrix::I());
test_axis_aligned(r, SkMatrix::Scale(-1.f, 1.f));
test_axis_aligned(r, SkMatrix::Scale(1.f, -1.f));
test_axis_aligned(r, SkMatrix::MakeScale(-1.f, 1.f));
test_axis_aligned(r, SkMatrix::MakeScale(1.f, -1.f));
SkMatrix rotation;
rotation.setRotate(90.f);

View File

@ -73,7 +73,7 @@ static void test_dont_find_if_diff_key(skiatest::Reporter* reporter,
SkIRect clip2 = SkIRect::MakeWH(200, 200);
SkImageFilterCacheKey key0(0, SkMatrix::I(), clip1, image->uniqueID(), image->subset());
SkImageFilterCacheKey key1(1, SkMatrix::I(), clip1, image->uniqueID(), image->subset());
SkImageFilterCacheKey key2(0, SkMatrix::Translate(5, 5), clip1,
SkImageFilterCacheKey key2(0, SkMatrix::MakeTrans(5, 5), clip1,
image->uniqueID(), image->subset());
SkImageFilterCacheKey key3(0, SkMatrix::I(), clip2, image->uniqueID(), image->subset());
SkImageFilterCacheKey key4(0, SkMatrix::I(), clip1, subset->uniqueID(), subset->subset());

View File

@ -1915,7 +1915,7 @@ DEF_TEST(ImageSourceBounds, reporter) {
REPORTER_ASSERT(reporter,
input == source1->filterBounds(input, SkMatrix::I(),
SkImageFilter::kReverse_MapDirection, &input));
SkMatrix scale(SkMatrix::Scale(2, 2));
SkMatrix scale(SkMatrix::MakeScale(2));
SkIRect scaledBounds = SkIRect::MakeWH(128, 128);
REPORTER_ASSERT(reporter,
scaledBounds == source1->filterBounds(input, scale,

Some files were not shown because too many files have changed in this diff Show More