aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-06-23 13:32:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-23 17:56:31 +0000
commit2ac96dc82c45b4425c288dedbf3d35d70ac36928 (patch)
treecedce9afaea646b71ca607544a2a142fd5e953e2 /tools
parent80ce804f3e18e29726ab2575333e4441d312a9ed (diff)
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/viewer/Viewer.cpp8
-rw-r--r--tools/viewer/sk_app/Window.cpp2
-rw-r--r--tools/viewer/sk_app/Window.h2
-rw-r--r--tools/viewer/sk_app/win/Window_win.cpp7
-rw-r--r--tools/viewer/sk_app/win/Window_win.h2
5 files changed, 14 insertions, 7 deletions
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index e8e37346d8..c0b8dd83c0 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -684,7 +684,13 @@ void Viewer::setBackend(sk_app::Window::BackendType backendType) {
fWindow->registerMouseWheelFunc(on_mouse_wheel_handler, this);
fWindow->registerKeyFunc(on_key_handler, this);
fWindow->registerCharFunc(on_char_handler, this);
- fWindow->setRequestedDisplayParams(params);
+ // Don't allow the window to re-attach. If we're in MSAA mode, the params we grabbed above
+ // will still include our correct sample count. But the re-created fWindow will lose that
+ // information. On Windows, we need to re-create the window when changing sample count,
+ // so we'll incorrectly detect that situation, then re-initialize the window in GL mode,
+ // rendering this tear-down step pointless (and causing the Vulkan window context to fail
+ // as if we had never changed windows at all).
+ fWindow->setRequestedDisplayParams(params, false);
}
#endif
diff --git a/tools/viewer/sk_app/Window.cpp b/tools/viewer/sk_app/Window.cpp
index 12fb998ba7..9acea3f415 100644
--- a/tools/viewer/sk_app/Window.cpp
+++ b/tools/viewer/sk_app/Window.cpp
@@ -128,7 +128,7 @@ int Window::height() {
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 752dc47548..7d0c09750a 100644
--- a/tools/viewer/sk_app/Window.h
+++ b/tools/viewer/sk_app/Window.h
@@ -191,7 +191,7 @@ public:
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 6760089f79..0fb6513dae 100644
--- a/tools/viewer/sk_app/win/Window_win.cpp
+++ b/tools/viewer/sk_app/win/Window_win.cpp
@@ -369,9 +369,10 @@ void Window_win::onInval() {
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 @@ void Window_win::setRequestedDisplayParams(const DisplayParams& params) {
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 0c6e1f2915..139ab874c6 100644
--- a/tools/viewer/sk_app/win/Window_win.h
+++ b/tools/viewer/sk_app/win/Window_win.h
@@ -27,7 +27,7 @@ public:
void onInval() override;
- void setRequestedDisplayParams(const DisplayParams&) override;
+ void setRequestedDisplayParams(const DisplayParams&, bool allowReattach) override;
private:
void closeWindow();