Add outer blur to bleed GM family

Review URL: https://codereview.chromium.org/1429863007
This commit is contained in:
bsalomon 2015-11-04 04:36:12 -08:00 committed by Commit bot
parent e95a06883b
commit f57ef1c05f

View File

@ -59,11 +59,13 @@ static void draw_texture_bitmap_rect(SkCanvas* canvas, const SkBitmap& bitmap, c
if (kAlpha_8_GrPixelConfig == texture->config()) {
SkAutoMalloc pixels(texture->width() * texture->height());
memset(pixels.get(), 0, texture->width() * texture->height());
texture->writePixels(0, 0, texture->width(), texture->height(), desc.fConfig, pixels.get(), 0);
texture->writePixels(0, 0, texture->width(), texture->height(), desc.fConfig, pixels.get(),
0);
} else {
SkAutoMalloc pixels(texture->width() * texture->height() * sizeof(uint32_t));
SkOpts::memset32((uint32_t*)pixels.get(), 0xFF00FF00, texture->width()*texture->height());
texture->writePixels(0, 0, texture->width(), texture->height(), desc.fConfig, pixels.get(), 0);
texture->writePixels(0, 0, texture->width(), texture->height(), desc.fConfig, pixels.get(),
0);
}
// Upload the bitmap contents to the upper left.
@ -260,7 +262,7 @@ protected:
}
SkISize onISize() override {
return SkISize::Make(1050, 780);
return SkISize::Make(1200, 1080);
}
void onOnceBeforeDraw() override {
@ -329,7 +331,7 @@ protected:
gBleedRec[fBT].fDraw(canvas, fBitmapBig, fImageBig, src, dst, &paint, constraint);
}
// Draw the center of the small bitmap with a mask filter
// Draw the center of the small bitmap with a normal blur
void drawCase4(SkCanvas* canvas, int transX, int transY, bool aa,
SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
SkRect src = SkRect::MakeXYWH(2, 2,
@ -350,6 +352,27 @@ protected:
gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, src, dst, &paint, constraint);
}
// Draw the center of the small bitmap with a outer blur
void drawCase5(SkCanvas* canvas, int transX, int transY, bool aa,
SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) {
SkRect src = SkRect::MakeXYWH(2, 2,
SkIntToScalar(kSmallTextureSize - 4),
SkIntToScalar(kSmallTextureSize - 4));
SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY),
SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize));
SkPaint paint;
paint.setFilterQuality(filter);
SkMaskFilter* mf = SkBlurMaskFilter::Create(kOuter_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(7));
paint.setMaskFilter(mf)->unref();
paint.setShader(fShader);
paint.setColor(SK_ColorBLUE);
paint.setAntiAlias(aa);
gBleedRec[fBT].fDraw(canvas, fBitmapSmall, fImageSmall, src, dst, &paint, constraint);
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorGRAY);
SkTDArray<SkMatrix> matrices;
@ -358,7 +381,7 @@ protected:
// Draw with rotation and scale down in x, up in y.
SkMatrix m;
static const SkScalar kBottom = SkIntToScalar(kRow3Y + kBlockSize + kBlockSpacing);
static const SkScalar kBottom = SkIntToScalar(kRow4Y + kBlockSize + kBlockSpacing);
m.setTranslate(0, kBottom);
m.preRotate(15.f, 0, kBottom + kBlockSpacing);
m.preScale(0.71f, 1.22f);
@ -388,36 +411,42 @@ protected:
this->drawCase2(canvas, kCol0X, kRow1Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
this->drawCase3(canvas, kCol0X, kRow2Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
this->drawCase4(canvas, kCol0X, kRow3Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
this->drawCase5(canvas, kCol0X, kRow4Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality);
// Then draw a column with no bleeding and low filtering
this->drawCase1(canvas, kCol1X, kRow0Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
this->drawCase2(canvas, kCol1X, kRow1Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
this->drawCase3(canvas, kCol1X, kRow2Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
this->drawCase4(canvas, kCol1X, kRow3Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
this->drawCase5(canvas, kCol1X, kRow4Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality);
// Then draw a column with no bleeding and high filtering
this->drawCase1(canvas, kCol2X, kRow0Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
this->drawCase2(canvas, kCol2X, kRow1Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
this->drawCase3(canvas, kCol2X, kRow2Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
this->drawCase4(canvas, kCol2X, kRow3Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
this->drawCase5(canvas, kCol2X, kRow4Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality);
// Then draw a column with bleeding and no filtering (bleed should have no effect w/out blur)
this->drawCase1(canvas, kCol3X, kRow0Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
this->drawCase2(canvas, kCol3X, kRow1Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
this->drawCase3(canvas, kCol3X, kRow2Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
this->drawCase4(canvas, kCol3X, kRow3Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
this->drawCase5(canvas, kCol3X, kRow4Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality);
// Then draw a column with bleeding and low filtering
this->drawCase1(canvas, kCol4X, kRow0Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
this->drawCase2(canvas, kCol4X, kRow1Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
this->drawCase3(canvas, kCol4X, kRow2Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
this->drawCase4(canvas, kCol4X, kRow3Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
this->drawCase5(canvas, kCol4X, kRow4Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality);
// Finally draw a column with bleeding and high filtering
this->drawCase1(canvas, kCol5X, kRow0Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
this->drawCase2(canvas, kCol5X, kRow1Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
this->drawCase3(canvas, kCol5X, kRow2Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
this->drawCase4(canvas, kCol5X, kRow3Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
this->drawCase5(canvas, kCol5X, kRow4Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality);
SkPoint corners[] = { { 0, 0 },{ 0, kBottom },{ kWidth, kBottom },{ kWidth, 0 } };
matrices[m].mapPoints(corners, 4);
@ -438,7 +467,7 @@ protected:
private:
static const int kBlockSize = 70;
static const int kBlockSpacing = 5;
static const int kBlockSpacing = 12;
static const int kCol0X = kBlockSpacing;
static const int kCol1X = 2*kBlockSpacing + kBlockSize;
@ -452,6 +481,7 @@ private:
static const int kRow1Y = 2*kBlockSpacing + kBlockSize;
static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize;
static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize;
static const int kRow4Y = 5*kBlockSpacing + 4*kBlockSize;
static const int kSmallTextureSize = 6;
static const int kMaxTileSize = 32;