Flutter Engine
The Flutter Engine
Functions
skdiff_html.h File Reference
#include "tools/skdiff/skdiff.h"

Go to the source code of this file.

Functions

void print_diff_page (const int matchCount, const int colorThreshold, const RecordArray &differences, const SkString &baseDir, const SkString &comparisonDir, const SkString &outputDir)
 

Function Documentation

◆ print_diff_page()

void print_diff_page ( const int  matchCount,
const int  colorThreshold,
const RecordArray differences,
const SkString baseDir,
const SkString comparisonDir,
const SkString outputDir 
)

Definition at line 206 of file skdiff_html.cpp.

211 {
212
213 SkASSERT(!baseDir.isEmpty());
214 SkASSERT(!comparisonDir.isEmpty());
215 SkASSERT(!outputDir.isEmpty());
216
217 SkString outputPath(outputDir);
218 outputPath.append("index.html");
219 //SkFILEWStream outputStream ("index.html");
220 SkFILEWStream outputStream(outputPath.c_str());
221
222 // Need to convert paths from relative-to-cwd to relative-to-outputDir
223 // FIXME this doesn't work if there are '..' inside the outputDir
224
225 bool isPathAbsolute = false;
226 // On Windows or Linux, a path starting with PATH_DIV_CHAR is absolute.
227 if (outputDir.size() > 0 && PATH_DIV_CHAR == outputDir[0]) {
228 isPathAbsolute = true;
229 }
230#ifdef SK_BUILD_FOR_WIN
231 // On Windows, absolute paths can also start with "x:", where x is any
232 // drive letter.
233 if (outputDir.size() > 1 && ':' == outputDir[1]) {
234 isPathAbsolute = true;
235 }
236#endif
237
238 SkString relativePath;
239 if (!isPathAbsolute) {
240 unsigned int ui;
241 for (ui = 0; ui < outputDir.size(); ui++) {
242 if (outputDir[ui] == PATH_DIV_CHAR) {
243 relativePath.append(".." PATH_DIV_STR);
244 }
245 }
246 }
247
248 outputStream.writeText(
249 "<html>\n<head>\n"
250 "<script type=\"text/javascript\">\n"
251 "function generateCheckedList() {\n"
252 " const boxes = document.querySelectorAll('input[type=checkbox]:checked');\n"
253 " let fileCmdLineString = '';\n"
254 " let fileMultiLineString = '';\n"
255 " for (let i = 0; i < boxes.length; i++) {\n"
256 " fileMultiLineString += boxes[i].name + '<br>';\n"
257 " fileCmdLineString += boxes[i].name + '&nbsp;';\n"
258 " }\n"
259 " const checkedList = document.querySelector('#checkedList');\n"
260 " checkedList.innerHTML = fileCmdLineString + '<br><br>' + fileMultiLineString;\n"
261 "}\n"
262 "</script>\n</head>\n<body>\n");
263 print_table_header(&outputStream, matchCount, colorThreshold, differences,
264 baseDir, comparisonDir);
265 int i;
266 for (i = 0; i < differences.size(); i++) {
267 const DiffRecord& diff = differences[i];
268
269 switch (diff.fResult) {
270 // Cases in which there is no diff to report.
273 continue;
274 // Cases in which we want a detailed pixel diff.
278 print_diff_row(&outputStream, diff, relativePath);
279 continue;
280 default:
281 SkDEBUGFAIL("encountered DiffRecord with unknown result type");
282 continue;
283 }
284 }
285 outputStream.writeText(
286 "</table>\n"
287 "<input type=\"button\" "
288 "onclick=\"generateCheckedList()\" "
289 "value=\"Create Rebaseline List\">\n"
290 "<div id=\"checkedList\"></div>\n"
291 "</body>\n</html>\n");
292 outputStream.flush();
293}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
#define SkASSERT(cond)
Definition: SkAssert.h:116
size_t size() const
Definition: SkString.h:131
bool isEmpty() const
Definition: SkString.h:130
void append(const char text[])
Definition: SkString.h:203
int size() const
Definition: SkTArray.h:421
#define PATH_DIV_STR
Definition: skdiff.h:21
#define PATH_DIV_CHAR
Definition: skdiff.h:22
static void print_diff_row(SkFILEWStream *stream, const DiffRecord &diff, const SkString &relativePath)
static void print_table_header(SkFILEWStream *stream, const int matchCount, const int colorThreshold, const RecordArray &differences, const SkString &baseDir, const SkString &comparisonDir)
Definition: skdiff_html.cpp:27
Result fResult
Which category of diff result.
Definition: skdiff.h:154
@ kEqualBits_Result
Definition: skdiff.h:92
@ kCouldNotCompare_Result
Definition: skdiff.h:96
@ kDifferentSizes_Result
Definition: skdiff.h:95
@ kDifferentPixels_Result
Definition: skdiff.h:94
@ kEqualPixels_Result
Definition: skdiff.h:93