blob: 8de767db2b9972517b141c6744ca66b1764df8b0 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#ifndef DMUtil_DEFINED
2#define DMUtil_DEFINED
3
commit-bot@chromium.org66bb3d12013-10-16 19:13:38 +00004#include "SkBitmap.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00005#include "SkString.h"
6#include "gm_expectations.h"
7
commit-bot@chromium.org5fb2ce32014-04-17 23:35:06 +00008class SkBBHFactory;
robertphillips@google.com84b18c72014-04-13 19:09:42 +00009
mtklein@google.comd36522d2013-10-16 13:02:15 +000010// Small free functions used in more than one place in DM.
11
12namespace DM {
13
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000014// UnderJoin("a", "b") -> "a_b"
15SkString UnderJoin(const char* a, const char* b);
mtklein@google.comd36522d2013-10-16 13:02:15 +000016
mtkleine4d3e602014-06-06 09:28:43 -070017// "foo_bar.skp" -> "foo-bar_skp"
18SkString FileToTaskName(SkString);
19
mtklein73734562014-06-24 12:28:34 -070020// Draw gm to picture. If skr is true, uses EXPERIMENTAL_beginRecording().
skia.committer@gmail.com51997012014-04-14 03:04:57 +000021SkPicture* RecordPicture(skiagm::GM* gm,
mtklein73734562014-06-24 12:28:34 -070022 SkBBHFactory* factory = NULL,
23 bool skr = false);
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000024
commit-bot@chromium.org26642072014-05-15 17:33:31 +000025// Allocate an empty bitmap with this size and depth.
26void AllocatePixels(SkColorType, int w, int h, SkBitmap* bitmap);
27// Allocate an empty bitmap the same size and depth as reference.
28void AllocatePixels(const SkBitmap& reference, SkBitmap* bitmap);
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000029
30// Draw picture to bitmap.
mtklein73734562014-06-24 12:28:34 -070031void DrawPicture(const SkPicture& picture, SkBitmap* bitmap);
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000032
commit-bot@chromium.org69031a42014-05-16 13:03:46 +000033// What is the maximum component difference in these bitmaps?
34unsigned MaxComponentDifference(const SkBitmap& a, const SkBitmap& b);
35
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000036// Are these identical bitmaps?
37bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b);
mtklein@google.comd36522d2013-10-16 13:02:15 +000038
39} // namespace DM
40
41#endif // DMUtil_DEFINED