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

Side by Side Diff: tools/skpdiff/SkDiffContext.cpp

Issue 428443002: Cleanup: Rename SkOSPath functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 6 years, 4 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/skimage_main.cpp ('k') | tools/skpdiff/skpdiff_util.cpp » ('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 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 SkDebugf("Failed to load bitmap \"%s\"\n", testPath); 91 SkDebugf("Failed to load bitmap \"%s\"\n", testPath);
92 return; 92 return;
93 } 93 }
94 94
95 // Setup a record for this diff 95 // Setup a record for this diff
96 fRecordMutex.acquire(); 96 fRecordMutex.acquire();
97 DiffRecord* newRecord = fRecords.addToHead(DiffRecord()); 97 DiffRecord* newRecord = fRecords.addToHead(DiffRecord());
98 fRecordMutex.release(); 98 fRecordMutex.release();
99 99
100 // compute the common name 100 // compute the common name
101 SkString baseName = SkOSPath::SkBasename(baselinePath); 101 SkString baseName = SkOSPath::Basename(baselinePath);
102 SkString testName = SkOSPath::SkBasename(testPath); 102 SkString testName = SkOSPath::Basename(testPath);
103 newRecord->fCommonName = get_common_prefix(baseName, testName); 103 newRecord->fCommonName = get_common_prefix(baseName, testName);
104 104
105 newRecord->fBaselinePath = baselinePath; 105 newRecord->fBaselinePath = baselinePath;
106 newRecord->fTestPath = testPath; 106 newRecord->fTestPath = testPath;
107 newRecord->fSize = SkISize::Make(baselineBitmap.width(), baselineBitmap.heig ht()); 107 newRecord->fSize = SkISize::Make(baselineBitmap.width(), baselineBitmap.heig ht());
108 108
109 // only generate diff images if we have a place to store them 109 // only generate diff images if we have a place to store them
110 SkImageDiffer::BitmapsToCreate bitmapsToCreate; 110 SkImageDiffer::BitmapsToCreate bitmapsToCreate;
111 bitmapsToCreate.alphaMask = !fAlphaMaskDir.isEmpty(); 111 bitmapsToCreate.alphaMask = !fAlphaMaskDir.isEmpty();
112 bitmapsToCreate.rgbDiff = !fRgbDiffDir.isEmpty(); 112 bitmapsToCreate.rgbDiff = !fRgbDiffDir.isEmpty();
(...skipping 14 matching lines...) Expand all
127 // report more detail when it fails to compare two images') 127 // report more detail when it fails to compare two images')
128 diffData.fResult.result = -1; 128 diffData.fResult.result = -1;
129 continue; 129 continue;
130 } 130 }
131 131
132 if (bitmapsToCreate.alphaMask 132 if (bitmapsToCreate.alphaMask
133 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result 133 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result
134 && !diffData.fResult.poiAlphaMask.empty() 134 && !diffData.fResult.poiAlphaMask.empty()
135 && !newRecord->fCommonName.isEmpty()) { 135 && !newRecord->fCommonName.isEmpty()) {
136 136
137 newRecord->fAlphaMaskPath = SkOSPath::SkPathJoin(fAlphaMaskDir.c_str (), 137 newRecord->fAlphaMaskPath = SkOSPath::Join(fAlphaMaskDir.c_str(),
138 newRecord->fCommonN ame.c_str()); 138 newRecord->fCommonName.c_ str());
139 139
140 // compute the image diff and output it 140 // compute the image diff and output it
141 SkBitmap copy; 141 SkBitmap copy;
142 diffData.fResult.poiAlphaMask.copyTo(&copy, kN32_SkColorType); 142 diffData.fResult.poiAlphaMask.copyTo(&copy, kN32_SkColorType);
143 SkImageEncoder::EncodeFile(newRecord->fAlphaMaskPath.c_str(), copy, 143 SkImageEncoder::EncodeFile(newRecord->fAlphaMaskPath.c_str(), copy,
144 SkImageEncoder::kPNG_Type, 100); 144 SkImageEncoder::kPNG_Type, 100);
145 145
146 // cleanup the existing bitmap to free up resources; 146 // cleanup the existing bitmap to free up resources;
147 diffData.fResult.poiAlphaMask.reset(); 147 diffData.fResult.poiAlphaMask.reset();
148 148
149 bitmapsToCreate.alphaMask = false; 149 bitmapsToCreate.alphaMask = false;
150 } 150 }
151 151
152 if (bitmapsToCreate.rgbDiff 152 if (bitmapsToCreate.rgbDiff
153 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result 153 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result
154 && !diffData.fResult.rgbDiffBitmap.empty() 154 && !diffData.fResult.rgbDiffBitmap.empty()
155 && !newRecord->fCommonName.isEmpty()) { 155 && !newRecord->fCommonName.isEmpty()) {
156 // TODO(djsollen): Rather than taking the max r/g/b diffs that come back from 156 // TODO(djsollen): Rather than taking the max r/g/b diffs that come back from
157 // a particular differ and storing them as toplevel fields within 157 // a particular differ and storing them as toplevel fields within
158 // newRecord, we should extend outputRecords() to report optional 158 // newRecord, we should extend outputRecords() to report optional
159 // fields for each differ (not just "result" and "pointsOfInterest") . 159 // fields for each differ (not just "result" and "pointsOfInterest") .
160 // See http://skbug.com/2712 ('allow skpdiff to report different set s 160 // See http://skbug.com/2712 ('allow skpdiff to report different set s
161 // of result fields for different comparison algorithms') 161 // of result fields for different comparison algorithms')
162 newRecord->fMaxRedDiff = diffData.fResult.maxRedDiff; 162 newRecord->fMaxRedDiff = diffData.fResult.maxRedDiff;
163 newRecord->fMaxGreenDiff = diffData.fResult.maxGreenDiff; 163 newRecord->fMaxGreenDiff = diffData.fResult.maxGreenDiff;
164 newRecord->fMaxBlueDiff = diffData.fResult.maxBlueDiff; 164 newRecord->fMaxBlueDiff = diffData.fResult.maxBlueDiff;
165 165
166 newRecord->fRgbDiffPath = SkOSPath::SkPathJoin(fRgbDiffDir.c_str(), 166 newRecord->fRgbDiffPath = SkOSPath::Join(fRgbDiffDir.c_str(),
167 newRecord->fCommonNam e.c_str()); 167 newRecord->fCommonName.c_st r());
168 SkImageEncoder::EncodeFile(newRecord->fRgbDiffPath.c_str(), 168 SkImageEncoder::EncodeFile(newRecord->fRgbDiffPath.c_str(),
169 diffData.fResult.rgbDiffBitmap, 169 diffData.fResult.rgbDiffBitmap,
170 SkImageEncoder::kPNG_Type, 100); 170 SkImageEncoder::kPNG_Type, 100);
171 diffData.fResult.rgbDiffBitmap.reset(); 171 diffData.fResult.rgbDiffBitmap.reset();
172 bitmapsToCreate.rgbDiff = false; 172 bitmapsToCreate.rgbDiff = false;
173 } 173 }
174 174
175 if (bitmapsToCreate.whiteDiff 175 if (bitmapsToCreate.whiteDiff
176 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result 176 && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result
177 && !diffData.fResult.whiteDiffBitmap.empty() 177 && !diffData.fResult.whiteDiffBitmap.empty()
178 && !newRecord->fCommonName.isEmpty()) { 178 && !newRecord->fCommonName.isEmpty()) {
179 newRecord->fWhiteDiffPath = SkOSPath::SkPathJoin(fWhiteDiffDir.c_str (), 179 newRecord->fWhiteDiffPath = SkOSPath::Join(fWhiteDiffDir.c_str(),
180 newRecord->fCommonN ame.c_str()); 180 newRecord->fCommonName.c_ str());
181 SkImageEncoder::EncodeFile(newRecord->fWhiteDiffPath.c_str(), 181 SkImageEncoder::EncodeFile(newRecord->fWhiteDiffPath.c_str(),
182 diffData.fResult.whiteDiffBitmap, 182 diffData.fResult.whiteDiffBitmap,
183 SkImageEncoder::kPNG_Type, 100); 183 SkImageEncoder::kPNG_Type, 100);
184 diffData.fResult.whiteDiffBitmap.reset(); 184 diffData.fResult.whiteDiffBitmap.reset();
185 bitmapsToCreate.whiteDiff = false; 185 bitmapsToCreate.whiteDiff = false;
186 } 186 }
187 } 187 }
188 } 188 }
189 189
190 class SkThreadedDiff : public SkRunnable { 190 class SkThreadedDiff : public SkRunnable {
(...skipping 25 matching lines...) Expand all
216 } 216 }
217 217
218 SkThreadPool threadPool(fThreadCount); 218 SkThreadPool threadPool(fThreadCount);
219 SkTArray<SkThreadedDiff> runnableDiffs; 219 SkTArray<SkThreadedDiff> runnableDiffs;
220 runnableDiffs.reset(baselineEntries.count()); 220 runnableDiffs.reset(baselineEntries.count());
221 221
222 for (int x = 0; x < baselineEntries.count(); x++) { 222 for (int x = 0; x < baselineEntries.count(); x++) {
223 const char* baseFilename = baselineEntries[x].c_str(); 223 const char* baseFilename = baselineEntries[x].c_str();
224 224
225 // Find the real location of each file to compare 225 // Find the real location of each file to compare
226 SkString baselineFile = SkOSPath::SkPathJoin(baselinePath, baseFilename) ; 226 SkString baselineFile = SkOSPath::Join(baselinePath, baseFilename);
227 SkString testFile = SkOSPath::SkPathJoin(testPath, baseFilename); 227 SkString testFile = SkOSPath::Join(testPath, baseFilename);
228 228
229 // Check that the test file exists and is a file 229 // Check that the test file exists and is a file
230 if (sk_exists(testFile.c_str()) && !sk_isdir(testFile.c_str())) { 230 if (sk_exists(testFile.c_str()) && !sk_isdir(testFile.c_str())) {
231 // Queue up the comparison with the differ 231 // Queue up the comparison with the differ
232 runnableDiffs[x].setup(this, baselineFile, testFile); 232 runnableDiffs[x].setup(this, baselineFile, testFile);
233 threadPool.add(&runnableDiffs[x]); 233 threadPool.add(&runnableDiffs[x]);
234 } else { 234 } else {
235 SkDebugf("Baseline file \"%s\" has no corresponding test file\n", ba selineFile.c_str()); 235 SkDebugf("Baseline file \"%s\" has no corresponding test file\n", ba selineFile.c_str());
236 } 236 }
237 } 237 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 for (int i = 0; i < cntColumns; i++) { 433 for (int i = 0; i < cntColumns; i++) {
434 SkString str; 434 SkString str;
435 str.printf(", %f", values[i]); 435 str.printf(", %f", values[i]);
436 stream.writeText(str.c_str()); 436 stream.writeText(str.c_str());
437 } 437 }
438 stream.writeText("\n"); 438 stream.writeText("\n");
439 439
440 currentRecord = iter2.next(); 440 currentRecord = iter2.next();
441 } 441 }
442 } 442 }
OLDNEW
« no previous file with comments | « tools/skimage_main.cpp ('k') | tools/skpdiff/skpdiff_util.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698