90b5a2a653
This does render_pictures, plus checks SkRecord optimizations. Disable an SkRecord optimization that draws several bot SKPs wrong. (To be investigated.) BUG=skia:2378 R=reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/270543004 git-svn-id: http://skia.googlecode.com/svn/trunk@14739 2bbb7eff-a529-9590-31e7-b0007b416f81
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#include "DMUtil.h"
|
|
|
|
#include "SkPicture.h"
|
|
#include "SkPictureRecorder.h"
|
|
|
|
namespace DM {
|
|
|
|
SkString UnderJoin(const char* a, const char* b) {
|
|
SkString s;
|
|
s.appendf("%s_%s", a, b);
|
|
return s;
|
|
}
|
|
|
|
SkPicture* RecordPicture(skiagm::GM* gm, uint32_t recordFlags, SkBBHFactory* factory) {
|
|
const SkISize size = gm->getISize();
|
|
SkPictureRecorder recorder;
|
|
SkCanvas* canvas = recorder.beginRecording(size.width(), size.height(), factory, recordFlags);
|
|
canvas->concat(gm->getInitialTransform());
|
|
gm->draw(canvas);
|
|
canvas->flush();
|
|
return recorder.endRecording();
|
|
}
|
|
|
|
static void setup_bitmap(SkColorType ct, int width, int height, SkBitmap* bitmap) {
|
|
bitmap->allocPixels(SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType));
|
|
bitmap->eraseColor(0x00000000);
|
|
}
|
|
|
|
void SetupBitmap(SkColorType ct, skiagm::GM* gm, SkBitmap* bitmap) {
|
|
setup_bitmap(ct, gm->getISize().width(), gm->getISize().height(), bitmap);
|
|
}
|
|
|
|
void SetupBitmap(SkColorType ct, SkBenchmark* bench, SkBitmap* bitmap) {
|
|
setup_bitmap(ct, bench->getSize().x(), bench->getSize().y(), bitmap);
|
|
}
|
|
|
|
void SetupBitmap(SkColorType ct, const SkPicture& pic, SkBitmap* bitmap) {
|
|
setup_bitmap(ct, pic.width(), pic.height(), bitmap);
|
|
}
|
|
|
|
void DrawPicture(SkPicture* picture, SkBitmap* bitmap) {
|
|
SkASSERT(picture != NULL);
|
|
SkASSERT(bitmap != NULL);
|
|
SkCanvas canvas(*bitmap);
|
|
canvas.drawPicture(*picture);
|
|
canvas.flush();
|
|
}
|
|
|
|
bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) {
|
|
const SkAutoLockPixels lockA(a), lockB(b);
|
|
return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels(), b.getSize());
|
|
}
|
|
|
|
} // namespace DM
|