From 409d470a4973e2ba9f95983b9820931adcf7cd73 Mon Sep 17 00:00:00 2001 From: mtklein Date: Mon, 29 Feb 2016 07:38:01 -0800 Subject: Add gamma_correct option field to dm.json E.g. { "max_rss_MB" : 23, "results" : [ { "key" : { "config" : "pdf", "name" : "gamma", "source_type" : "gm" }, "md5" : "c5dfb531f4d76c77c3305b6a04733262", "options" : { "ext" : "pdf", "gamma_correct" : false } }, { "key" : { "config" : "8888", "name" : "gamma", "source_type" : "gm" }, "md5" : "6177860ed24106446d3a9087527e67bf", "options" : { "ext" : "png", "gamma_correct" : false } }, { "key" : { "config" : "f16", "name" : "gamma", "source_type" : "gm" }, "md5" : "213f80145953ecd4c71e0612447b2ad9", "options" : { "ext" : "png", "gamma_correct" : true } } ] } BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1741973002 Review URL: https://codereview.chromium.org/1741973002 --- dm/DM.cpp | 7 +++++++ dm/DMJsonWriter.cpp | 22 ++++++++++++---------- dm/DMJsonWriter.h | 1 + 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'dm') diff --git a/dm/DM.cpp b/dm/DM.cpp index 48aaea7e4e..9173bb7858 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -1053,12 +1053,19 @@ struct Task { const char* ext, SkStream* data, size_t len, const SkBitmap* bitmap) { + bool gammaCorrect = false; + if (bitmap) { + gammaCorrect = bitmap->profileType() == kSRGB_SkColorProfileType + || bitmap-> colorType() == kRGBA_F16_SkColorType; + } + JsonWriter::BitmapResult result; result.name = task.src->name(); result.config = task.sink.tag; result.sourceType = task.src.tag; result.sourceOptions = task.src.options; result.ext = ext; + result.gammaCorrect = gammaCorrect; result.md5 = md5; JsonWriter::AddBitmapResult(result); diff --git a/dm/DMJsonWriter.cpp b/dm/DMJsonWriter.cpp index 5317567d68..24b8a58724 100644 --- a/dm/DMJsonWriter.cpp +++ b/dm/DMJsonWriter.cpp @@ -52,11 +52,12 @@ void JsonWriter::DumpJson() { SkAutoMutexAcquire lock(&gBitmapResultLock); for (int i = 0; i < gBitmapResults.count(); i++) { Json::Value result; - result["key"]["name"] = gBitmapResults[i].name.c_str(); - result["key"]["config"] = gBitmapResults[i].config.c_str(); - result["key"]["source_type"] = gBitmapResults[i].sourceType.c_str(); - result["options"]["ext"] = gBitmapResults[i].ext.c_str(); - result["md5"] = gBitmapResults[i].md5.c_str(); + result["key"]["name"] = gBitmapResults[i].name.c_str(); + result["key"]["config"] = gBitmapResults[i].config.c_str(); + result["key"]["source_type"] = gBitmapResults[i].sourceType.c_str(); + result["options"]["ext"] = gBitmapResults[i].ext.c_str(); + result["options"]["gamma_correct"] = gBitmapResults[i].gammaCorrect; + result["md5"] = gBitmapResults[i].md5.c_str(); // Source options only need to be part of the key if they exist. // Source type by source type, we either always set options or never set options. @@ -110,11 +111,12 @@ bool JsonWriter::ReadJson(const char* path, void(*callback)(BitmapResult)) { BitmapResult br; for (unsigned i = 0; i < results.size(); i++) { const Json::Value& r = results[i]; - br.name = r["key"]["name"].asCString(); - br.config = r["key"]["config"].asCString(); - br.sourceType = r["key"]["source_type"].asCString(); - br.ext = r["options"]["ext"].asCString(); - br.md5 = r["md5"].asCString(); + br.name = r["key"]["name"].asCString(); + br.config = r["key"]["config"].asCString(); + br.sourceType = r["key"]["source_type"].asCString(); + br.ext = r["options"]["ext"].asCString(); + br.gammaCorrect = r["options"]["gamma_correct"].asBool(); + br.md5 = r["md5"].asCString(); if (!r["key"]["source_options"].isNull()) { br.sourceOptions = r["key"]["source_options"].asCString(); diff --git a/dm/DMJsonWriter.h b/dm/DMJsonWriter.h index 67c9cf6a1a..68e27a54b1 100644 --- a/dm/DMJsonWriter.h +++ b/dm/DMJsonWriter.h @@ -29,6 +29,7 @@ public: SkString sourceOptions; // "image", "codec", "subset", "scanline" SkString md5; // In ASCII, so 32 bytes long. SkString ext; // Extension of file we wrote: "png", "pdf", ... + bool gammaCorrect; // Old configs are not gamma correct, some new ones are. }; /** -- cgit v1.2.3