Add matrix constructing helpers to SkMatrix
Review URL: https://codereview.chromium.org/1034273002
This commit is contained in:
parent
41f88f0251
commit
1d24b8dfe9
@ -153,8 +153,7 @@ static void make_unit_star(SkPath* path, int n) {
|
||||
|
||||
static void make_poly(SkPath* path) {
|
||||
make_unit_star(path, 9);
|
||||
SkMatrix matrix;
|
||||
matrix.setScale(SkIntToScalar(100), SkIntToScalar(100));
|
||||
const SkMatrix matrix = SkMatrix::MakeScale(SkIntToScalar(100), SkIntToScalar(100));
|
||||
path->transform(matrix);
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,7 @@ protected:
|
||||
SkPath path;
|
||||
this->makePath(&path);
|
||||
if (fFlags & kBig_Flag) {
|
||||
SkMatrix m;
|
||||
m.setScale(SkIntToScalar(3), SkIntToScalar(3));
|
||||
const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(3), SkIntToScalar(3));
|
||||
path.transform(m);
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,7 @@ protected:
|
||||
SkPath path;
|
||||
this->makePath(&path);
|
||||
if (fFlags & kBig_Flag) {
|
||||
SkMatrix m;
|
||||
m.setScale(SkIntToScalar(10), SkIntToScalar(10));
|
||||
const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(10), SkIntToScalar(10));
|
||||
path.transform(m);
|
||||
}
|
||||
|
||||
|
@ -116,9 +116,8 @@ void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
|
||||
} else {
|
||||
for (int i = 0; i < loops; i++) {
|
||||
for (int j = 0; j < fTileRects.count(); ++j) {
|
||||
SkMatrix trans;
|
||||
trans.setTranslate(-fTileRects[j].fLeft / fScale,
|
||||
-fTileRects[j].fTop / fScale);
|
||||
const SkMatrix trans = SkMatrix::MakeTrans(-fTileRects[j].fLeft / fScale,
|
||||
-fTileRects[j].fTop / fScale);
|
||||
fSurfaces[j]->getCanvas()->drawPicture(fPic, &trans, NULL);
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,7 @@ static SkShader* make_bg_shader() {
|
||||
*bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCC,
|
||||
0xCC, 0xCC);
|
||||
|
||||
SkMatrix m;
|
||||
m.setScale(SkIntToScalar(6), SkIntToScalar(6));
|
||||
const SkMatrix m = SkMatrix::MakeScale(SkIntToScalar(6), SkIntToScalar(6));
|
||||
SkShader* s = SkShader::CreateBitmapShader(bm,
|
||||
SkShader::kRepeat_TileMode,
|
||||
SkShader::kRepeat_TileMode,
|
||||
|
@ -191,9 +191,8 @@ protected:
|
||||
SkDEBUGFAIL("Couldn't get Gr test target.");
|
||||
return;
|
||||
}
|
||||
SkMatrix m;
|
||||
const SkMatrix m = SkMatrix::MakeTrans(x, y);
|
||||
SkPath p;
|
||||
m.setTranslate(x, y);
|
||||
path->transform(m, &p);
|
||||
|
||||
GrPrimitiveEdgeType edgeType = (GrPrimitiveEdgeType) et;
|
||||
|
@ -423,8 +423,8 @@ static void tiled(SkCanvas* finalCanvas, SkMultiPictureDraw* mpd,
|
||||
|
||||
SkCanvas* subCanvas = step.fSurf->getCanvas();
|
||||
|
||||
SkMatrix trans;
|
||||
trans.setTranslate(-SkIntToScalar(x*kTileWidth), -SkIntToScalar(y*kTileHeight));
|
||||
const SkMatrix trans = SkMatrix::MakeTrans(-SkIntToScalar(x*kTileWidth),
|
||||
-SkIntToScalar(y*kTileHeight));
|
||||
|
||||
create_content(mpd, pfGen, pictures, subCanvas, trans);
|
||||
}
|
||||
|
@ -124,8 +124,7 @@ protected:
|
||||
if (!fp) {
|
||||
continue;
|
||||
}
|
||||
SkMatrix viewMatrix;
|
||||
viewMatrix.setTranslate(x, y);
|
||||
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
|
||||
GrPipelineBuilder pipelineBuilder;
|
||||
pipelineBuilder.setRenderTarget(rt);
|
||||
pipelineBuilder.addColorProcessor(fp);
|
||||
|
@ -23,6 +23,18 @@ class SkString;
|
||||
*/
|
||||
class SK_API SkMatrix {
|
||||
public:
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar sx, SkScalar sy) {
|
||||
SkMatrix m;
|
||||
m.setScale(sx, sy);
|
||||
return m;
|
||||
}
|
||||
|
||||
static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkScalar dx, SkScalar dy) {
|
||||
SkMatrix m;
|
||||
m.setTranslate(dx, dy);
|
||||
return m;
|
||||
}
|
||||
|
||||
/** Enum of bit fields for the mask return by getType().
|
||||
Use this to identify the complexity of the matrix.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user