diff options
author | 2016-05-05 12:32:03 -0700 | |
---|---|---|
committer | 2016-05-05 12:32:03 -0700 | |
commit | a8d0d6c8bad00e713bc33e5f0d47ca4fec104433 (patch) | |
tree | 8f78250c57c9c9d96f8e2fac7864630c97fe3cb9 /tools | |
parent | 2d1ee7936e3536e45c963db004e3b512bb415fd8 (diff) |
More refactoring for Viewer
* Move support files into sk_app and main files up to top directory
* Rename VulkanTestContext and create WindowContext parent class
* Place VulkanWindowContext et al. in sk_app namespace.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1944413005
Review-Url: https://codereview.chromium.org/1944413005
Diffstat (limited to 'tools')
-rw-r--r-- | tools/viewer/GMSlide.cpp (renamed from tools/viewer/viewer/GMSlide.cpp) | 0 | ||||
-rw-r--r-- | tools/viewer/GMSlide.h (renamed from tools/viewer/viewer/GMSlide.h) | 0 | ||||
-rw-r--r-- | tools/viewer/SKPSlide.cpp (renamed from tools/viewer/viewer/SKPSlide.cpp) | 0 | ||||
-rw-r--r-- | tools/viewer/SKPSlide.h (renamed from tools/viewer/viewer/SKPSlide.h) | 0 | ||||
-rw-r--r-- | tools/viewer/Slide.h (renamed from tools/viewer/viewer/Slide.h) | 0 | ||||
-rw-r--r-- | tools/viewer/Viewer.cpp (renamed from tools/viewer/viewer/Viewer.cpp) | 0 | ||||
-rw-r--r-- | tools/viewer/Viewer.h (renamed from tools/viewer/viewer/Viewer.h) | 4 | ||||
-rw-r--r-- | tools/viewer/sk_app/Application.h (renamed from tools/viewer/Application.h) | 0 | ||||
-rw-r--r-- | tools/viewer/sk_app/VulkanWindowContext.cpp (renamed from tools/viewer/VulkanTestContext.cpp) | 77 | ||||
-rw-r--r-- | tools/viewer/sk_app/VulkanWindowContext.h (renamed from tools/viewer/VulkanTestContext.h) | 40 | ||||
-rw-r--r-- | tools/viewer/sk_app/Window.cpp (renamed from tools/viewer/Window.cpp) | 12 | ||||
-rw-r--r-- | tools/viewer/sk_app/Window.h (renamed from tools/viewer/Window.h) | 5 | ||||
-rw-r--r-- | tools/viewer/sk_app/WindowContext.h | 36 | ||||
-rw-r--r-- | tools/viewer/sk_app/android/VulkanWindowContext_android.cpp (renamed from tools/viewer/android/VulkanTestContext_android.cpp) | 10 | ||||
-rw-r--r-- | tools/viewer/sk_app/android/VulkanWindowContext_android.h (renamed from tools/viewer/android/VulkanTestContext_android.h) | 5 | ||||
-rw-r--r-- | tools/viewer/sk_app/android/Window_android.cpp (renamed from tools/viewer/android/Window_android.cpp) | 4 | ||||
-rw-r--r-- | tools/viewer/sk_app/android/Window_android.h (renamed from tools/viewer/android/Window_android.h) | 0 | ||||
-rw-r--r-- | tools/viewer/sk_app/android/main_android.cpp (renamed from tools/viewer/android/main_android.cpp) | 0 | ||||
-rw-r--r-- | tools/viewer/sk_app/win/VulkanWindowContext_win.cpp (renamed from tools/viewer/win/VulkanTestContext_win.cpp) | 26 | ||||
-rw-r--r-- | tools/viewer/sk_app/win/VulkanWindowContext_win.h (renamed from tools/viewer/win/VulkanTestContext_win.h) | 6 | ||||
-rw-r--r-- | tools/viewer/sk_app/win/Window_win.cpp (renamed from tools/viewer/win/Window_win.cpp) | 6 | ||||
-rw-r--r-- | tools/viewer/sk_app/win/Window_win.h (renamed from tools/viewer/win/Window_win.h) | 0 | ||||
-rw-r--r-- | tools/viewer/sk_app/win/main_win.cpp (renamed from tools/viewer/win/main_win.cpp) | 0 |
23 files changed, 146 insertions, 85 deletions
diff --git a/tools/viewer/viewer/GMSlide.cpp b/tools/viewer/GMSlide.cpp index 6096044a38..6096044a38 100644 --- a/tools/viewer/viewer/GMSlide.cpp +++ b/tools/viewer/GMSlide.cpp diff --git a/tools/viewer/viewer/GMSlide.h b/tools/viewer/GMSlide.h index 6b03527202..6b03527202 100644 --- a/tools/viewer/viewer/GMSlide.h +++ b/tools/viewer/GMSlide.h diff --git a/tools/viewer/viewer/SKPSlide.cpp b/tools/viewer/SKPSlide.cpp index 6a9899b92f..6a9899b92f 100644 --- a/tools/viewer/viewer/SKPSlide.cpp +++ b/tools/viewer/SKPSlide.cpp diff --git a/tools/viewer/viewer/SKPSlide.h b/tools/viewer/SKPSlide.h index 42845fa30d..42845fa30d 100644 --- a/tools/viewer/viewer/SKPSlide.h +++ b/tools/viewer/SKPSlide.h diff --git a/tools/viewer/viewer/Slide.h b/tools/viewer/Slide.h index cdc225b0a8..cdc225b0a8 100644 --- a/tools/viewer/viewer/Slide.h +++ b/tools/viewer/Slide.h diff --git a/tools/viewer/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index ededc1f1c1..ededc1f1c1 100644 --- a/tools/viewer/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp diff --git a/tools/viewer/viewer/Viewer.h b/tools/viewer/Viewer.h index 43d29baa96..2ae7ae39f9 100644 --- a/tools/viewer/viewer/Viewer.h +++ b/tools/viewer/Viewer.h @@ -8,8 +8,8 @@ #ifndef Viewer_DEFINED #define Viewer_DEFINED -#include "../Application.h" -#include "../Window.h" +#include "sk_app/Application.h" +#include "sk_app/Window.h" #include "gm.h" #include "SkAnimTimer.h" #include "Slide.h" diff --git a/tools/viewer/Application.h b/tools/viewer/sk_app/Application.h index 235ff09ed4..235ff09ed4 100644 --- a/tools/viewer/Application.h +++ b/tools/viewer/sk_app/Application.h diff --git a/tools/viewer/VulkanTestContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp index e9137c0ee3..8f5f4209a4 100644 --- a/tools/viewer/VulkanTestContext.cpp +++ b/tools/viewer/sk_app/VulkanWindowContext.cpp @@ -8,7 +8,7 @@ #include "GrContext.h" #include "SkSurface.h" -#include "VulkanTestContext.h" +#include "VulkanWindowContext.h" #include "vk/GrVkInterface.h" #include "vk/GrVkUtil.h" @@ -22,18 +22,20 @@ #define GET_PROC(F) f ## F = (PFN_vk ## F) vkGetInstanceProcAddr(instance, "vk" #F) #define GET_DEV_PROC(F) f ## F = (PFN_vk ## F) vkGetDeviceProcAddr(device, "vk" #F) -VulkanTestContext::VulkanTestContext(void* platformData, int msaaSampleCount) - : fSurface(VK_NULL_HANDLE) - , fSwapchain(VK_NULL_HANDLE) - , fCommandPool(VK_NULL_HANDLE) - , fBackbuffers(nullptr) { +namespace sk_app { + +VulkanWindowContext::VulkanWindowContext(void* platformData, int msaaSampleCount) + : fSurface(VK_NULL_HANDLE) + , fSwapchain(VK_NULL_HANDLE) + , fCommandPool(VK_NULL_HANDLE) + , fBackbuffers(nullptr) { // any config code here (particularly for msaa)? this->initializeContext(platformData); } -void VulkanTestContext::initializeContext(void* platformData) { +void VulkanWindowContext::initializeContext(void* platformData) { fBackendContext.reset(GrVkBackendContext::Create(&fPresentQueueIndex, canPresent)); if (!(fBackendContext->fExtensions & kKHR_surface_GrVkExtensionFlag) || @@ -55,7 +57,7 @@ void VulkanTestContext::initializeContext(void* platformData) { GET_DEV_PROC(AcquireNextImageKHR); GET_DEV_PROC(QueuePresentKHR); - fContext = GrContext::Create(kVulkan_GrBackend, (GrBackendContext)fBackendContext.get()); + fContext = GrContext::Create(kVulkan_GrBackend, (GrBackendContext) fBackendContext.get()); fSurface = createVkSurface(instance, platformData); if (VK_NULL_HANDLE == fSurface) { @@ -81,8 +83,7 @@ void VulkanTestContext::initializeContext(void* platformData) { vkGetDeviceQueue(fBackendContext->fDevice, fPresentQueueIndex, 0, &fPresentQueue); } -bool VulkanTestContext::createSwapchain(uint32_t width, uint32_t height) -{ +bool VulkanWindowContext::createSwapchain(uint32_t width, uint32_t height) { // check for capabilities VkSurfaceCapabilitiesKHR caps; VkResult res = fGetPhysicalDeviceSurfaceCapabilitiesKHR(fBackendContext->fPhysicalDevice, @@ -116,7 +117,7 @@ bool VulkanTestContext::createSwapchain(uint32_t width, uint32_t height) SkAutoMalloc presentModeAlloc(presentModeCount * sizeof(VkPresentModeKHR)); VkPresentModeKHR* presentModes = (VkPresentModeKHR*)presentModeAlloc.get(); res = fGetPhysicalDeviceSurfacePresentModesKHR(fBackendContext->fPhysicalDevice, fSurface, - &presentModeCount, presentModes); + &presentModeCount, presentModes); if (VK_SUCCESS != res) { return false; } @@ -223,7 +224,7 @@ bool VulkanTestContext::createSwapchain(uint32_t width, uint32_t height) return true; } -void VulkanTestContext::createBuffers(VkFormat format) { +void VulkanWindowContext::createBuffers(VkFormat format) { GrVkFormatToPixelConfig(format, &fPixelConfig); fGetSwapchainImagesKHR(fBackendContext->fDevice, fSwapchain, &fImageCount, nullptr); @@ -311,14 +312,14 @@ void VulkanTestContext::createBuffers(VkFormat format) { fCurrentBackbufferIndex = fImageCount; } -void VulkanTestContext::destroyBuffers() { +void VulkanWindowContext::destroyBuffers() { if (fBackbuffers) { for (uint32_t i = 0; i < fImageCount + 1; ++i) { GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, - WaitForFences(fBackendContext->fDevice, 2, + WaitForFences(fBackendContext->fDevice, 2, fBackbuffers[i].fUsageFences, - true, UINT64_MAX)); + true, UINT64_MAX)); fBackbuffers[i].fImageIndex = -1; GR_VK_CALL(fBackendContext->fInterface, DestroySemaphore(fBackendContext->fDevice, @@ -349,11 +350,11 @@ void VulkanTestContext::destroyBuffers() { fImages = nullptr; } -VulkanTestContext::~VulkanTestContext() { +VulkanWindowContext::~VulkanWindowContext() { this->destroyContext(); } -void VulkanTestContext::destroyContext() { +void VulkanWindowContext::destroyContext() { if (!fBackendContext.get()) { return; } @@ -383,7 +384,7 @@ void VulkanTestContext::destroyContext() { fBackendContext.reset(nullptr); } -VulkanTestContext::BackbufferInfo* VulkanTestContext::getAvailableBackbuffer() { +VulkanWindowContext::BackbufferInfo* VulkanWindowContext::getAvailableBackbuffer() { SkASSERT(fBackbuffers); ++fCurrentBackbufferIndex; @@ -399,7 +400,7 @@ VulkanTestContext::BackbufferInfo* VulkanTestContext::getAvailableBackbuffer() { return backbuffer; } -SkSurface* VulkanTestContext::getBackbufferSurface() { +SkSurface* VulkanWindowContext::getBackbufferSurface() { BackbufferInfo* backbuffer = this->getAvailableBackbuffer(); SkASSERT(backbuffer); @@ -424,7 +425,7 @@ SkSurface* VulkanTestContext::getBackbufferSurface() { } // acquire the image - res = fAcquireNextImageKHR(fBackendContext->fDevice, fSwapchain, UINT64_MAX, + res = fAcquireNextImageKHR(fBackendContext->fDevice, fSwapchain, UINT64_MAX, backbuffer->fAcquireSemaphore, VK_NULL_HANDLE, &backbuffer->fImageIndex); @@ -439,7 +440,7 @@ SkSurface* VulkanTestContext::getBackbufferSurface() { VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT : VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - VkAccessFlags srcAccessMask = (VK_IMAGE_LAYOUT_UNDEFINED == layout) ? + VkAccessFlags srcAccessMask = (VK_IMAGE_LAYOUT_UNDEFINED == layout) ? 0 : VK_ACCESS_MEMORY_READ_BIT; VkAccessFlags dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; @@ -464,15 +465,15 @@ SkSurface* VulkanTestContext::getBackbufferSurface() { GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, BeginCommandBuffer(backbuffer->fTransitionCmdBuffers[0], &info)); - GR_VK_CALL(fBackendContext->fInterface, - CmdPipelineBarrier(backbuffer->fTransitionCmdBuffers[0], - srcStageMask, dstStageMask, 0, - 0, nullptr, - 0, nullptr, - 1, &imageMemoryBarrier)); + GR_VK_CALL(fBackendContext->fInterface, + CmdPipelineBarrier(backbuffer->fTransitionCmdBuffers[0], + srcStageMask, dstStageMask, 0, + 0, nullptr, + 0, nullptr, + 1, &imageMemoryBarrier)); GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, - EndCommandBuffer(backbuffer->fTransitionCmdBuffers[0])); + EndCommandBuffer(backbuffer->fTransitionCmdBuffers[0])); VkPipelineStageFlags waitDstStageFlags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; // insert the layout transfer into the queue and wait on the acquire @@ -485,16 +486,16 @@ SkSurface* VulkanTestContext::getBackbufferSurface() { submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &backbuffer->fTransitionCmdBuffers[0]; submitInfo.signalSemaphoreCount = 0; - + GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, - QueueSubmit(fBackendContext->fQueue, 1, &submitInfo, + QueueSubmit(fBackendContext->fQueue, 1, &submitInfo, backbuffer->fUsageFences[0])); return fSurfaces[backbuffer->fImageIndex].get(); } -void VulkanTestContext::swapBuffers() { +void VulkanWindowContext::swapBuffers() { BackbufferInfo* backbuffer = fBackbuffers + fCurrentBackbufferIndex; @@ -525,11 +526,11 @@ void VulkanTestContext::swapBuffers() { GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, BeginCommandBuffer(backbuffer->fTransitionCmdBuffers[1], &info)); GR_VK_CALL(fBackendContext->fInterface, - CmdPipelineBarrier(backbuffer->fTransitionCmdBuffers[1], - srcStageMask, dstStageMask, 0, - 0, nullptr, - 0, nullptr, - 1, &imageMemoryBarrier)); + CmdPipelineBarrier(backbuffer->fTransitionCmdBuffers[1], + srcStageMask, dstStageMask, 0, + 0, nullptr, + 0, nullptr, + 1, &imageMemoryBarrier)); GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, EndCommandBuffer(backbuffer->fTransitionCmdBuffers[1])); @@ -547,7 +548,7 @@ void VulkanTestContext::swapBuffers() { submitInfo.pSignalSemaphores = &backbuffer->fRenderSemaphore; GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, - QueueSubmit(fBackendContext->fQueue, 1, &submitInfo, + QueueSubmit(fBackendContext->fQueue, 1, &submitInfo, backbuffer->fUsageFences[1])); // Submit present operation to present queue @@ -566,3 +567,5 @@ void VulkanTestContext::swapBuffers() { fQueuePresentKHR(fPresentQueue, &presentInfo); } + +} //namespace sk_app diff --git a/tools/viewer/VulkanTestContext.h b/tools/viewer/sk_app/VulkanWindowContext.h index 60b3b80cf4..48f8ed536b 100644 --- a/tools/viewer/VulkanTestContext.h +++ b/tools/viewer/sk_app/VulkanWindowContext.h @@ -5,27 +5,29 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#ifndef VulkanTestContext_DEFINED -#define VulkanTestContext_DEFINED +#ifndef VulkanWindowContext_DEFINED +#define VulkanWindowContext_DEFINED #ifdef SK_VULKAN -#include "GrTypes.h" #include "vk/GrVkBackendContext.h" +#include "WindowContext.h" class SkSurface; class GrContext; -class VulkanTestContext { +namespace sk_app { + +class VulkanWindowContext : public WindowContext { public: - ~VulkanTestContext(); + ~VulkanWindowContext() override; // each platform will have to implement these in its CPP file static VkSurfaceKHR createVkSurface(VkInstance, void* platformData); static bool canPresent(VkInstance, VkPhysicalDevice, uint32_t queueFamilyIndex); - static VulkanTestContext* Create(void* platformData, int msaaSampleCount) { - VulkanTestContext* ctx = new VulkanTestContext(platformData, msaaSampleCount); + static VulkanWindowContext* Create(void* platformData, int msaaSampleCount) { + VulkanWindowContext* ctx = new VulkanWindowContext(platformData, msaaSampleCount); if (!ctx->isValid()) { delete ctx; return nullptr; @@ -33,22 +35,24 @@ public: return ctx; } - SkSurface* getBackbufferSurface(); - void swapBuffers(); + SkSurface* getBackbufferSurface() override; + void swapBuffers() override; - bool makeCurrent() { return true; } + bool makeCurrent() override { return true; } - bool isValid() { return SkToBool(fBackendContext.get()); } + bool isValid() override { return SkToBool(fBackendContext.get()); } - void resize(uint32_t w, uint32_t h) { - this->createSwapchain(w, h); + void resize(uint32_t w, uint32_t h) override { + this->createSwapchain(w, h); } - GrBackendContext getBackendContext() { return (GrBackendContext)fBackendContext.get(); } + GrBackendContext getBackendContext() override { + return (GrBackendContext) fBackendContext.get(); + } private: - VulkanTestContext(); - VulkanTestContext(void*, int msaaSampleCount); + VulkanWindowContext(); + VulkanWindowContext(void*, int msaaSampleCount); void initializeContext(void*); void destroyContext(); @@ -76,7 +80,7 @@ private: private: FNPTR_TYPE fPtr; }; - + // WSI interface functions VkPtr<PFN_vkDestroySurfaceKHR> fDestroySurfaceKHR; VkPtr<PFN_vkGetPhysicalDeviceSurfaceSupportKHR> fGetPhysicalDeviceSurfaceSupportKHR; @@ -109,6 +113,8 @@ private: uint32_t fCurrentBackbufferIndex; }; +} // namespace sk_app + #endif // SK_VULKAN #endif diff --git a/tools/viewer/Window.cpp b/tools/viewer/sk_app/Window.cpp index 6a83a3ba81..a7fd6b0cf6 100644 --- a/tools/viewer/Window.cpp +++ b/tools/viewer/sk_app/Window.cpp @@ -9,7 +9,7 @@ #include "SkSurface.h" #include "SkCanvas.h" -#include "VulkanTestContext.h" +#include "VulkanWindowContext.h" namespace sk_app { @@ -36,8 +36,8 @@ Window::Window() : fCharFunc(default_char_func) } void Window::detach() { - delete fTestContext; - fTestContext = nullptr; + delete fWindowContext; + fWindowContext = nullptr; } bool Window::onChar(SkUnichar c, uint32_t modifiers) { @@ -53,7 +53,7 @@ bool Window::onMouse(int x, int y, InputState state, uint32_t modifiers) { } void Window::onPaint() { - SkSurface* backbuffer = fTestContext->getBackbufferSurface(); + SkSurface* backbuffer = fWindowContext->getBackbufferSurface(); if (backbuffer) { // draw into the canvas of this surface SkCanvas* canvas = backbuffer->getCanvas(); @@ -62,7 +62,7 @@ void Window::onPaint() { canvas->flush(); - fTestContext->swapBuffers(); + fWindowContext->swapBuffers(); } else { // try recreating testcontext } @@ -72,7 +72,7 @@ void Window::onPaint() { void Window::onResize(uint32_t w, uint32_t h) { fWidth = w; fHeight = h; - fTestContext->resize(w, h); + fWindowContext->resize(w, h); } } // namespace sk_app diff --git a/tools/viewer/Window.h b/tools/viewer/sk_app/Window.h index 913d2da00a..3dd558e75a 100644 --- a/tools/viewer/Window.h +++ b/tools/viewer/sk_app/Window.h @@ -12,10 +12,11 @@ #include "SkRect.h" class SkCanvas; -class VulkanTestContext; namespace sk_app { +class WindowContext; + class Window { public: static Window* CreateNativeWindow(void* platformData); @@ -143,7 +144,7 @@ protected: OnPaintFunc fPaintFunc; void* fPaintUserData; - VulkanTestContext* fTestContext; + WindowContext* fWindowContext; }; } // namespace sk_app diff --git a/tools/viewer/sk_app/WindowContext.h b/tools/viewer/sk_app/WindowContext.h new file mode 100644 index 0000000000..5811bedd32 --- /dev/null +++ b/tools/viewer/sk_app/WindowContext.h @@ -0,0 +1,36 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef WindowContext_DEFINED +#define WindowContext_DEFINED + +#include "GrTypes.h" + +class SkSurface; + +namespace sk_app { + +// TODO: fill this out with an interface +class WindowContext { +public: + virtual ~WindowContext() {} + + virtual SkSurface* getBackbufferSurface() = 0; + + virtual void swapBuffers() = 0; + + virtual bool makeCurrent() = 0; + + virtual bool isValid() = 0; + + virtual void resize(uint32_t w, uint32_t h) = 0; + + virtual GrBackendContext getBackendContext() = 0; +}; + +} // namespace sk_app + +#endif diff --git a/tools/viewer/android/VulkanTestContext_android.cpp b/tools/viewer/sk_app/android/VulkanWindowContext_android.cpp index 58dbcb2843..1ef994aa3f 100644 --- a/tools/viewer/android/VulkanTestContext_android.cpp +++ b/tools/viewer/sk_app/android/VulkanWindowContext_android.cpp @@ -6,12 +6,14 @@ * found in the LICENSE file. */ -#include "VulkanTestContext_android.h" +#include "VulkanWindowContext_android.h" #include "vk/GrVkInterface.h" #include "vk/GrVkUtil.h" -VkSurfaceKHR VulkanTestContext::createVkSurface(VkInstance instance, void* platformData) { +namespace sk_app { + +VkSurfaceKHR VulkanWindowContext::createVkSurface(VkInstance instance, void* platformData) { static PFN_vkCreateAndroidSurfaceKHR createAndroidSurfaceKHR = nullptr; if (!createAndroidSurfaceKHR) { createAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr(instance, @@ -37,7 +39,9 @@ VkSurfaceKHR VulkanTestContext::createVkSurface(VkInstance instance, void* platf return (VK_SUCCESS == res) ? surface : VK_NULL_HANDLE; } -bool VulkanTestContext::canPresent(VkInstance instance, VkPhysicalDevice physDev, +bool VulkanWindowContext::canPresent(VkInstance instance, VkPhysicalDevice physDev, uint32_t queueFamilyIndex) { return true; } + +} // namespace sk_app diff --git a/tools/viewer/android/VulkanTestContext_android.h b/tools/viewer/sk_app/android/VulkanWindowContext_android.h index 66ed35c2f6..dd53e13b69 100644 --- a/tools/viewer/android/VulkanTestContext_android.h +++ b/tools/viewer/sk_app/android/VulkanWindowContext_android.h @@ -10,14 +10,17 @@ #ifdef SK_VULKAN -#include "../VulkanTestContext.h" +#include "../VulkanWindowContext.h" struct ANativeWindow; +namespace sk_app { + struct ContextPlatformData_android { ANativeWindow* fNativeWindow; }; +} #endif // SK_VULKAN #endif diff --git a/tools/viewer/android/Window_android.cpp b/tools/viewer/sk_app/android/Window_android.cpp index ebccb8beff..94be02c933 100644 --- a/tools/viewer/android/Window_android.cpp +++ b/tools/viewer/sk_app/android/Window_android.cpp @@ -7,7 +7,7 @@ #include "Window_android.h" -#include "VulkanTestContext_android.h" +#include "VulkanWindowContext_android.h" namespace sk_app { @@ -53,7 +53,7 @@ void Window_android::initDisplay(ANativeWindow* window) { SkASSERT(window); ContextPlatformData_android platformData; platformData.fNativeWindow = window; - fTestContext = VulkanTestContext::Create((void*)&platformData, mSampleCount); + fWindowContext = VulkanWindowContext::Create((void*)&platformData, mSampleCount); } static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { diff --git a/tools/viewer/android/Window_android.h b/tools/viewer/sk_app/android/Window_android.h index d41f0a54c2..d41f0a54c2 100644 --- a/tools/viewer/android/Window_android.h +++ b/tools/viewer/sk_app/android/Window_android.h diff --git a/tools/viewer/android/main_android.cpp b/tools/viewer/sk_app/android/main_android.cpp index 9334f0ccd3..9334f0ccd3 100644 --- a/tools/viewer/android/main_android.cpp +++ b/tools/viewer/sk_app/android/main_android.cpp diff --git a/tools/viewer/win/VulkanTestContext_win.cpp b/tools/viewer/sk_app/win/VulkanWindowContext_win.cpp index 37ef667429..05f3bddd31 100644 --- a/tools/viewer/win/VulkanTestContext_win.cpp +++ b/tools/viewer/sk_app/win/VulkanWindowContext_win.cpp @@ -6,24 +6,26 @@ * found in the LICENSE file. */ -#include "VulkanTestContext_win.h" +#include "VulkanWindowContext_win.h" #include "vk/GrVkInterface.h" #include "vk/GrVkUtil.h" +namespace sk_app { + // Platform dependant call -VkSurfaceKHR VulkanTestContext::createVkSurface(VkInstance instance, void* platformData) { +VkSurfaceKHR VulkanWindowContext::createVkSurface(VkInstance instance, void* platformData) { static PFN_vkCreateWin32SurfaceKHR createWin32SurfaceKHR = nullptr; if (!createWin32SurfaceKHR) { - createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)vkGetInstanceProcAddr(instance, - "vkCreateWin32SurfaceKHR"); + createWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) vkGetInstanceProcAddr(instance, + "vkCreateWin32SurfaceKHR"); } if (!platformData) { return VK_NULL_HANDLE; } - ContextPlatformData_win* winPlatformData = - reinterpret_cast<ContextPlatformData_win*>(platformData); + ContextPlatformData_win* winPlatformData = + reinterpret_cast<ContextPlatformData_win*>(platformData); VkSurfaceKHR surface; VkWin32SurfaceCreateInfoKHR surfaceCreateInfo; @@ -43,16 +45,18 @@ VkSurfaceKHR VulkanTestContext::createVkSurface(VkInstance instance, void* platf } // Platform dependant call -bool VulkanTestContext::canPresent(VkInstance instance, VkPhysicalDevice physDev, +bool VulkanWindowContext::canPresent(VkInstance instance, VkPhysicalDevice physDev, uint32_t queueFamilyIndex) { - static PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR - getPhysicalDeviceWin32PresentationSupportKHR = nullptr; + static PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR + getPhysicalDeviceWin32PresentationSupportKHR = nullptr; if (!getPhysicalDeviceWin32PresentationSupportKHR) { - getPhysicalDeviceWin32PresentationSupportKHR = + getPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) vkGetInstanceProcAddr(instance, - "vkGetPhysicalDeviceWin32PresentationSupportKHR"); + "vkGetPhysicalDeviceWin32PresentationSupportKHR"); } VkBool32 check = getPhysicalDeviceWin32PresentationSupportKHR(physDev, queueFamilyIndex); return (VK_FALSE != check); } + +} // namespace sk_app diff --git a/tools/viewer/win/VulkanTestContext_win.h b/tools/viewer/sk_app/win/VulkanWindowContext_win.h index 59b5c2cfd6..e0b5a156f9 100644 --- a/tools/viewer/win/VulkanTestContext_win.h +++ b/tools/viewer/sk_app/win/VulkanWindowContext_win.h @@ -11,7 +11,9 @@ #ifdef SK_VULKAN #include <windows.h> -#include "../VulkanTestContext.h" +#include "../VulkanWindowContext.h" + +namespace sk_app { // for Windows struct ContextPlatformData_win { @@ -19,6 +21,8 @@ struct ContextPlatformData_win { HWND fHWnd; }; +} + #endif // SK_VULKAN #endif diff --git a/tools/viewer/win/Window_win.cpp b/tools/viewer/sk_app/win/Window_win.cpp index d5711b7245..1dd07a6c9c 100644 --- a/tools/viewer/win/Window_win.cpp +++ b/tools/viewer/sk_app/win/Window_win.cpp @@ -12,7 +12,7 @@ #include <windowsx.h> #include "SkUtils.h" -#include "VulkanTestContext_win.h" +#include "VulkanWindowContext_win.h" namespace sk_app { @@ -273,9 +273,9 @@ bool Window_win::attach(BackEndType attachType, int msaaSampleCount) { platformData.fHInstance = fHInstance; platformData.fHWnd = fHWnd; - fTestContext = VulkanTestContext::Create((void*)&platformData, msaaSampleCount); + fWindowContext = VulkanWindowContext::Create((void*)&platformData, msaaSampleCount); - return (SkToBool(fTestContext)); + return (SkToBool(fWindowContext)); } void Window_win::inval() { diff --git a/tools/viewer/win/Window_win.h b/tools/viewer/sk_app/win/Window_win.h index e295212f31..e295212f31 100644 --- a/tools/viewer/win/Window_win.h +++ b/tools/viewer/sk_app/win/Window_win.h diff --git a/tools/viewer/win/main_win.cpp b/tools/viewer/sk_app/win/main_win.cpp index ba1629c837..ba1629c837 100644 --- a/tools/viewer/win/main_win.cpp +++ b/tools/viewer/sk_app/win/main_win.cpp |