Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 987a80c0 authored by Stan Iliev's avatar Stan Iliev
Browse files

Set color space on Vulkan render target surface

Test: Pass UiRendering tests with Vulkan pipeline
Bug: 116117654
Bug: 111436479
Change-Id: Id58a8a93c6f311402273b1a9e3606c9732f55aec
parent 17646e22
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -122,8 +122,9 @@ bool SkiaVulkanPipeline::setSurface(ANativeWindow* surface, SwapBehavior swapBeh
        mVkSurface = nullptr;
    }

    mSurfaceColorSpace = SkColorSpace::MakeSRGB();
    if (surface) {
        mVkSurface = mVkManager.createSurface(surface, colorMode);
        mVkSurface = mVkManager.createSurface(surface, colorMode, mSurfaceColorSpace);
    }

    if (colorMode == ColorMode::SRGB) {
+6 −4
Original line number Diff line number Diff line
@@ -472,8 +472,9 @@ SkSurface* VulkanManager::getBackbufferSurface(VulkanSurface** surfaceOut) {
    window->query(window, NATIVE_WINDOW_HEIGHT, &windowHeight);
    if (windowWidth != surface->mWindowWidth || windowHeight != surface->mWindowHeight) {
        ColorMode colorMode = surface->mColorMode;
        sk_sp<SkColorSpace> colorSpace = surface->mColorSpace;
        destroySurface(surface);
        *surfaceOut = createSurface(window, colorMode);
        *surfaceOut = createSurface(window, colorMode, colorSpace);
        surface = *surfaceOut;
    }

@@ -647,7 +648,7 @@ void VulkanManager::createBuffers(VulkanSurface* surface, VkFormat format, VkExt
        imageInfo.mSurface = SkSurface::MakeFromBackendRenderTarget(
                mRenderThread.getGrContext(), backendRT, kTopLeft_GrSurfaceOrigin,
                surface->mColorMode == ColorMode::WideColorGamut ? kRGBA_F16_SkColorType
                : kRGBA_8888_SkColorType, nullptr, &props);
                : kRGBA_8888_SkColorType, surface->mColorSpace, &props);
    }

    SkASSERT(mCommandPool != VK_NULL_HANDLE);
@@ -833,14 +834,15 @@ bool VulkanManager::createSwapchain(VulkanSurface* surface) {
    return true;
}

VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode colorMode) {
VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode colorMode,
        sk_sp<SkColorSpace> surfaceColorSpace) {
    initialize();

    if (!window) {
        return nullptr;
    }

    VulkanSurface* surface = new VulkanSurface(colorMode, window);
    VulkanSurface* surface = new VulkanSurface(colorMode, window, surfaceColorSpace);

    VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo;
    memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR));
+5 −3
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ class RenderThread;

class VulkanSurface {
public:
    VulkanSurface(ColorMode colorMode, ANativeWindow* window)
            : mColorMode(colorMode), mNativeWindow(window) {}
    VulkanSurface(ColorMode colorMode, ANativeWindow* window, sk_sp<SkColorSpace> colorSpace)
            : mColorMode(colorMode), mNativeWindow(window), mColorSpace(colorSpace) {}

    sk_sp<SkSurface> getBackBufferSurface() { return mBackbuffer; }

@@ -79,6 +79,7 @@ private:
    ANativeWindow* mNativeWindow;
    int mWindowWidth = 0;
    int mWindowHeight = 0;
    sk_sp<SkColorSpace> mColorSpace;
};

// This class contains the shared global Vulkan objects, such as VkInstance, VkDevice and VkQueue,
@@ -96,7 +97,8 @@ 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, ColorMode colorMode);
    VulkanSurface* createSurface(ANativeWindow* window, ColorMode colorMode,
            sk_sp<SkColorSpace> surfaceColorSpace);

    // Destroy the VulkanSurface and all associated vulkan objects.
    void destroySurface(VulkanSurface* surface);