Hack to fix MSAA GL -> Vk transition on Windows Viewer

Bug: skia:
Change-Id: I49417789ab43734a1cbb4010281482970579971d
Reviewed-on: https://skia-review.googlesource.com/20505
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tools/viewer/sk_app/Window.cpp b/tools/viewer/sk_app/Window.cpp
index 12fb998..9acea3f 100644
--- a/tools/viewer/sk_app/Window.cpp
+++ b/tools/viewer/sk_app/Window.cpp
@@ -128,7 +128,7 @@
     return fWindowContext->height();
 }
 
-void Window::setRequestedDisplayParams(const DisplayParams& params) {
+void Window::setRequestedDisplayParams(const DisplayParams& params, bool /* allowReattach */) {
     fRequestedDisplayParams = params;
     if (fWindowContext) {
         fWindowContext->setDisplayParams(fRequestedDisplayParams);
diff --git a/tools/viewer/sk_app/Window.h b/tools/viewer/sk_app/Window.h
index 752dc47..7d0c097 100644
--- a/tools/viewer/sk_app/Window.h
+++ b/tools/viewer/sk_app/Window.h
@@ -191,7 +191,7 @@
     int height();
 
     virtual const DisplayParams& getRequestedDisplayParams() { return fRequestedDisplayParams; }
-    virtual void setRequestedDisplayParams(const DisplayParams&);
+    virtual void setRequestedDisplayParams(const DisplayParams&, bool allowReattach = true);
 
     // Actual parameters in effect, obtained from the native window.
     int sampleCount() const;
diff --git a/tools/viewer/sk_app/win/Window_win.cpp b/tools/viewer/sk_app/win/Window_win.cpp
index 6760089..0fb6513 100644
--- a/tools/viewer/sk_app/win/Window_win.cpp
+++ b/tools/viewer/sk_app/win/Window_win.cpp
@@ -369,9 +369,10 @@
     InvalidateRect(fHWnd, nullptr, false);
 }
 
-void Window_win::setRequestedDisplayParams(const DisplayParams& params) {
+void Window_win::setRequestedDisplayParams(const DisplayParams& params, bool allowReattach) {
     // GL on Windows doesn't let us change MSAA after the window is created
-    if (params.fMSAASampleCount != this->getRequestedDisplayParams().fMSAASampleCount) {
+    if (params.fMSAASampleCount != this->getRequestedDisplayParams().fMSAASampleCount
+            && allowReattach) {
         // Need to change these early, so attach() creates the window context correctly
         fRequestedDisplayParams = params;
 
@@ -381,7 +382,7 @@
         this->attach(fBackend);
     }
 
-    INHERITED::setRequestedDisplayParams(params);
+    INHERITED::setRequestedDisplayParams(params, allowReattach);
 }
 
 }   // namespace sk_app
diff --git a/tools/viewer/sk_app/win/Window_win.h b/tools/viewer/sk_app/win/Window_win.h
index 0c6e1f2..139ab87 100644
--- a/tools/viewer/sk_app/win/Window_win.h
+++ b/tools/viewer/sk_app/win/Window_win.h
@@ -27,7 +27,7 @@
 
     void onInval() override;
 
-    void setRequestedDisplayParams(const DisplayParams&) override;
+    void setRequestedDisplayParams(const DisplayParams&, bool allowReattach) override;
 
 private:
     void closeWindow();