[viewer] Tear down any GPU resources on a resize.

On GL, and possibly other backends, we reset the context on a resize,
so we need to tear down any GPU resources and rebuild them for the
next draw.

Bug: b/301949729
Change-Id: If5e5b8af48b937e63c8ee68b1b2ff5b84193a67a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/864456
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index b1af47b..017559d 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1890,6 +1890,10 @@
 void Viewer::onResize(int width, int height) {
     if (fCurrentSlide >= 0) {
+        // Resizing can reset the context on some backends so just tear it all down.
+        // We'll rebuild these resources on the next draw.
+        fSlides[fCurrentSlide]->gpuTeardown();
         SkScalar scaleFactor = 1.0;
         if (fApplyBackingScale) {
             scaleFactor = fWindow->scaleFactor();