ok: fix an assert from unbalanced save/restores
The 'dont_clip_to_layer' GM does not balance its layers. It calls saveLayer() 3x but restore() only 2x. This may be a bug in the GM itself, but I'm not sure so I haven't changed it here. If ok is writing .pngs, the surface passes ownership of its buffer to an image snapshot, simply marking it as immutable. Then, when the surface is destroyed later, it destroys its inner canvas, which restores its save stack to zero, actually doing some drawing in the case of unbalanced saveLayer()s. We then call notifyPixelsChanged() and hit an assert saying "you just wrote some pixels but this buffer was marked immutable." DM doesn't show this problem because it's doesn't really use surfaces and images, just bitmaps. There's no ownership handoff and nothing is ever immutable, so the condition triggering the assert never comes up. I'm not really sure where we want to say is the bug: - SkCanvas can draw in its destructor? - SkSurface doesn't restore to zero before snapping an image? - that dont_clip_to_layer should call restore three times? In any case, this guards against it in ok. I was using this as a convenient crash to help figure out how to best save and print stack traces, but now that I've got that worked out we might as well fix this. Change-Id: Id6d397f534dd1b50219e0d3078c989a4910883a6 Reviewed-on: https://skia-review.googlesource.com/10140 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
61e990297a
commit
adf7b330bd
@ -396,7 +396,10 @@ int main(int argc, char** argv) {
|
||||
|
||||
auto size = src->size();
|
||||
auto surface = SkSurface::MakeRasterN32Premul(size.width(), size.height());
|
||||
src->draw(surface->getCanvas());
|
||||
|
||||
auto canvas = surface->getCanvas();
|
||||
src->draw(canvas);
|
||||
canvas->restoreToCount(0);
|
||||
|
||||
if (!write_dir.empty()) {
|
||||
auto image = surface->makeImageSnapshot();
|
||||
|
Loading…
Reference in New Issue
Block a user