[fiddle] Clear the canvas to white before calling draw().
Bug: skia: Change-Id: I17f1d47c3d04f09ca613e2d3f98d4c73e4bad02c Reviewed-on: https://skia-review.googlesource.com/19847 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Joe Gregorio <jcgregorio@google.com>
This commit is contained in:
parent
7e3a364337
commit
4f12f1e209
@ -93,6 +93,11 @@ static SkData* encode_snapshot(const sk_sp<SkSurface>& surface) {
|
||||
return img ? img->encode() : nullptr;
|
||||
}
|
||||
|
||||
static SkCanvas* prepare_canvas(SkCanvas * canvas) {
|
||||
canvas->clear(SK_ColorWHITE);
|
||||
return canvas;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
SkCommandLineFlags::Parse(argc, argv);
|
||||
duration = FLAGS_duration;
|
||||
@ -136,7 +141,7 @@ int main(int argc, char** argv) {
|
||||
if (options.raster) {
|
||||
auto rasterSurface = SkSurface::MakeRaster(info);
|
||||
srand(0);
|
||||
draw(rasterSurface->getCanvas());
|
||||
draw(prepare_canvas(rasterSurface->getCanvas()));
|
||||
rasterData.reset(encode_snapshot(rasterSurface));
|
||||
}
|
||||
if (options.gpu) {
|
||||
@ -150,7 +155,7 @@ int main(int argc, char** argv) {
|
||||
exit(1);
|
||||
}
|
||||
srand(0);
|
||||
draw(surface->getCanvas());
|
||||
draw(prepare_canvas(surface->getCanvas()));
|
||||
gpuData.reset(encode_snapshot(surface));
|
||||
}
|
||||
}
|
||||
@ -159,7 +164,7 @@ int main(int argc, char** argv) {
|
||||
sk_sp<SkDocument> document(SkDocument::MakePDF(&pdfStream));
|
||||
if (document) {
|
||||
srand(0);
|
||||
draw(document->beginPage(options.size.width(), options.size.height()));
|
||||
draw(prepare_canvas(document->beginPage(options.size.width(), options.size.height())));
|
||||
document->close();
|
||||
pdfData = pdfStream.detachAsData();
|
||||
}
|
||||
@ -169,7 +174,7 @@ int main(int argc, char** argv) {
|
||||
size = options.size;
|
||||
SkPictureRecorder recorder;
|
||||
srand(0);
|
||||
draw(recorder.beginRecording(size.width(), size.height()));
|
||||
draw(prepare_canvas(recorder.beginRecording(size.width(), size.height())));
|
||||
auto picture = recorder.finishRecordingAsPicture();
|
||||
SkDynamicMemoryWStream skpStream;
|
||||
picture->serialize(&skpStream);
|
||||
|
Loading…
Reference in New Issue
Block a user