Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: gm/mipmap.cpp

Issue 2029373004: respect srgb gamma when building mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/gamma.cpp ('k') | gm/showmiplevels.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
+}
+
« no previous file with comments | « gm/gamma.cpp ('k') | gm/showmiplevels.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698