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

Unified Diff: tools/PictureRenderer.cpp

Issue 273783004: add --readJsonSummaryPath to render_pictures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 | tools/image_expectations.h » ('j') | tools/image_expectations.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/PictureRenderer.cpp
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index b5dc0fc93dad973a2d763731e46d195aeb836e92..496853603428c263ad09df32d1bb5f2e0cf3d149 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -284,14 +284,11 @@ static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& i
SkBitmap bitmap;
SkISize size = canvas->getDeviceSize();
- sk_tools::setup_bitmap(&bitmap, size.width(), size.height());
-
- // Make sure we only compute the bitmap hash once (at most).
borenet 2014/05/09 15:54:01 Do we no longer care about this?
epoger 2014/05/09 16:06:25 We do, but BitmapAndDigest takes care of it for us
- uint64_t hash;
- bool generatedHash = false;
+ setup_bitmap(&bitmap, size.width(), size.height());
canvas->readPixels(&bitmap, 0, 0);
- sk_tools::force_all_opaque(bitmap);
+ force_all_opaque(bitmap);
+ BitmapAndDigest bitmapAndDigest(bitmap);
SkString escapedInputFilename(inputFilename);
replace_char(&escapedInputFilename, '.', '_');
@@ -299,18 +296,13 @@ static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& i
// TODO(epoger): what about including the config type within outputFilename? That way,
// we could combine results of different config types without conflicting filenames.
SkString outputFilename;
+ const ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr();
const char *outputSubdirPtr = NULL;
if (useChecksumBasedFilenames) {
- SkASSERT(!generatedHash);
- SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash));
- generatedHash = true;
-
outputSubdirPtr = escapedInputFilename.c_str();
- // TODO(epoger): The string constant below will be removed when I land
- // the second part of https://codereview.chromium.org/261313004/
- // ('add --readJsonSummaryPath to render_pictures')
- outputFilename.set("bitmap-64bitMD5_");
- outputFilename.appendU64(hash);
+ outputFilename.set(imageDigestPtr->getHashType());
+ outputFilename.append("_");
+ outputFilename.appendU64(imageDigestPtr->getHashValue());
} else {
outputFilename.set(escapedInputFilename);
if (NULL != tileNumberPtr) {
@@ -321,11 +313,7 @@ static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& i
outputFilename.append(".png");
if (NULL != jsonSummaryPtr) {
- if (!generatedHash) {
- SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash));
- generatedHash = true;
- }
-
+ const ImageDigest *imageDigestPtr = bitmapAndDigest.getImageDigestPtr();
SkString outputRelativePath;
if (outputSubdirPtr) {
outputRelativePath.set(outputSubdirPtr);
@@ -336,7 +324,7 @@ static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& i
}
jsonSummaryPtr->add(inputFilename.c_str(), outputRelativePath.c_str(),
- hash, tileNumberPtr);
+ *imageDigestPtr, tileNumberPtr);
}
if (outputDir.isEmpty()) {
« no previous file with comments | « no previous file | tools/image_expectations.h » ('j') | tools/image_expectations.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698