filter-quality is deprecated, pass sampling to drawImage
Bug: skia:7650 Change-Id: Ifd92705bd042db74a6c2527858239b0b8e5a4def Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360981 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
ecdd979bc0
commit
039f1367ae
@ -115,13 +115,13 @@ protected:
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setFilterQuality(kLow_SkFilterQuality);
|
||||
|
||||
for (int i = 0; i < kRectCount; ++i) {
|
||||
int imageIndex = kImageMode == ImageMode::kShared ? 0 : i;
|
||||
SkIRect srcRect = SkIRect::MakeWH(fImages[imageIndex]->width(),
|
||||
SkRect srcRect = SkRect::MakeIWH(fImages[imageIndex]->width(),
|
||||
fImages[imageIndex]->height());
|
||||
canvas->drawImageRect(fImages[imageIndex].get(), srcRect, fRects[i], &paint,
|
||||
canvas->drawImageRect(fImages[imageIndex].get(), srcRect, fRects[i],
|
||||
SkSamplingOptions(SkFilterMode::kLinear), &paint,
|
||||
SkCanvas::kFast_SrcRectConstraint);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ protected:
|
||||
void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& paint) {
|
||||
canvas->save();
|
||||
canvas->clipIRect(fImage->bounds().makeOffset(x, y));
|
||||
canvas->drawImage(fImage, SkIntToScalar(x), SkIntToScalar(y), &paint);
|
||||
canvas->drawImage(fImage, SkIntToScalar(x), SkIntToScalar(y), SkSamplingOptions(), &paint);
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ static void draw_image(SkCanvas* canvas, SkImage* img) {
|
||||
// optmizations
|
||||
SkPaint paint;
|
||||
paint.setAlpha(0x10);
|
||||
canvas->drawImage(img, 0, 0, &paint);
|
||||
canvas->drawImage(img, 0, 0, SkSamplingOptions(), &paint);
|
||||
}
|
||||
|
||||
void set_cache_budget(SkCanvas* canvas, int approxImagesInBudget) {
|
||||
|
@ -49,19 +49,19 @@ protected:
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkPaint paint;
|
||||
auto img = make_bm();
|
||||
canvas->drawImage(img, 10, 10, &paint);
|
||||
canvas->drawImage(img, 10, 10);
|
||||
canvas->translate(img->width() + SkIntToScalar(10), 0);
|
||||
|
||||
paint.setMaskFilter(SkEmbossMaskFilter::Make(
|
||||
SkBlurMask::ConvertRadiusToSigma(3),
|
||||
{ { SK_Scalar1, SK_Scalar1, SK_Scalar1 }, 0, 128, 16*2 }));
|
||||
canvas->drawImage(img, 10, 10, &paint);
|
||||
canvas->drawImage(img, 10, 10, SkSamplingOptions(), &paint);
|
||||
canvas->translate(img->width() + SkIntToScalar(10), 0);
|
||||
|
||||
// this combination of emboss+colorfilter used to crash -- so we exercise it to
|
||||
// confirm that we have a fix.
|
||||
paint.setColorFilter(SkColorFilters::Blend(0xFFFF0000, SkBlendMode::kSrcATop));
|
||||
canvas->drawImage(img, 10, 10, &paint);
|
||||
canvas->drawImage(img, 10, 10, SkSamplingOptions(), &paint);
|
||||
canvas->translate(img->width() + SkIntToScalar(10), 0);
|
||||
|
||||
paint.setAntiAlias(true);
|
||||
|
@ -153,11 +153,11 @@ private:
|
||||
|
||||
static constexpr SkScalar kPad = 5.f;
|
||||
|
||||
constexpr SkFilterQuality kQualities[] = {
|
||||
kNone_SkFilterQuality,
|
||||
kLow_SkFilterQuality,
|
||||
kMedium_SkFilterQuality,
|
||||
kHigh_SkFilterQuality,
|
||||
const SkSamplingOptions kSamplings[] = {
|
||||
SkSamplingOptions(SkFilterMode::kNearest),
|
||||
SkSamplingOptions(SkFilterMode::kLinear),
|
||||
SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear),
|
||||
SkSamplingOptions({1.0f/3, 1.0f/3}),
|
||||
};
|
||||
|
||||
constexpr SkScalar kScales[] = {1.0f, 1.2f, 0.75f};
|
||||
@ -170,16 +170,14 @@ private:
|
||||
for (auto s : kScales) {
|
||||
canvas->save();
|
||||
canvas->scale(s, s);
|
||||
for (auto q : kQualities) {
|
||||
for (auto s : kSamplings) {
|
||||
// drawImage
|
||||
SkPaint plainPaint;
|
||||
plainPaint.setFilterQuality(q);
|
||||
canvas->drawImage(img, 0, 0, &plainPaint);
|
||||
canvas->drawImage(img, 0, 0, s);
|
||||
canvas->translate(w + kPad, 0);
|
||||
|
||||
// clamp/clamp shader
|
||||
SkPaint clampPaint;
|
||||
clampPaint.setShader(fGradImgs[i]->makeShader(SkSamplingOptions(q)));
|
||||
clampPaint.setShader(fGradImgs[i]->makeShader(s));
|
||||
canvas->drawRect(SkRect::MakeWH(1.5f*w, 1.5f*h), clampPaint);
|
||||
canvas->translate(1.5f*w + kPad, 0);
|
||||
|
||||
@ -187,14 +185,14 @@ private:
|
||||
SkPaint repeatPaint;
|
||||
repeatPaint.setShader(fGradImgs[i]->makeShader(SkTileMode::kRepeat,
|
||||
SkTileMode::kMirror,
|
||||
SkSamplingOptions(q)));
|
||||
s));
|
||||
canvas->drawRect(SkRect::MakeWH(1.5f*w, 1.5f*h), repeatPaint);
|
||||
canvas->translate(1.5f*w + kPad, 0);
|
||||
|
||||
// drawImageRect with kStrict
|
||||
auto srcRect = SkRect::MakeXYWH(.25f*w, .25f*h, .50f*w, .50f*h);
|
||||
auto dstRect = SkRect::MakeXYWH( 0, 0, .50f*w, .50f*h);
|
||||
canvas->drawImageRect(fGradImgs[i], srcRect, dstRect, &plainPaint,
|
||||
canvas->drawImageRect(fGradImgs[i], srcRect, dstRect, s, nullptr,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
canvas->translate(.5f*w + kPad, 0);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ DEF_TEST(Image_NewFromGenerator, r) {
|
||||
SkCanvas canvas(bitmap);
|
||||
const SkColor kDefaultColor = 0xffabcdef;
|
||||
canvas.clear(kDefaultColor);
|
||||
canvas.drawImage(image, 0, 0, nullptr);
|
||||
canvas.drawImage(image, 0, 0);
|
||||
if (TestImageGenerator::kSucceedGetPixels_TestType == test) {
|
||||
REPORTER_ASSERT(
|
||||
r, TestImageGenerator::Color() == bitmap.getColor(0, 0));
|
||||
|
@ -248,10 +248,11 @@ DEF_TEST(DrawBitmapRect, reporter) {
|
||||
|
||||
SkCanvas canvas(dst);
|
||||
|
||||
SkIRect srcR = { gWidth, 0, gWidth + 16, 16 };
|
||||
SkRect dstR = { 0, 0, SkIntToScalar(16), SkIntToScalar(16) };
|
||||
SkRect srcR = { gWidth, 0, gWidth + 16, 16 };
|
||||
SkRect dstR = { 0, 0, 16, 16 };
|
||||
|
||||
canvas.drawImageRect(src.asImage(), srcR, dstR, nullptr);
|
||||
canvas.drawImageRect(src.asImage(), srcR, dstR, SkSamplingOptions(), nullptr,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
|
||||
// ensure that we draw nothing if srcR does not intersect the bitmap
|
||||
REPORTER_ASSERT(reporter, check_for_all_zeros(dst));
|
||||
|
@ -337,16 +337,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(Gr1x1TextureMipMappedTest, reporter, ctxInfo)
|
||||
// Make sure we scale so we don't optimize out the use of mips.
|
||||
surface->getCanvas()->scale(0.5f, 0.5f);
|
||||
|
||||
SkPaint paint;
|
||||
// This should upload the image to a non mipped GrTextureProxy.
|
||||
surface->getCanvas()->drawImage(bmpImage, 0, 0, &paint);
|
||||
surface->getCanvas()->drawImage(bmpImage, 0, 0);
|
||||
surface->flushAndSubmit();
|
||||
|
||||
// Now set the filter quality to high so we use mip maps. We should find the non mipped texture
|
||||
// in the cache for the SkImage. Since the texture is 1x1 we should just use that texture
|
||||
// instead of trying to do a copy to a mipped texture.
|
||||
paint.setFilterQuality(kHigh_SkFilterQuality);
|
||||
surface->getCanvas()->drawImage(bmpImage, 0, 0, &paint);
|
||||
surface->getCanvas()->drawImage(bmpImage, 0, 0, SkSamplingOptions({1.0f/3, 1.0f/3}));
|
||||
surface->flushAndSubmit();
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrOpsTaskFlushCount, reporter, ctxInfo) {
|
||||
canvas1->clear(SK_ColorRED);
|
||||
canvas2->clear(SK_ColorRED);
|
||||
|
||||
SkIRect srcRect = SkIRect::MakeWH(1, 1);
|
||||
SkRect srcRect = SkRect::MakeWH(1, 1);
|
||||
SkRect dstRect = SkRect::MakeWH(1, 1);
|
||||
SkPaint paint;
|
||||
paint.setColor(SK_ColorGREEN);
|
||||
@ -58,12 +58,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrOpsTaskFlushCount, reporter, ctxInfo) {
|
||||
srcRect.fRight = srcRect.fLeft + 1;
|
||||
|
||||
sk_sp<SkImage> image = surface1->makeImageSnapshot();
|
||||
canvas2->drawImageRect(image.get(), srcRect, dstRect, nullptr);
|
||||
canvas2->drawImageRect(image.get(), srcRect, dstRect, SkSamplingOptions(), nullptr,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
if (i != 999) {
|
||||
dstRect.fLeft = i+1;
|
||||
dstRect.fRight = dstRect.fLeft + 1;
|
||||
image = surface2->makeImageSnapshot();
|
||||
canvas1->drawImageRect(image.get(), srcRect, dstRect, nullptr);
|
||||
canvas1->drawImageRect(image.get(), srcRect, dstRect, SkSamplingOptions(), nullptr,
|
||||
SkCanvas::kStrict_SrcRectConstraint);
|
||||
}
|
||||
}
|
||||
context->flushAndSubmit();
|
||||
|
@ -49,10 +49,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrTextureMipMapInvalidationTest, reporter, ct
|
||||
// Painting with downscale and medium filter quality should result in mipmap creation
|
||||
// Flush the context rather than the canvas as flushing the canvas triggers MIP level
|
||||
// generation.
|
||||
SkPaint paint;
|
||||
paint.setFilterQuality(kMedium_SkFilterQuality);
|
||||
SkSamplingOptions sampling(SkFilterMode::kLinear, SkMipmapMode::kLinear);
|
||||
|
||||
surf2->getCanvas()->scale(0.2f, 0.2f);
|
||||
surf2->getCanvas()->drawImage(surf1->makeImageSnapshot(), 0, 0, &paint);
|
||||
surf2->getCanvas()->drawImage(surf1->makeImageSnapshot(), 0, 0, sampling);
|
||||
context->flushAndSubmit();
|
||||
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
|
||||
REPORTER_ASSERT(reporter, !allocateMips || !mipsAreDirty(surf1.get()));
|
||||
@ -100,9 +100,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReimportImageTextureWithMipLevels, reporter,
|
||||
SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
surf = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kYes, singlePixelInfo, 1,
|
||||
kTopLeft_GrSurfaceOrigin, nullptr);
|
||||
SkPaint paint;
|
||||
paint.setFilterQuality(kMedium_SkFilterQuality);
|
||||
surf->getCanvas()->drawImageRect(img, SkRect::MakeWH(1, 1), &paint);
|
||||
|
||||
surf->getCanvas()->drawImageRect(img, SkRect::MakeWH(1, 1),
|
||||
SkSamplingOptions(SkFilterMode::kLinear,
|
||||
SkMipmapMode::kLinear));
|
||||
uint32_t pixel;
|
||||
surf->readPixels(singlePixelInfo, &pixel, sizeof(uint32_t), 0, 0);
|
||||
REPORTER_ASSERT(reporter, pixel == SkPreMultiplyColor(SK_ColorDKGRAY));
|
||||
|
@ -1357,7 +1357,6 @@ static sk_sp<SkImage> any_image_will_do() {
|
||||
DEF_TEST(Image_nonfinite_dst, reporter) {
|
||||
auto surf = SkSurface::MakeRasterN32Premul(10, 10);
|
||||
auto img = any_image_will_do();
|
||||
SkPaint paint;
|
||||
|
||||
for (SkScalar bad : { SK_ScalarInfinity, SK_ScalarNaN}) {
|
||||
for (int bits = 1; bits <= 15; ++bits) {
|
||||
@ -1367,7 +1366,7 @@ DEF_TEST(Image_nonfinite_dst, reporter) {
|
||||
if (bits & 4) dst.fRight = bad;
|
||||
if (bits & 8) dst.fBottom = bad;
|
||||
|
||||
surf->getCanvas()->drawImageRect(img, dst, &paint);
|
||||
surf->getCanvas()->drawImageRect(img, dst, SkSamplingOptions());
|
||||
|
||||
// we should draw nothing
|
||||
ToolUtils::PixelIter iter(surf.get());
|
||||
|
@ -220,7 +220,8 @@ static void fill_in_mips(SkMipmapBuilder* builder, sk_sp<SkImage> img) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
SkPixmap pm = builder->level(i);
|
||||
auto surf = SkSurface::MakeRasterDirect(pm);
|
||||
surf->getCanvas()->drawImageRect(img, SkRect::MakeIWH(pm.width(), pm.height()), nullptr);
|
||||
surf->getCanvas()->drawImageRect(img, SkRect::MakeIWH(pm.width(), pm.height()),
|
||||
SkSamplingOptions());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,11 +53,11 @@ static void draw_basic(SkCanvas* canvas, int seed, sk_sp<SkImage> image) {
|
||||
paint.setColor(SK_ColorGREEN);
|
||||
canvas->drawPath(path, paint);
|
||||
|
||||
canvas->drawImage(image, 128-seed, 128, &paint);
|
||||
canvas->drawImage(image, 128-seed, 128, SkSamplingOptions(), &paint);
|
||||
|
||||
if (seed % 2 == 0) {
|
||||
SkRect rect2 = SkRect::MakeXYWH(0, 0, 40, 60);
|
||||
canvas->drawImageRect(image, rect2, &paint);
|
||||
canvas->drawImageRect(image, rect2, SkSamplingOptions(), &paint);
|
||||
}
|
||||
|
||||
SkPaint paint2;
|
||||
|
@ -61,9 +61,9 @@ DEF_TEST(SkPDF_JpegEmbedTest, r) {
|
||||
canvas->clear(SK_ColorLTGRAY);
|
||||
|
||||
sk_sp<SkImage> im1(SkImage::MakeFromEncoded(mandrillData));
|
||||
canvas->drawImage(im1.get(), 65.0, 0.0, nullptr);
|
||||
canvas->drawImage(im1.get(), 65.0, 0.0);
|
||||
sk_sp<SkImage> im2(SkImage::MakeFromEncoded(cmykData));
|
||||
canvas->drawImage(im2.get(), 0.0, 512.0, nullptr);
|
||||
canvas->drawImage(im2.get(), 0.0, 512.0);
|
||||
|
||||
document->endPage();
|
||||
document->close();
|
||||
|
@ -392,7 +392,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageNullFulfill, reporter, ctxInfo) {
|
||||
canvas->drawImage(refImg, 0, 0);
|
||||
SkPaint paint;
|
||||
paint.setColorFilter(SkColorFilters::LinearToSRGBGamma());
|
||||
canvas->drawImage(refImg, 0, 0, &paint);
|
||||
canvas->drawImage(refImg, 0, 0, SkSamplingOptions(), &paint);
|
||||
auto shader = refImg->makeShader(SkSamplingOptions());
|
||||
REPORTER_ASSERT(reporter, shader);
|
||||
paint.setShader(std::move(shader));
|
||||
|
@ -69,7 +69,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
||||
nullptr);
|
||||
SkCanvas* c = s->getCanvas();
|
||||
|
||||
c->drawImageRect(bigImg, SkRect::MakeWH(1024, 600), nullptr);
|
||||
c->drawImageRect(bigImg, SkRect::MakeWH(1024, 600), SkSamplingOptions());
|
||||
|
||||
smImg = s->makeImageSnapshot();
|
||||
}
|
||||
@ -99,7 +99,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
|
||||
|
||||
SkRect dstRect = SkRect::MakeXYWH(offset.fX, offset.fY,
|
||||
outSubset.width(), outSubset.height());
|
||||
dstCanvas->drawImageRect(filteredImg, outSubset, dstRect, nullptr);
|
||||
dstCanvas->drawImageRect(filteredImg, SkRect::Make(outSubset), dstRect, SkSamplingOptions(),
|
||||
nullptr, SkCanvas::kStrict_SrcRectConstraint);
|
||||
|
||||
// Flush here to mimic Chrome's SkiaHelper::ApplyImageFilter
|
||||
dContext->flushAndSubmit();
|
||||
|
@ -55,7 +55,7 @@ DEF_TEST(serial_procs_image, reporter) {
|
||||
{
|
||||
SkPictureRecorder rec;
|
||||
SkCanvas* canvas = rec.beginRecording(128, 128);
|
||||
canvas->drawImage(src_img, 0, 0, nullptr);
|
||||
canvas->drawImage(src_img, 0, 0);
|
||||
pic = rec.finishRecordingAsPicture();
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ static void TestBitmapSerialization(const SkBitmap& validBitmap,
|
||||
SkPaint paint;
|
||||
paint.setImageFilter(deserializedFilter);
|
||||
canvas.clipRect(SkRect::MakeXYWH(0, 0, SkIntToScalar(24), SkIntToScalar(24)));
|
||||
canvas.drawImage(bitmap.asImage(), 0, 0, &paint);
|
||||
canvas.drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ DEF_TEST(SkImageFromBitmap_extractSubset, reporter) {
|
||||
tgt.allocN32Pixels(gWidth, gHeight);
|
||||
SkCanvas canvas(tgt);
|
||||
canvas.clear(SK_ColorTRANSPARENT);
|
||||
canvas.drawImage(image, 0, 0, nullptr);
|
||||
canvas.drawImage(image, 0, 0);
|
||||
|
||||
uint32_t pixel = 0;
|
||||
SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType);
|
||||
|
@ -153,14 +153,11 @@ static void test_discarded_image(skiatest::Reporter* reporter, const SkMatrix& t
|
||||
|
||||
sk_sp<SkImage> image(buildImage());
|
||||
|
||||
// always use high quality to ensure caching when scaled
|
||||
SkPaint paint;
|
||||
paint.setFilterQuality(kHigh_SkFilterQuality);
|
||||
|
||||
// draw the image (with a transform, to tickle different code paths) to ensure
|
||||
// any associated resources get cached
|
||||
canvas->concat(transform);
|
||||
canvas->drawImage(image, 0, 0, &paint);
|
||||
// always use high quality to ensure caching when scaled
|
||||
canvas->drawImage(image, 0, 0, SkSamplingOptions({1.0f/3, 1.0f/3}));
|
||||
|
||||
const auto desc = SkBitmapCacheDesc::Make(image.get());
|
||||
|
||||
|
@ -66,7 +66,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureStripAtlasManagerColorFilterTest, repo
|
||||
auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
|
||||
canvas->drawImage(std::move(img), 0, 0, &p);
|
||||
canvas->drawImage(std::move(img), 0, 0, SkSamplingOptions(), &p);
|
||||
|
||||
context->abandonContext();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user