bungeman@google.com | e3c8ddf | 2012-12-05 20:13:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef skdiff_utils_DEFINED |
| 9 | #define skdiff_utils_DEFINED |
| 10 | |
| 11 | #include "skdiff.h" |
bungeman@google.com | e3c8ddf | 2012-12-05 20:13:12 +0000 | [diff] [blame] | 12 | |
| 13 | class SkBitmap; |
| 14 | class SkData; |
| 15 | class SkString; |
| 16 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 17 | /** Returns true if the two buffers passed in are both non-nullptr, |
bungeman@google.com | e3c8ddf | 2012-12-05 20:13:12 +0000 | [diff] [blame] | 18 | * have the same length, and contain exactly the same byte values. |
| 19 | */ |
| 20 | bool are_buffers_equal(SkData* skdata1, SkData* skdata2); |
| 21 | |
| 22 | /** Reads the file at the given path and returns its complete contents as an |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 23 | * SkData object (or returns nullptr on error). |
bungeman@google.com | e3c8ddf | 2012-12-05 20:13:12 +0000 | [diff] [blame] | 24 | */ |
| 25 | SkData* read_file(const char* file_path); |
| 26 | |
| 27 | /** Decodes the fileBits into the resource.fBitmap. Returns false on failure. */ |
msarett | 667433f | 2016-03-17 07:17:54 -0700 | [diff] [blame] | 28 | bool get_bitmap(SkData* fileBits, DiffResource& resource, bool sizeOnly); |
bungeman@google.com | e3c8ddf | 2012-12-05 20:13:12 +0000 | [diff] [blame] | 29 | |
| 30 | /** Writes the bitmap as a PNG to the path specified. */ |
| 31 | bool write_bitmap(const SkString& path, const SkBitmap& bitmap); |
| 32 | |
| 33 | /** Given an image filename, returns the name of the file containing |
| 34 | * the associated difference image. |
| 35 | */ |
| 36 | SkString filename_to_diff_filename(const SkString& filename); |
| 37 | |
| 38 | /** Given an image filename, returns the name of the file containing |
| 39 | * the "white" difference image. |
| 40 | */ |
| 41 | SkString filename_to_white_filename(const SkString& filename); |
| 42 | |
| 43 | /** Calls compute_diff and handles the difference and white diff resources. |
| 44 | * If !outputDir.isEmpty(), writes out difference and white images. |
| 45 | */ |
| 46 | void create_and_write_diff_image(DiffRecord* drp, |
| 47 | DiffMetricProc dmp, |
| 48 | const int colorThreshold, |
| 49 | const SkString& outputDir, |
| 50 | const SkString& filename); |
| 51 | |
| 52 | #endif |