Home | History | Annotate | Download | only in dm
      1 #include "DMUtil.h"
      2 
      3 #include "SkPicture.h"
      4 
      5 namespace DM {
      6 
      7 SkString UnderJoin(const char* a, const char* b) {
      8     SkString s;
      9     s.appendf("%s_%s", a, b);
     10     return s;
     11 }
     12 
     13 void RecordPicture(skiagm::GM* gm, SkPicture* picture, uint32_t recordFlags) {
     14     const SkISize size = gm->getISize();
     15     SkCanvas* canvas = picture->beginRecording(size.width(), size.height(), recordFlags);
     16     canvas->concat(gm->getInitialTransform());
     17     gm->draw(canvas);
     18     canvas->flush();
     19     picture->endRecording();
     20 }
     21 
     22 void SetupBitmap(const SkBitmap::Config config, skiagm::GM* gm, SkBitmap* bitmap) {
     23     const SkISize size = gm->getISize();
     24     bitmap->setConfig(config, size.width(), size.height());
     25     bitmap->allocPixels();
     26     bitmap->eraseColor(0x00000000);
     27 }
     28 
     29 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) {
     30     SkASSERT(picture != NULL);
     31     SkASSERT(bitmap != NULL);
     32     SkCanvas canvas(*bitmap);
     33     canvas.drawPicture(*picture);
     34     canvas.flush();
     35 }
     36 
     37 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) {
     38     const SkAutoLockPixels lockA(a), lockB(b);
     39     return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels(), b.getSize());
     40 }
     41 
     42 }  // namespace DM
     43