2012-12-05 20:13:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef skdiff_utils_DEFINED
|
|
|
|
#define skdiff_utils_DEFINED
|
|
|
|
|
|
|
|
#include "skdiff.h"
|
|
|
|
|
|
|
|
class SkBitmap;
|
|
|
|
class SkData;
|
|
|
|
class SkString;
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
/** Returns true if the two buffers passed in are both non-nullptr,
|
2012-12-05 20:13:12 +00:00
|
|
|
* have the same length, and contain exactly the same byte values.
|
|
|
|
*/
|
|
|
|
bool are_buffers_equal(SkData* skdata1, SkData* skdata2);
|
|
|
|
|
|
|
|
/** Reads the file at the given path and returns its complete contents as an
|
2015-08-27 14:41:13 +00:00
|
|
|
* SkData object (or returns nullptr on error).
|
2012-12-05 20:13:12 +00:00
|
|
|
*/
|
|
|
|
SkData* read_file(const char* file_path);
|
|
|
|
|
|
|
|
/** Decodes the fileBits into the resource.fBitmap. Returns false on failure. */
|
2016-03-17 14:17:54 +00:00
|
|
|
bool get_bitmap(SkData* fileBits, DiffResource& resource, bool sizeOnly);
|
2012-12-05 20:13:12 +00:00
|
|
|
|
|
|
|
/** Writes the bitmap as a PNG to the path specified. */
|
|
|
|
bool write_bitmap(const SkString& path, const SkBitmap& bitmap);
|
|
|
|
|
|
|
|
/** Given an image filename, returns the name of the file containing
|
|
|
|
* the associated difference image.
|
|
|
|
*/
|
|
|
|
SkString filename_to_diff_filename(const SkString& filename);
|
|
|
|
|
|
|
|
/** Given an image filename, returns the name of the file containing
|
|
|
|
* the "white" difference image.
|
|
|
|
*/
|
|
|
|
SkString filename_to_white_filename(const SkString& filename);
|
|
|
|
|
|
|
|
/** Calls compute_diff and handles the difference and white diff resources.
|
|
|
|
* If !outputDir.isEmpty(), writes out difference and white images.
|
|
|
|
*/
|
|
|
|
void create_and_write_diff_image(DiffRecord* drp,
|
|
|
|
DiffMetricProc dmp,
|
|
|
|
const int colorThreshold,
|
|
|
|
const SkString& outputDir,
|
|
|
|
const SkString& filename);
|
|
|
|
|
|
|
|
#endif
|