Pass sampling to drawImage
Bug: skia:7650
Change-Id: I050841a401610b4a68b549602e27c0bac8e62067
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/358196
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/gm/perspshaders.cpp b/gm/perspshaders.cpp
index bcc9531..96d2433 100644
--- a/gm/perspshaders.cpp
+++ b/gm/perspshaders.cpp
@@ -56,9 +56,8 @@
}
void onOnceBeforeDraw() override {
- fBitmap = ToolUtils::create_checkerboard_bitmap(
+ fBitmapImage = ToolUtils::create_checkerboard_image(
kCellSize, kCellSize, SK_ColorBLUE, SK_ColorYELLOW, kCellSize / 10);
- fBitmap.setImmutable();
SkPoint pts1[] = {
{ 0, 0 },
@@ -89,13 +88,12 @@
fPath.close();
}
- void drawRow(SkCanvas* canvas, SkFilterQuality filterQ) {
+ void drawRow(SkCanvas* canvas, const SkSamplingOptions& sampling) {
SkPaint filterPaint;
- filterPaint.setFilterQuality(filterQ);
filterPaint.setAntiAlias(fDoAA);
SkPaint pathPaint;
- pathPaint.setShader(fBitmap.makeShader(SkSamplingOptions(filterQ)));
+ pathPaint.setShader(fBitmapImage->makeShader(sampling));
pathPaint.setAntiAlias(fDoAA);
SkPaint gradPaint1;
@@ -111,13 +109,13 @@
canvas->save();
canvas->concat(fPerspMatrix);
- canvas->drawBitmapRect(fBitmap, r, &filterPaint);
+ canvas->drawImageRect(fBitmapImage, r, sampling, &filterPaint);
canvas->restore();
canvas->translate(SkIntToScalar(kCellSize), 0);
canvas->save();
canvas->concat(fPerspMatrix);
- canvas->drawImage(fImage.get(), 0, 0, &filterPaint);
+ canvas->drawImage(fImage.get(), 0, 0, sampling, &filterPaint);
canvas->restore();
canvas->translate(SkIntToScalar(kCellSize), 0);
@@ -152,13 +150,14 @@
fImage = make_image(canvas, kCellSize, kCellSize);
}
- this->drawRow(canvas, kNone_SkFilterQuality);
+ this->drawRow(canvas, SkSamplingOptions(SkFilterMode::kNearest));
canvas->translate(0, SkIntToScalar(kCellSize));
- this->drawRow(canvas, kLow_SkFilterQuality);
+ this->drawRow(canvas, SkSamplingOptions(SkFilterMode::kLinear));
canvas->translate(0, SkIntToScalar(kCellSize));
- this->drawRow(canvas, kMedium_SkFilterQuality);
+ this->drawRow(canvas, SkSamplingOptions(SkFilterMode::kLinear,
+ SkMipmapMode::kNearest));
canvas->translate(0, SkIntToScalar(kCellSize));
- this->drawRow(canvas, kHigh_SkFilterQuality);
+ this->drawRow(canvas, SkSamplingOptions({1.0f/3, 1.0f/3}));
canvas->translate(0, SkIntToScalar(kCellSize));
}
private:
@@ -172,7 +171,7 @@
sk_sp<SkShader> fLinearGrad2;
SkMatrix fPerspMatrix;
sk_sp<SkImage> fImage;
- SkBitmap fBitmap;
+ sk_sp<SkImage> fBitmapImage;
using INHERITED = GM;
};