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

Unified Diff: gm/gamma.cpp

Issue 2007973002: Manually generated sRGB mipmaps. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Break long columns Created 4 years, 7 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 | « no previous file | include/gpu/GrTexture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gamma.cpp
diff --git a/gm/gamma.cpp b/gm/gamma.cpp
index 5dbfb9425bffb6772c1a73fa9c4fad1abc01e8a6..25608d26b3632c7b70b996265e31a0ded7cdfba8 100644
--- a/gm/gamma.cpp
+++ b/gm/gamma.cpp
@@ -10,7 +10,7 @@
#include "Resources.h"
#include "SkGradientShader.h"
-DEF_SIMPLE_GM(gamma, canvas, 500, 200) {
+DEF_SIMPLE_GM(gamma, canvas, 560, 200) {
SkPaint p;
const SkScalar sz = 50.0f;
const int szInt = SkScalarTruncToInt(sz);
@@ -34,8 +34,19 @@ DEF_SIMPLE_GM(gamma, canvas, 500, 200) {
SkImageInfo srgbGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlphaType,
kSRGB_SkColorProfileType);
srgbGreyBmp.allocPixels(srgbGreyInfo);
+ // 0xBC = 255 * linear_to_srgb(0.5f)
srgbGreyBmp.eraseARGB(0xFF, 0xBC, 0xBC, 0xBC);
+ SkBitmap mipmapBmp;
+ SkImageInfo mipmapInfo = SkImageInfo::MakeN32(2, 2, kOpaque_SkAlphaType,
+ kSRGB_SkColorProfileType);
+ mipmapBmp.allocPixels(mipmapInfo);
+ SkPMColor* mipmapPixels = reinterpret_cast<SkPMColor*>(mipmapBmp.getPixels());
+ // 0x89 = 255 * linear_to_srgb(0.25f)
+ mipmapPixels[0] = mipmapPixels[3] = SkPackARGB32(0xFF, 0x89, 0x89, 0x89);
+ // 0xE1 = 255 * linear_to_srgb(0.75f)
+ mipmapPixels[1] = mipmapPixels[2] = SkPackARGB32(0xFF, 0xE1, 0xE1, 0xE1);
+
SkPaint textPaint;
textPaint.setColor(SK_ColorWHITE);
@@ -107,6 +118,12 @@ DEF_SIMPLE_GM(gamma, canvas, 500, 200) {
p.setFilterQuality(SkFilterQuality::kMedium_SkFilterQuality);
nextRect("Dither", "Scale");
+ // 25%/75% dither, scaled down by 2x. Tests ALL aspects of minification. Specifically, are
+ // sRGB sources decoded to linear before computing mipmaps?
+ p.setShader(SkShader::MakeBitmapShader(mipmapBmp, rpt, rpt, &scaleMatrix));
+ p.setFilterQuality(SkFilterQuality::kMedium_SkFilterQuality);
+ nextRect("MipMaps", 0);
+
// 50% grey via paint color.
p.setColor(0xff7f7f7f);
nextRect("Color", 0);
« no previous file with comments | « no previous file | include/gpu/GrTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698