aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMUtil.h
blob: 8de767db2b9972517b141c6744ca66b1764df8b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef DMUtil_DEFINED
#define DMUtil_DEFINED

#include "SkBitmap.h"
#include "SkString.h"
#include "gm_expectations.h"

class SkBBHFactory;

// Small free functions used in more than one place in DM.

namespace DM {

// UnderJoin("a", "b") -> "a_b"
SkString UnderJoin(const char* a, const char* b);

// "foo_bar.skp" -> "foo-bar_skp"
SkString FileToTaskName(SkString);

// Draw gm to picture.  If skr is true, uses EXPERIMENTAL_beginRecording().
SkPicture* RecordPicture(skiagm::GM* gm,
                         SkBBHFactory* factory = NULL,
                         bool skr = false);

// Allocate an empty bitmap with this size and depth.
void AllocatePixels(SkColorType, int w, int h, SkBitmap* bitmap);
// Allocate an empty bitmap the same size and depth as reference.
void AllocatePixels(const SkBitmap& reference, SkBitmap* bitmap);

// Draw picture to bitmap.
void DrawPicture(const SkPicture& picture, SkBitmap* bitmap);

// What is the maximum component difference in these bitmaps?
unsigned MaxComponentDifference(const SkBitmap& a, const SkBitmap& b);

// Are these identical bitmaps?
bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b);

}  // namespace DM

#endif  // DMUtil_DEFINED