aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skdiff/skdiff_utils.h
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-10-13 17:36:40 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-14 14:02:42 +0000
commitfe9172705791848ebfe5b5630973b7e67305f64c (patch)
tree15c823ed4d95e16e20126e9529d0104ba7886fe0 /tools/skdiff/skdiff_utils.h
parentc434f5122a2394639ddeb66a1ded456565b043cd (diff)
Move skdiff tool and add to gn build.
I really wanted this today, so I got it working again. Change-Id: I1a37d48d4806198b55c59d1df5ff15a03500195f Reviewed-on: https://skia-review.googlesource.com/3383 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tools/skdiff/skdiff_utils.h')
-rw-r--r--tools/skdiff/skdiff_utils.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/skdiff/skdiff_utils.h b/tools/skdiff/skdiff_utils.h
new file mode 100644
index 0000000000..c799325e36
--- /dev/null
+++ b/tools/skdiff/skdiff_utils.h
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+/** Returns true if the two buffers passed in are both non-nullptr,
+ * 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
+ * SkData object (or returns nullptr on error).
+ */
+sk_sp<SkData> read_file(const char* file_path);
+
+/** Decodes the fileBits into the resource.fBitmap. Returns false on failure. */
+bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly);
+
+/** 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