blob: dfb7f920223ccc029fa39dbb73e74e646ec60ab7 [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"
mtklein0b36e6b2014-09-11 12:30:12 -07005#include "SkCanvas.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00006#include "SkString.h"
mtklein197ceda2014-09-09 07:36:57 -07007#include "gm.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00008
commit-bot@chromium.org5fb2ce32014-04-17 23:35:06 +00009class SkBBHFactory;
robertphillips@google.com84b18c72014-04-13 19:09:42 +000010
mtklein@google.comd36522d2013-10-16 13:02:15 +000011// Small free functions used in more than one place in DM.
12
13namespace DM {
14
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000015// UnderJoin("a", "b") -> "a_b"
16SkString UnderJoin(const char* a, const char* b);
mtklein@google.comd36522d2013-10-16 13:02:15 +000017
mtkleine4d3e602014-06-06 09:28:43 -070018// "foo_bar.skp" -> "foo-bar_skp"
19SkString FileToTaskName(SkString);
20
mtkleina9ceaf52014-09-29 08:44:46 -070021// Draw gm to picture.
22SkPicture* RecordPicture(skiagm::GM* gm, SkBBHFactory* factory = NULL);
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000023
commit-bot@chromium.org26642072014-05-15 17:33:31 +000024// Allocate an empty bitmap with this size and depth.
25void AllocatePixels(SkColorType, int w, int h, SkBitmap* bitmap);
26// Allocate an empty bitmap the same size and depth as reference.
27void AllocatePixels(const SkBitmap& reference, SkBitmap* bitmap);
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000028
29// Draw picture to bitmap.
mtklein73734562014-06-24 12:28:34 -070030void DrawPicture(const SkPicture& picture, SkBitmap* bitmap);
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000031
commit-bot@chromium.org69031a42014-05-16 13:03:46 +000032// What is the maximum component difference in these bitmaps?
33unsigned MaxComponentDifference(const SkBitmap& a, const SkBitmap& b);
34
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000035// Are these identical bitmaps?
36bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b);
mtklein@google.comd36522d2013-10-16 13:02:15 +000037
mtklein0b36e6b2014-09-11 12:30:12 -070038// Hook to modify canvas using global flag values (e.g. --matrix).
39void CanvasPreflight(SkCanvas*);
40
mtklein@google.comd36522d2013-10-16 13:02:15 +000041} // namespace DM
42
43#endif // DMUtil_DEFINED