#include "tools/fiddle/examples.h"
REG_FIDDLE(Canvas_MakeRasterDirect, 256, 256, true, 0) {
void draw(SkCanvas*) {
SkImageInfo info = SkImageInfo::MakeN32Premul(3, 3);
const size_t minRowBytes = info.minRowBytes();
const size_t size = info.computeMinByteSize();
SkPMColor* pixels = new SkPMColor[size];
std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(info, pixels, minRowBytes);
canvas->clear(SK_ColorWHITE);
SkPMColor pmWhite = pixels[0];
SkPaint paint;
canvas->drawPoint(1, 1, paint);
for (int y = 0; y < info.height(); ++y) {
for (int x = 0; x < info.width(); ++x) {
SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x');
}
SkDebugf("\n");
}
delete[] pixels;
}
}