aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-05-02 16:15:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-02 20:27:26 +0000
commitfbdc080d3cae3695544ffbc05c6ff6f5b4514c02 (patch)
treed4085ac19224469f9a4c2bbefeeba360a8997e96 /tools
parent93f20f5629e52eed732d2b9d6dbbb351cc30b2cd (diff)
Add wireframe mode to Viewer.
Change-Id: I0ff11088465a4702acf9841a791d76f286ddbaf1 Reviewed-on: https://skia-review.googlesource.com/15147 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/viewer/Viewer.cpp6
-rw-r--r--tools/viewer/sk_app/GLWindowContext.cpp3
-rw-r--r--tools/viewer/sk_app/RasterWindowContext.h2
-rw-r--r--tools/viewer/sk_app/VulkanWindowContext.cpp15
-rw-r--r--tools/viewer/sk_app/VulkanWindowContext.h9
-rw-r--r--tools/viewer/sk_app/WindowContext.h10
-rw-r--r--tools/viewer/sk_app/android/GLWindowContext_android.cpp7
-rw-r--r--tools/viewer/sk_app/android/RasterWindowContext_android.cpp6
-rw-r--r--tools/viewer/sk_app/unix/GLWindowContext_unix.cpp4
-rw-r--r--tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp6
-rw-r--r--tools/viewer/sk_app/win/GLWindowContext_win.cpp4
-rw-r--r--tools/viewer/sk_app/win/RasterWindowContext_win.cpp7
12 files changed, 57 insertions, 22 deletions
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index e53bd1ab64..5854451a41 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -690,6 +690,7 @@ void Viewer::setBackend(sk_app::Window::BackendType backendType) {
// Switching from OpenGL to Vulkan in the same window is problematic at this point on
// Windows, so we just delete the window and recreate it.
if (sk_app::Window::kVulkan_BackendType == fBackendType) {
+ DisplayParams params = fWindow->getRequestedDisplayParams();
delete fWindow;
fWindow = Window::CreateNativeWindow(nullptr);
@@ -703,6 +704,7 @@ 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);
}
#endif
@@ -1022,6 +1024,10 @@ void Viewer::drawImGui(SkCanvas* canvas) {
if (ctx && ImGui::Checkbox("Instanced Rendering", inst)) {
paramsChanged = true;
}
+ bool* wire = &params.fGrContextOptions.fWireframeMode;
+ if (ctx && ImGui::Checkbox("Wireframe Mode", wire)) {
+ paramsChanged = true;
+ }
if (ctx) {
int sampleCount = fWindow->sampleCount();
diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp
index 6195199ce0..faa78ab09c 100644
--- a/tools/viewer/sk_app/GLWindowContext.cpp
+++ b/tools/viewer/sk_app/GLWindowContext.cpp
@@ -22,10 +22,9 @@
namespace sk_app {
GLWindowContext::GLWindowContext(const DisplayParams& params)
- : WindowContext()
+ : WindowContext(params)
, fBackendContext(nullptr)
, fSurface(nullptr) {
- fDisplayParams = params;
fDisplayParams.fMSAASampleCount = fDisplayParams.fMSAASampleCount ?
GrNextPow2(fDisplayParams.fMSAASampleCount) :
0;
diff --git a/tools/viewer/sk_app/RasterWindowContext.h b/tools/viewer/sk_app/RasterWindowContext.h
index 0393e9a0ba..75bde03ad7 100644
--- a/tools/viewer/sk_app/RasterWindowContext.h
+++ b/tools/viewer/sk_app/RasterWindowContext.h
@@ -14,6 +14,8 @@ namespace sk_app {
class RasterWindowContext : public WindowContext {
public:
+ RasterWindowContext(const DisplayParams& params) : WindowContext(params) {}
+
// Explicitly convert nullptr to GrBackendContext is needed for compiling
GrBackendContext getBackendContext() override { return (GrBackendContext) nullptr; }
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp
index 809c6142ac..e53cc7c1c2 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -31,7 +31,9 @@ namespace sk_app {
VulkanWindowContext::VulkanWindowContext(const DisplayParams& params,
CreateVkSurfaceFn createVkSurface,
CanPresentFn canPresent)
- : WindowContext()
+ : WindowContext(params)
+ , fCreateVkSurfaceFn(createVkSurface)
+ , fCanPresentFn(canPresent)
, fSurface(VK_NULL_HANDLE)
, fSwapchain(VK_NULL_HANDLE)
, fImages(nullptr)
@@ -39,10 +41,13 @@ VulkanWindowContext::VulkanWindowContext(const DisplayParams& params,
, fSurfaces(nullptr)
, fCommandPool(VK_NULL_HANDLE)
, fBackbuffers(nullptr) {
+ this->initializeContext();
+}
+void VulkanWindowContext::initializeContext() {
// any config code here (particularly for msaa)?
fBackendContext.reset(GrVkBackendContext::Create(vkGetInstanceProcAddr, vkGetDeviceProcAddr,
- &fPresentQueueIndex, canPresent));
+ &fPresentQueueIndex, fCanPresentFn));
if (!(fBackendContext->fExtensions & kKHR_surface_GrVkExtensionFlag) ||
!(fBackendContext->fExtensions & kKHR_swapchain_GrVkExtensionFlag)) {
@@ -64,9 +69,9 @@ VulkanWindowContext::VulkanWindowContext(const DisplayParams& params,
GET_DEV_PROC(QueuePresentKHR);
fContext = GrContext::Create(kVulkan_GrBackend, (GrBackendContext) fBackendContext.get(),
- params.fGrContextOptions);
+ fDisplayParams.fGrContextOptions);
- fSurface = createVkSurface(instance);
+ fSurface = fCreateVkSurfaceFn(instance);
if (VK_NULL_HANDLE == fSurface) {
fBackendContext.reset(nullptr);
return;
@@ -81,7 +86,7 @@ VulkanWindowContext::VulkanWindowContext(const DisplayParams& params,
return;
}
- if (!this->createSwapchain(-1, -1, params)) {
+ if (!this->createSwapchain(-1, -1, fDisplayParams)) {
this->destroyContext();
return;
}
diff --git a/tools/viewer/sk_app/VulkanWindowContext.h b/tools/viewer/sk_app/VulkanWindowContext.h
index cafaeada1b..81e5f3d2d5 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.h
+++ b/tools/viewer/sk_app/VulkanWindowContext.h
@@ -33,7 +33,9 @@ public:
}
void setDisplayParams(const DisplayParams& params) override {
- this->createSwapchain(fWidth, fHeight, params);
+ this->destroyContext();
+ fDisplayParams = params;
+ this->initializeContext();
}
GrBackendContext getBackendContext() override {
@@ -48,6 +50,7 @@ public:
VulkanWindowContext(const DisplayParams&, CreateVkSurfaceFn, CanPresentFn);
private:
+ void initializeContext();
void destroyContext();
struct BackbufferInfo {
@@ -75,6 +78,10 @@ private:
FNPTR_TYPE fPtr;
};
+ // Create functions
+ CreateVkSurfaceFn fCreateVkSurfaceFn;
+ CanPresentFn fCanPresentFn;
+
// WSI interface functions
VkPtr<PFN_vkDestroySurfaceKHR> fDestroySurfaceKHR;
VkPtr<PFN_vkGetPhysicalDeviceSurfaceSupportKHR> fGetPhysicalDeviceSurfaceSupportKHR;
diff --git a/tools/viewer/sk_app/WindowContext.h b/tools/viewer/sk_app/WindowContext.h
index 75b52b9c99..fbd2756b67 100644
--- a/tools/viewer/sk_app/WindowContext.h
+++ b/tools/viewer/sk_app/WindowContext.h
@@ -20,10 +20,12 @@ namespace sk_app {
class WindowContext {
public:
- WindowContext() : fContext(nullptr)
- , fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
- , fSampleCount(0)
- , fStencilBits(0) {}
+ WindowContext(const DisplayParams& params)
+ : fContext(nullptr)
+ , fDisplayParams(params)
+ , fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
+ , fSampleCount(0)
+ , fStencilBits(0) {}
virtual ~WindowContext() {}
diff --git a/tools/viewer/sk_app/android/GLWindowContext_android.cpp b/tools/viewer/sk_app/android/GLWindowContext_android.cpp
index 1529b3a4d1..b7a1fa8a90 100644
--- a/tools/viewer/sk_app/android/GLWindowContext_android.cpp
+++ b/tools/viewer/sk_app/android/GLWindowContext_android.cpp
@@ -36,10 +36,13 @@ private:
// For setDisplayParams and resize which call onInitializeContext with null platformData
ANativeWindow* fNativeWindow = nullptr;
+
+ typedef GLWindowContext INHERITED;
};
-GLWindowContext_android::GLWindowContext_android(ANativeWindow* window, const DisplayParams& params)
- : GLWindowContext(params)
+GLWindowContext_android::GLWindowContext_android(ANativeWindow* window,
+ const DisplayParams& params)
+ : INHERITED(params)
, fDisplay(EGL_NO_DISPLAY)
, fEGLContext(EGL_NO_CONTEXT)
, fSurface(EGL_NO_SURFACE)
diff --git a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp b/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
index 7077e2cfee..101e51ef42 100644
--- a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
+++ b/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
@@ -32,11 +32,13 @@ private:
ANativeWindow* fNativeWindow = nullptr;
ANativeWindow_Buffer fBuffer;
ARect fBounds;
+
+ typedef RasterWindowContext INHERITED;
};
RasterWindowContext_android::RasterWindowContext_android(ANativeWindow* window,
- const DisplayParams& params) {
- fDisplayParams = params;
+ const DisplayParams& params)
+ : INHERITED(params) {
fNativeWindow = window;
fWidth = ANativeWindow_getWidth(fNativeWindow);
fHeight = ANativeWindow_getHeight(fNativeWindow);
diff --git a/tools/viewer/sk_app/unix/GLWindowContext_unix.cpp b/tools/viewer/sk_app/unix/GLWindowContext_unix.cpp
index 530a5b67dd..ce2727e111 100644
--- a/tools/viewer/sk_app/unix/GLWindowContext_unix.cpp
+++ b/tools/viewer/sk_app/unix/GLWindowContext_unix.cpp
@@ -37,10 +37,12 @@ private:
GLXFBConfig* fFBConfig;
XVisualInfo* fVisualInfo;
GLXContext fGLContext;
+
+ typedef GLWindowContext INHERITED;
};
GLWindowContext_xlib::GLWindowContext_xlib(const XlibWindowInfo& winInfo, const DisplayParams& params)
- : GLWindowContext(params)
+ : INHERITED(params)
, fDisplay(winInfo.fDisplay)
, fWindow(winInfo.fWindow)
, fFBConfig(winInfo.fFBConfig)
diff --git a/tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp b/tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp
index 73846a11ab..6bfa6fd0be 100644
--- a/tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp
+++ b/tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp
@@ -29,13 +29,15 @@ protected:
Display* fDisplay;
XWindow fWindow;
GC fGC;
+
+ typedef RasterWindowContext INHERITED;
};
RasterWindowContext_xlib::RasterWindowContext_xlib(Display* display, XWindow window, int width,
int height, const DisplayParams& params)
- : fDisplay(display)
+ : INHERITED(params)
+ , fDisplay(display)
, fWindow(window) {
- fDisplayParams = params;
fGC = XCreateGC(fDisplay, fWindow, 0, nullptr);
this->resize(width, height);
fWidth = width;
diff --git a/tools/viewer/sk_app/win/GLWindowContext_win.cpp b/tools/viewer/sk_app/win/GLWindowContext_win.cpp
index 24db9659f0..20c3d9140a 100644
--- a/tools/viewer/sk_app/win/GLWindowContext_win.cpp
+++ b/tools/viewer/sk_app/win/GLWindowContext_win.cpp
@@ -33,10 +33,12 @@ protected:
private:
HWND fHWND;
HGLRC fHGLRC;
+
+ typedef GLWindowContext INHERITED;
};
GLWindowContext_win::GLWindowContext_win(HWND wnd, const DisplayParams& params)
- : GLWindowContext(params)
+ : INHERITED(params)
, fHWND(wnd)
, fHGLRC(NULL) {
diff --git a/tools/viewer/sk_app/win/RasterWindowContext_win.cpp b/tools/viewer/sk_app/win/RasterWindowContext_win.cpp
index 96fe8f22a9..85bb65e674 100644
--- a/tools/viewer/sk_app/win/RasterWindowContext_win.cpp
+++ b/tools/viewer/sk_app/win/RasterWindowContext_win.cpp
@@ -31,11 +31,14 @@ protected:
SkAutoMalloc fSurfaceMemory;
sk_sp<SkSurface> fBackbufferSurface;
HWND fWnd;
+
+private:
+ typedef RasterWindowContext INHERITED;
};
RasterWindowContext_win::RasterWindowContext_win(HWND wnd, const DisplayParams& params)
- : fWnd(wnd) {
- fDisplayParams = params;
+ : INHERITED(params)
+ , fWnd(wnd) {
RECT rect;
GetWindowRect(wnd, &rect);
this->resize(rect.right - rect.left, rect.bottom - rect.top);