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

Side by Side Diff: tools/PictureRenderer.cpp

Issue 274463004: Revert of extract some common code from PictureRenderer (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 unified diff | Download patch
« no previous file with comments | « tools/PictureRenderer.h ('k') | tools/image_expectations.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "PictureRenderer.h" 8 #include "PictureRenderer.h"
9 #include "picture_utils.h" 9 #include "picture_utils.h"
10 #include "SamplePipeControllers.h" 10 #include "SamplePipeControllers.h"
(...skipping 30 matching lines...) Expand all
41 return SkScalarLog(x) * log2_conversion_factor; 41 return SkScalarLog(x) * log2_conversion_factor;
42 } 42 }
43 43
44 namespace sk_tools { 44 namespace sk_tools {
45 45
46 enum { 46 enum {
47 kDefaultTileWidth = 256, 47 kDefaultTileWidth = 256,
48 kDefaultTileHeight = 256 48 kDefaultTileHeight = 256
49 }; 49 };
50 50
51 /*
52 * TODO(epoger): Make constant strings consistent instead of mixing hypenated an d camel-caps.
53 *
54 * TODO(epoger): Similar constants are already maintained in 2 other places:
55 * gm/gm_json.py and gm/gm_expectations.cpp. We shouldn't add yet a third place.
56 * Figure out a way to share the definitions instead.
57 *
58 * Note that, as of https://codereview.chromium.org/226293002 , the JSON
59 * schema used here has started to differ from the one in gm_expectations.cpp .
60 * TODO(epoger): Consider getting GM and render_pictures to use the same JSON
61 * output module.
62 */
63 const static char kJsonKey_ActualResults[] = "actual-results";
64 const static char kJsonKey_Header[] = "header";
65 const static char kJsonKey_Header_Type[] = "type";
66 const static char kJsonKey_Header_Revision[] = "revision"; // unique within Typ e
67 const static char kJsonKey_Image_ChecksumAlgorithm[] = "checksumAlgorithm";
68 const static char kJsonKey_Image_ChecksumValue[] = "checksumValue";
69 const static char kJsonKey_Image_ComparisonResult[] = "comparisonResult";
70 const static char kJsonKey_Image_Filepath[] = "filepath";
71 const static char kJsonKey_Source_TiledImages[] = "tiled-images";
72 const static char kJsonKey_Source_WholeImage[] = "whole-image";
73 // Values (not keys) that are written out by this JSON generator
74 const static char kJsonValue_Header_Type[] = "ChecksummedImages";
75 const static int kJsonValue_Header_Revision = 1;
76 const static char kJsonValue_Image_ChecksumAlgorithm_Bitmap64bitMD5[] = "bitmap- 64bitMD5";
77 const static char kJsonValue_Image_ComparisonResult_NoComparison[] = "no-compari son";
78
79 void ImageResultsSummary::add(const char *sourceName, const char *fileName, uint 64_t hash,
80 const int *tileNumber) {
81 Json::Value image;
82 image[kJsonKey_Image_ChecksumAlgorithm] = kJsonValue_Image_ChecksumAlgorithm _Bitmap64bitMD5;
83 image[kJsonKey_Image_ChecksumValue] = Json::UInt64(hash);
84 image[kJsonKey_Image_ComparisonResult] = kJsonValue_Image_ComparisonResult_N oComparison;
85 image[kJsonKey_Image_Filepath] = fileName;
86 if (NULL == tileNumber) {
87 fActualResults[sourceName][kJsonKey_Source_WholeImage] = image;
88 } else {
89 fActualResults[sourceName][kJsonKey_Source_TiledImages][*tileNumber] = i mage;
90 }
91 }
92
93 void ImageResultsSummary::add(const char *sourceName, const char *fileName, cons t SkBitmap& bitmap,
94 const int *tileNumber) {
95 uint64_t hash;
96 SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash));
97 this->add(sourceName, fileName, hash, tileNumber);
98 }
99
100 void ImageResultsSummary::writeToFile(const char *filename) {
101 Json::Value header;
102 header[kJsonKey_Header_Type] = kJsonValue_Header_Type;
103 header[kJsonKey_Header_Revision] = kJsonValue_Header_Revision;
104 Json::Value root;
105 root[kJsonKey_Header] = header;
106 root[kJsonKey_ActualResults] = fActualResults;
107 std::string jsonStdString = root.toStyledString();
108 SkFILEWStream stream(filename);
109 stream.write(jsonStdString.c_str(), jsonStdString.length());
110 }
111
51 void PictureRenderer::init(SkPicture* pict, const SkString* outputDir, 112 void PictureRenderer::init(SkPicture* pict, const SkString* outputDir,
52 const SkString* inputFilename, bool useChecksumBasedF ilenames) { 113 const SkString* inputFilename, bool useChecksumBasedF ilenames) {
53 this->CopyString(&fOutputDir, outputDir); 114 this->CopyString(&fOutputDir, outputDir);
54 this->CopyString(&fInputFilename, inputFilename); 115 this->CopyString(&fInputFilename, inputFilename);
55 fUseChecksumBasedFilenames = useChecksumBasedFilenames; 116 fUseChecksumBasedFilenames = useChecksumBasedFilenames;
56 117
57 SkASSERT(NULL == fPicture); 118 SkASSERT(NULL == fPicture);
58 SkASSERT(NULL == fCanvas.get()); 119 SkASSERT(NULL == fCanvas.get());
59 if (NULL != fPicture || NULL != fCanvas.get()) { 120 if (NULL != fPicture || NULL != fCanvas.get()) {
60 return; 121 return;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // TODO(epoger): what about including the config type within outputFilename? That way, 360 // TODO(epoger): what about including the config type within outputFilename? That way,
300 // we could combine results of different config types without conflicting fi lenames. 361 // we could combine results of different config types without conflicting fi lenames.
301 SkString outputFilename; 362 SkString outputFilename;
302 const char *outputSubdirPtr = NULL; 363 const char *outputSubdirPtr = NULL;
303 if (useChecksumBasedFilenames) { 364 if (useChecksumBasedFilenames) {
304 SkASSERT(!generatedHash); 365 SkASSERT(!generatedHash);
305 SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash)); 366 SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash));
306 generatedHash = true; 367 generatedHash = true;
307 368
308 outputSubdirPtr = escapedInputFilename.c_str(); 369 outputSubdirPtr = escapedInputFilename.c_str();
309 // TODO(epoger): The string constant below will be removed when I land 370 outputFilename.set(kJsonValue_Image_ChecksumAlgorithm_Bitmap64bitMD5);
310 // the second part of https://codereview.chromium.org/261313004/ 371 outputFilename.append("_");
311 // ('add --readJsonSummaryPath to render_pictures')
312 outputFilename.set("bitmap-64bitMD5_");
313 outputFilename.appendU64(hash); 372 outputFilename.appendU64(hash);
314 } else { 373 } else {
315 outputFilename.set(escapedInputFilename); 374 outputFilename.set(escapedInputFilename);
316 if (NULL != tileNumberPtr) { 375 if (NULL != tileNumberPtr) {
317 outputFilename.append("-tile"); 376 outputFilename.append("-tile");
318 outputFilename.appendS32(*tileNumberPtr); 377 outputFilename.appendS32(*tileNumberPtr);
319 } 378 }
320 } 379 }
321 outputFilename.append(".png"); 380 outputFilename.append(".png");
322 381
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 virtual SkString getConfigNameInternal() SK_OVERRIDE { 1012 virtual SkString getConfigNameInternal() SK_OVERRIDE {
954 return SkString("picture_clone"); 1013 return SkString("picture_clone");
955 } 1014 }
956 }; 1015 };
957 1016
958 PictureRenderer* CreatePictureCloneRenderer() { 1017 PictureRenderer* CreatePictureCloneRenderer() {
959 return SkNEW(PictureCloneRenderer); 1018 return SkNEW(PictureCloneRenderer);
960 } 1019 }
961 1020
962 } // namespace sk_tools 1021 } // namespace sk_tools
OLDNEW
« no previous file with comments | « tools/PictureRenderer.h ('k') | tools/image_expectations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698