| Index: gm/mipmap.cpp
|
| diff --git a/gm/mipmap.cpp b/gm/mipmap.cpp
|
| index ae73a8de9db19259bd4114cfa50b54acd552333f..45b4d1512636cc5fbdb6e1e57cb5f930e517be53 100644
|
| --- a/gm/mipmap.cpp
|
| +++ b/gm/mipmap.cpp
|
| @@ -47,3 +47,52 @@ DEF_SIMPLE_GM(mipmap, canvas, 400, 200) {
|
| }
|
| canvas->drawImage(img.get(), 20, 20, nullptr);
|
| }
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////////////////////////
|
| +
|
| +// create a circle image computed raw, so we can wrap it as a linear or srgb image
|
| +static sk_sp<SkImage> make(sk_sp<SkColorSpace> cs) {
|
| + const int N = 100;
|
| + SkImageInfo info = SkImageInfo::Make(N, N, kN32_SkColorType, kPremul_SkAlphaType, cs);
|
| + SkBitmap bm;
|
| + bm.allocPixels(info);
|
| +
|
| + for (int y = 0; y < N; ++y) {
|
| + for (int x = 0; x < N; ++x) {
|
| + *bm.getAddr32(x, y) = (x ^ y) & 1 ? 0xFFFFFFFF : 0xFF000000;
|
| + }
|
| + }
|
| + bm.setImmutable();
|
| + return SkImage::MakeFromBitmap(bm);
|
| +}
|
| +
|
| +static void show_mips(SkCanvas* canvas, SkImage* img) {
|
| + SkPaint paint;
|
| + paint.setFilterQuality(kMedium_SkFilterQuality);
|
| +
|
| + SkRect dst = SkRect::MakeIWH(img->width(), img->height());
|
| + while (dst.width() > 5) {
|
| + canvas->drawImageRect(img, dst, &paint);
|
| + dst.offset(dst.width() + 10, 0);
|
| + dst.fRight = dst.fLeft + SkScalarHalf(dst.width());
|
| + dst.fBottom = dst.fTop + SkScalarHalf(dst.height());
|
| + }
|
| +}
|
| +
|
| +/*
|
| + * Ensure that in L32 drawing mode, both images/mips look the same as each other, and
|
| + * their mips are darker than the original (since the mips should ignore the gamma in L32).
|
| + *
|
| + * Ensure that in S32 drawing mode, all images/mips look the same, and look correct (i.e.
|
| + * the mip levels match the original in brightness).
|
| + */
|
| +DEF_SIMPLE_GM(mipmap_srgb, canvas, 260, 230) {
|
| + sk_sp<SkImage> limg = make(nullptr);
|
| + sk_sp<SkImage> simg = make(SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named));
|
| +
|
| + canvas->translate(10, 10);
|
| + show_mips(canvas, limg.get());
|
| + canvas->translate(0, limg->height() + 10.0f);
|
| + show_mips(canvas, simg.get());
|
| +}
|
| +
|
|
|