diff options
author | csmartdalton <csmartdalton@google.com> | 2017-02-24 16:04:47 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-27 16:46:34 +0000 |
commit | 578f064a60b63ddfb00831e9e59a47060bfcefe0 (patch) | |
tree | c38f7fe730f7933d322c4455c45c9531d539c77d /tools/viewer/sk_app/unix | |
parent | ab8e02a4dee79fc4300c5eec0fbbc44d07f433d3 (diff) |
Add msaa flag and UI to viewer
BUG=skia:
Change-Id: I0a24d5e6a4271f84ea5c82eb6d9ede9a1e63f86a
Reviewed-on: https://skia-review.googlesource.com/8787
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'tools/viewer/sk_app/unix')
-rw-r--r-- | tools/viewer/sk_app/unix/Window_unix.cpp | 34 | ||||
-rw-r--r-- | tools/viewer/sk_app/unix/Window_unix.h | 4 | ||||
-rw-r--r-- | tools/viewer/sk_app/unix/main_unix.cpp | 5 |
3 files changed, 24 insertions, 19 deletions
diff --git a/tools/viewer/sk_app/unix/Window_unix.cpp b/tools/viewer/sk_app/unix/Window_unix.cpp index d7bb84945c..de3cbd868e 100644 --- a/tools/viewer/sk_app/unix/Window_unix.cpp +++ b/tools/viewer/sk_app/unix/Window_unix.cpp @@ -29,7 +29,7 @@ Window* Window::CreateNativeWindow(void* platformData) { SkASSERT(display); Window_unix* window = new Window_unix(); - if (!window->initWindow(display, nullptr)) { + if (!window->initWindow(display)) { delete window; return nullptr; } @@ -41,8 +41,8 @@ const long kEventMask = ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask; -bool Window_unix::initWindow(Display* display, const DisplayParams* params) { - if (params && params->fMSAASampleCount != fMSAASampleCount) { +bool Window_unix::initWindow(Display* display) { + if (fRequestedDisplayParams.fMSAASampleCount != fMSAASampleCount) { this->closeWindow(); } // we already have a window @@ -63,7 +63,7 @@ bool Window_unix::initWindow(Display* display, const DisplayParams* params) { None }; SkASSERT(nullptr == fVisualInfo); - if (params && params->fMSAASampleCount > 0) { + if (fRequestedDisplayParams.fMSAASampleCount > 0) { static const GLint kAttCount = SK_ARRAY_COUNT(att); GLint msaaAtt[kAttCount + 4]; memcpy(msaaAtt, att, sizeof(att)); @@ -71,14 +71,12 @@ bool Window_unix::initWindow(Display* display, const DisplayParams* params) { msaaAtt[kAttCount - 1] = GLX_SAMPLE_BUFFERS_ARB; msaaAtt[kAttCount + 0] = 1; msaaAtt[kAttCount + 1] = GLX_SAMPLES_ARB; - msaaAtt[kAttCount + 2] = params->fMSAASampleCount; + msaaAtt[kAttCount + 2] = fRequestedDisplayParams.fMSAASampleCount; msaaAtt[kAttCount + 3] = None; fVisualInfo = glXChooseVisual(display, DefaultScreen(display), msaaAtt); - fMSAASampleCount = params->fMSAASampleCount; } if (nullptr == fVisualInfo) { fVisualInfo = glXChooseVisual(display, DefaultScreen(display), att); - fMSAASampleCount = 0; } if (fVisualInfo) { @@ -115,6 +113,8 @@ bool Window_unix::initWindow(Display* display, const DisplayParams* params) { return false; } + fMSAASampleCount = fRequestedDisplayParams.fMSAASampleCount; + // set up to catch window delete message fWmDeleteMessage = XInternAtom(display, "WM_DELETE_WINDOW", False); XSetWMProtocols(display, fWindow, &fWmDeleteMessage, 1); @@ -132,15 +132,15 @@ bool Window_unix::initWindow(Display* display, const DisplayParams* params) { void Window_unix::closeWindow() { if (fDisplay) { this->detach(); - SkASSERT(fGC); - XFreeGC(fDisplay, fGC); - fGC = nullptr; + if (fGC) { + XFreeGC(fDisplay, fGC); + fGC = nullptr; + } gWindowMap.remove(fWindow); XDestroyWindow(fDisplay, fWindow); fWindow = 0; fVisualInfo = nullptr; fDisplay = nullptr; - fMSAASampleCount = 0; } } @@ -292,8 +292,8 @@ void Window_unix::show() { XMapWindow(fDisplay, fWindow); } -bool Window_unix::attach(BackendType attachType, const DisplayParams& params) { - this->initWindow(fDisplay, ¶ms); +bool Window_unix::attach(BackendType attachType) { + this->initWindow(fDisplay); window_context_factory::XlibWindowInfo winInfo; winInfo.fDisplay = fDisplay; @@ -311,14 +311,16 @@ bool Window_unix::attach(BackendType attachType, const DisplayParams& params) { switch (attachType) { #ifdef SK_VULKAN case kVulkan_BackendType: - fWindowContext = window_context_factory::NewVulkanForXlib(winInfo, params); + fWindowContext = window_context_factory::NewVulkanForXlib(winInfo, + fRequestedDisplayParams); break; #endif case kNativeGL_BackendType: - fWindowContext = window_context_factory::NewGLForXlib(winInfo, params); + fWindowContext = window_context_factory::NewGLForXlib(winInfo, fRequestedDisplayParams); break; case kRaster_BackendType: - fWindowContext = window_context_factory::NewRasterForXlib(winInfo, params); + fWindowContext = window_context_factory::NewRasterForXlib(winInfo, + fRequestedDisplayParams); break; } this->onBackendCreated(); diff --git a/tools/viewer/sk_app/unix/Window_unix.h b/tools/viewer/sk_app/unix/Window_unix.h index b0c06c5856..be202f74d2 100644 --- a/tools/viewer/sk_app/unix/Window_unix.h +++ b/tools/viewer/sk_app/unix/Window_unix.h @@ -28,12 +28,12 @@ public: , fMSAASampleCount(0) {} ~Window_unix() override { this->closeWindow(); } - bool initWindow(Display* display, const DisplayParams* params); + bool initWindow(Display* display); void setTitle(const char*) override; void show() override; - bool attach(BackendType attachType, const DisplayParams& params) override; + bool attach(BackendType) override; void onInval() override; diff --git a/tools/viewer/sk_app/unix/main_unix.cpp b/tools/viewer/sk_app/unix/main_unix.cpp index a5e7004423..beb3eda10e 100644 --- a/tools/viewer/sk_app/unix/main_unix.cpp +++ b/tools/viewer/sk_app/unix/main_unix.cpp @@ -1,4 +1,5 @@ /* + * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be @@ -53,7 +54,9 @@ int main(int argc, char**argv) { XNextEvent(display, &event); sk_app::Window_unix* win = sk_app::Window_unix::gWindowMap.find(event.xany.window); - SkASSERT(win); + if (!win) { + continue; + } // paint and resize events get collapsed switch (event.type) { |