Loading libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -123,8 +123,7 @@ bool SkiaVulkanPipeline::setSurface(Surface* surface, SwapBehavior swapBehavior, } if (surface) { // TODO: handle color mode mVkSurface = mVkManager.createSurface(surface); mVkSurface = mVkManager.createSurface(surface, colorMode); } return mVkSurface != nullptr; Loading libs/hwui/renderthread/VulkanManager.cpp +15 −16 Original line number Diff line number Diff line Loading @@ -618,7 +618,8 @@ void VulkanManager::createBuffers(VulkanSurface* surface, VkFormat format, VkExt VulkanSurface::ImageInfo& imageInfo = surface->mImageInfos[i]; imageInfo.mSurface = SkSurface::MakeFromBackendRenderTarget( mRenderThread.getGrContext(), backendRT, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, nullptr, &props); surface->mColorMode == ColorMode::WideColorGamut ? kRGBA_F16_SkColorType : kRGBA_8888_SkColorType, nullptr, &props); } SkASSERT(mCommandPool != VK_NULL_HANDLE); Loading Loading @@ -733,24 +734,22 @@ bool VulkanManager::createSwapchain(VulkanSurface* surface) { ? VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR : VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; // Pick our surface format. For now, just make sure it matches our sRGB request: VkFormat surfaceFormat = VK_FORMAT_UNDEFINED; VkFormat surfaceFormat = VK_FORMAT_R8G8B8A8_UNORM; VkColorSpaceKHR colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; bool wantSRGB = false; #ifdef ANDROID_ENABLE_LINEAR_BLENDING wantSRGB = true; #endif if (surface->mColorMode == ColorMode::WideColorGamut) { surfaceFormat = VK_FORMAT_R16G16B16A16_SFLOAT; colorSpace = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT; } bool foundSurfaceFormat = false; for (uint32_t i = 0; i < surfaceFormatCount; ++i) { // We are assuming we can get either R8G8B8A8_UNORM or R8G8B8A8_SRGB VkFormat desiredFormat = wantSRGB ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM; if (desiredFormat == surfaceFormats[i].format) { surfaceFormat = surfaceFormats[i].format; colorSpace = surfaceFormats[i].colorSpace; if (surfaceFormat == surfaceFormats[i].format && colorSpace == surfaceFormats[i].colorSpace) { foundSurfaceFormat = true; break; } } if (VK_FORMAT_UNDEFINED == surfaceFormat) { if (!foundSurfaceFormat) { return false; } Loading Loading @@ -812,14 +811,14 @@ bool VulkanManager::createSwapchain(VulkanSurface* surface) { return true; } VulkanSurface* VulkanManager::createSurface(ANativeWindow* window) { VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode colorMode) { initialize(); if (!window) { return nullptr; } VulkanSurface* surface = new VulkanSurface(); VulkanSurface* surface = new VulkanSurface(colorMode); VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo; memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR)); Loading libs/hwui/renderthread/VulkanManager.h +4 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <ui/Fence.h> #include <utils/StrongPointer.h> #include <vk/GrVkBackendContext.h> #include "IRenderPipeline.h" class GrVkExtensions; Loading @@ -37,7 +38,7 @@ class RenderThread; class VulkanSurface { public: VulkanSurface() {} VulkanSurface(ColorMode colorMode) : mColorMode(colorMode) {} sk_sp<SkSurface> getBackBufferSurface() { return mBackbuffer; } Loading Loading @@ -73,6 +74,7 @@ private: VkImage* mImages = nullptr; ImageInfo* mImageInfos; uint16_t mCurrentTime = 0; ColorMode mColorMode; }; // This class contains the shared global Vulkan objects, such as VkInstance, VkDevice and VkQueue, Loading @@ -90,7 +92,7 @@ public: // Given a window this creates a new VkSurfaceKHR and VkSwapchain and stores them inside a new // VulkanSurface object which is returned. VulkanSurface* createSurface(ANativeWindow* window); VulkanSurface* createSurface(ANativeWindow* window, ColorMode colorMode); // Destroy the VulkanSurface and all associated vulkan objects. void destroySurface(VulkanSurface* surface); Loading Loading
libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -123,8 +123,7 @@ bool SkiaVulkanPipeline::setSurface(Surface* surface, SwapBehavior swapBehavior, } if (surface) { // TODO: handle color mode mVkSurface = mVkManager.createSurface(surface); mVkSurface = mVkManager.createSurface(surface, colorMode); } return mVkSurface != nullptr; Loading
libs/hwui/renderthread/VulkanManager.cpp +15 −16 Original line number Diff line number Diff line Loading @@ -618,7 +618,8 @@ void VulkanManager::createBuffers(VulkanSurface* surface, VkFormat format, VkExt VulkanSurface::ImageInfo& imageInfo = surface->mImageInfos[i]; imageInfo.mSurface = SkSurface::MakeFromBackendRenderTarget( mRenderThread.getGrContext(), backendRT, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, nullptr, &props); surface->mColorMode == ColorMode::WideColorGamut ? kRGBA_F16_SkColorType : kRGBA_8888_SkColorType, nullptr, &props); } SkASSERT(mCommandPool != VK_NULL_HANDLE); Loading Loading @@ -733,24 +734,22 @@ bool VulkanManager::createSwapchain(VulkanSurface* surface) { ? VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR : VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; // Pick our surface format. For now, just make sure it matches our sRGB request: VkFormat surfaceFormat = VK_FORMAT_UNDEFINED; VkFormat surfaceFormat = VK_FORMAT_R8G8B8A8_UNORM; VkColorSpaceKHR colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; bool wantSRGB = false; #ifdef ANDROID_ENABLE_LINEAR_BLENDING wantSRGB = true; #endif if (surface->mColorMode == ColorMode::WideColorGamut) { surfaceFormat = VK_FORMAT_R16G16B16A16_SFLOAT; colorSpace = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT; } bool foundSurfaceFormat = false; for (uint32_t i = 0; i < surfaceFormatCount; ++i) { // We are assuming we can get either R8G8B8A8_UNORM or R8G8B8A8_SRGB VkFormat desiredFormat = wantSRGB ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM; if (desiredFormat == surfaceFormats[i].format) { surfaceFormat = surfaceFormats[i].format; colorSpace = surfaceFormats[i].colorSpace; if (surfaceFormat == surfaceFormats[i].format && colorSpace == surfaceFormats[i].colorSpace) { foundSurfaceFormat = true; break; } } if (VK_FORMAT_UNDEFINED == surfaceFormat) { if (!foundSurfaceFormat) { return false; } Loading Loading @@ -812,14 +811,14 @@ bool VulkanManager::createSwapchain(VulkanSurface* surface) { return true; } VulkanSurface* VulkanManager::createSurface(ANativeWindow* window) { VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode colorMode) { initialize(); if (!window) { return nullptr; } VulkanSurface* surface = new VulkanSurface(); VulkanSurface* surface = new VulkanSurface(colorMode); VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo; memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR)); Loading
libs/hwui/renderthread/VulkanManager.h +4 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include <ui/Fence.h> #include <utils/StrongPointer.h> #include <vk/GrVkBackendContext.h> #include "IRenderPipeline.h" class GrVkExtensions; Loading @@ -37,7 +38,7 @@ class RenderThread; class VulkanSurface { public: VulkanSurface() {} VulkanSurface(ColorMode colorMode) : mColorMode(colorMode) {} sk_sp<SkSurface> getBackBufferSurface() { return mBackbuffer; } Loading Loading @@ -73,6 +74,7 @@ private: VkImage* mImages = nullptr; ImageInfo* mImageInfos; uint16_t mCurrentTime = 0; ColorMode mColorMode; }; // This class contains the shared global Vulkan objects, such as VkInstance, VkDevice and VkQueue, Loading @@ -90,7 +92,7 @@ public: // Given a window this creates a new VkSurfaceKHR and VkSwapchain and stores them inside a new // VulkanSurface object which is returned. VulkanSurface* createSurface(ANativeWindow* window); VulkanSurface* createSurface(ANativeWindow* window, ColorMode colorMode); // Destroy the VulkanSurface and all associated vulkan objects. void destroySurface(VulkanSurface* surface); Loading