1#ifndef DMUtil_DEFINED 2#define DMUtil_DEFINED 3 4#include "SkBitmap.h" 5#include "SkCanvas.h" 6#include "SkString.h" 7#include "gm.h" 8 9class SkBBHFactory; 10 11// Small free functions used in more than one place in DM. 12 13namespace DM { 14 15// UnderJoin("a", "b") -> "a_b" 16SkString UnderJoin(const char* a, const char* b); 17 18// "foo_bar.skp" -> "foo-bar_skp" 19SkString FileToTaskName(SkString); 20 21// Draw gm to picture. If skr is true, uses EXPERIMENTAL_beginRecording(). 22SkPicture* RecordPicture(skiagm::GM* gm, 23 SkBBHFactory* factory = NULL, 24 bool skr = false); 25 26// Allocate an empty bitmap with this size and depth. 27void AllocatePixels(SkColorType, int w, int h, SkBitmap* bitmap); 28// Allocate an empty bitmap the same size and depth as reference. 29void AllocatePixels(const SkBitmap& reference, SkBitmap* bitmap); 30 31// Draw picture to bitmap. 32void DrawPicture(const SkPicture& picture, SkBitmap* bitmap); 33 34// What is the maximum component difference in these bitmaps? 35unsigned MaxComponentDifference(const SkBitmap& a, const SkBitmap& b); 36 37// Are these identical bitmaps? 38bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b); 39 40// Hook to modify canvas using global flag values (e.g. --matrix). 41void CanvasPreflight(SkCanvas*); 42 43} // namespace DM 44 45#endif // DMUtil_DEFINED 46