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

Side by Side Diff: tools/imagediff/image_diff.cc

Issue 6696085: Add the ability to write comments to PNGCodec::Encode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: strdup Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file input format is based loosely on 5 // This file input format is based loosely on
6 // Tools/DumpRenderTree/ImageDiff.m 6 // Tools/DumpRenderTree/ImageDiff.m
7 7
8 // The exact format of this tool's output to stdout is important, to match 8 // The exact format of this tool's output to stdout is important, to match
9 // what the run-webkit-tests script expects. 9 // what the run-webkit-tests script expects.
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <vector> 12 #include <vector>
13 #include <string> 13 #include <string>
14 #include <iostream> 14 #include <iostream>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/file_path.h" 18 #include "base/file_path.h"
19 #include "base/file_util.h" 19 #include "base/file_util.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/scoped_ptr.h" 22 #include "base/scoped_ptr.h"
23 #include "base/string_util.h" 23 #include "base/string_util.h"
24 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
25 #include "ui/gfx/codec/png_codec.h" 25 #include "ui/gfx/codec/png_codec.h"
26 #include "ui/gfx/size.h"
26 27
27 #if defined(OS_WIN) 28 #if defined(OS_WIN)
28 #include "windows.h" 29 #include "windows.h"
29 #endif 30 #endif
30 31
31 // Causes the app to remain open, waiting for pairs of filenames on stdin. 32 // Causes the app to remain open, waiting for pairs of filenames on stdin.
32 // The caller is then responsible for terminating this app. 33 // The caller is then responsible for terminating this app.
33 static const char kOptionPollStdin[] = "use-stdin"; 34 static const char kOptionPollStdin[] = "use-stdin";
34 static const char kOptionGenerateDiff[] = "diff"; 35 static const char kOptionGenerateDiff[] = "diff";
35 36
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return kStatusError; 310 return kStatusError;
310 } 311 }
311 312
312 Image diff_image; 313 Image diff_image;
313 bool same = CreateImageDiff(baseline_image, actual_image, &diff_image); 314 bool same = CreateImageDiff(baseline_image, actual_image, &diff_image);
314 if (same) 315 if (same)
315 return kStatusSame; 316 return kStatusSame;
316 317
317 std::vector<unsigned char> png_encoding; 318 std::vector<unsigned char> png_encoding;
318 gfx::PNGCodec::Encode(diff_image.data(), gfx::PNGCodec::FORMAT_RGBA, 319 gfx::PNGCodec::Encode(diff_image.data(), gfx::PNGCodec::FORMAT_RGBA,
319 diff_image.w(), diff_image.h(), diff_image.w() * 4, 320 gfx::Size(diff_image.w(), diff_image.h()),
320 false, &png_encoding); 321 diff_image.w() * 4, false,
322 std::vector<gfx::PNGCodec::Comment>(), &png_encoding);
321 if (file_util::WriteFile(out_file, 323 if (file_util::WriteFile(out_file,
322 reinterpret_cast<char*>(&png_encoding.front()), png_encoding.size()) < 0) 324 reinterpret_cast<char*>(&png_encoding.front()), png_encoding.size()) < 0)
323 return kStatusError; 325 return kStatusError;
324 326
325 return kStatusDifferent; 327 return kStatusDifferent;
326 } 328 }
327 329
328 // It isn't strictly correct to only support ASCII paths, but this 330 // It isn't strictly correct to only support ASCII paths, but this
329 // program reads paths on stdin and the program that spawns it outputs 331 // program reads paths on stdin and the program that spawns it outputs
330 // paths as non-wide strings anyway. 332 // paths as non-wide strings anyway.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 FilePath(args[1]), 373 FilePath(args[1]),
372 FilePath(args[2])); 374 FilePath(args[2]));
373 } 375 }
374 } else if (args.size() == 2) { 376 } else if (args.size() == 2) {
375 return CompareImages(FilePath(args[0]), FilePath(args[1])); 377 return CompareImages(FilePath(args[0]), FilePath(args[1]));
376 } 378 }
377 379
378 PrintHelp(); 380 PrintHelp();
379 return kStatusError; 381 return kStatusError;
380 } 382 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698