Fix bug in 1xN SkBitmapProcShader optimization

https://codereview.appspot.com/7187047/



git-svn-id: http://skia.googlecode.com/svn/trunk@7325 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2013-01-22 20:29:16 +00:00
parent 962f2d4e61
commit 1e3052354a
2 changed files with 30 additions and 17 deletions

View File

@ -33,6 +33,7 @@ class ConstXTileBench : public SkBenchmark {
SkString fName;
bool fDoFilter;
bool fDoTrans;
bool fDoScale;
enum { N = SkBENCHLOOP(20) };
static const int kWidth = 1;
static const int kHeight = 300;
@ -42,10 +43,12 @@ public:
SkShader::TileMode xTile,
SkShader::TileMode yTile,
bool doFilter,
bool doTrans)
bool doTrans,
bool doScale)
: INHERITED(param)
, fDoFilter(doFilter)
, fDoTrans(doTrans) {
, fDoTrans(doTrans)
, fDoScale(doScale) {
SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, kWidth, kHeight);
@ -72,6 +75,10 @@ public:
if (doTrans) {
fName.append("_trans");
}
if (doScale) {
fName.append("_scale");
}
}
protected:
@ -89,7 +96,7 @@ protected:
SkRect r;
if (fDoFilter) {
if (fDoScale) {
r = SkRect::MakeWH(SkIntToScalar(2 * 640), SkIntToScalar(2 * 480));
canvas->scale(SK_ScalarHalf, SK_ScalarHalf);
} else {
@ -112,19 +119,18 @@ private:
typedef SkBenchmark INHERITED;
};
DEF_BENCH(return new ConstXTileBench(p, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, false, false, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, false, false, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode, false, false, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, false, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, false, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode, false, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, true, false, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, true, false, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode, true, false, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, true, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, true, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode, true, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, false, true, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, false, true, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode, false, true, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, false, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, false, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode, false, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, true, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, true, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode, true, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, true, true, false))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, true, true, true))
DEF_BENCH(return new ConstXTileBench(p, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode, true, true, false))

View File

@ -455,7 +455,11 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf,
&pt);
yTemp = SkScalarFloorToInt(pt.fY);
// When the matrix has a scale component the setup code in
// chooseProcs multiples the inverse matrix by the inverse of the
// bitmap's width and height. Since this method is going to do
// its own tiling and sampling we need to undo that here.
yTemp = SkScalarFloorToInt(pt.fY * s.fBitmap->height());
} else {
yTemp = s.fFilterOneY + y;
}
@ -481,6 +485,9 @@ static void S32_D32_constX_shaderproc(const SkBitmapProcState& s,
SkIntToScalar(x) + SK_ScalarHalf,
SkIntToScalar(y) + SK_ScalarHalf,
&pt);
if (s.fInvType > SkMatrix::kTranslate_Mask) {
pt.fY *= s.fBitmap->height();
}
int iY2;
switch (s.fTileModeY) {