From 60befc2cdec54818ce738fd07236624dc1b287a2 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Wed, 21 Mar 2018 17:13:05 -0400 Subject: [PATCH] VulkanSurface and GPUSurfaceGL no longer use GrPixelConfig (#4814) * VulkanSurface and GPUSurfaceGL no longer use GrPixelConfig * fix 565 * fix gpu_surface_gl changes --- content_handler/vulkan_surface.cc | 8 ++++++-- content_handler/vulkan_surface.h | 1 + shell/gpu/gpu_surface_gl.cc | 28 ++++++++++++++++++---------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/content_handler/vulkan_surface.cc b/content_handler/vulkan_surface.cc index efb3f8934..7dbcc908e 100644 --- a/content_handler/vulkan_surface.cc +++ b/content_handler/vulkan_surface.cc @@ -152,6 +152,8 @@ bool VulkanSurface::AllocateDeviceMemory(sk_sp context, return false; } + const SkColorType color_type = kBGRA_8888_SkColorType; + // Create the image. const VkImageCreateInfo image_create_info = { .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, @@ -255,12 +257,13 @@ bool VulkanSurface::AllocateDeviceMemory(sk_sp context, return false; } - return SetupSkiaSurface(std::move(context), size, image_create_info, - memory_reqs); + return SetupSkiaSurface(std::move(context), size, color_type, + image_create_info, memory_reqs); } bool VulkanSurface::SetupSkiaSurface(sk_sp context, const SkISize& size, + SkColorType color_type, const VkImageCreateInfo& image_create_info, const VkMemoryRequirements& memory_reqs) { if (context == nullptr) { @@ -286,6 +289,7 @@ bool VulkanSurface::SetupSkiaSurface(sk_sp context, SkSurface::MakeFromBackendRenderTarget(context.get(), // sk_render_target, // kTopLeft_GrSurfaceOrigin, // + color_type, // nullptr, // &sk_surface_props // ); diff --git a/content_handler/vulkan_surface.h b/content_handler/vulkan_surface.h index 3a0d2801a..41a807af8 100644 --- a/content_handler/vulkan_surface.h +++ b/content_handler/vulkan_surface.h @@ -80,6 +80,7 @@ class VulkanSurface : public flow::SceneUpdateContext::SurfaceProducerSurface { bool SetupSkiaSurface(sk_sp context, const SkISize& size, + SkColorType color_type, const VkImageCreateInfo& image_create_info, const VkMemoryRequirements& memory_reqs); diff --git a/shell/gpu/gpu_surface_gl.cc b/shell/gpu/gpu_surface_gl.cc index 36551f1c0..b825ffc66 100644 --- a/shell/gpu/gpu_surface_gl.cc +++ b/shell/gpu/gpu_surface_gl.cc @@ -4,6 +4,9 @@ #include "gpu_surface_gl.h" +#include +#include + #include "flutter/glue/trace_event.h" #include "lib/fxl/arraysize.h" #include "lib/fxl/logging.h" @@ -71,31 +74,35 @@ bool GPUSurfaceGL::IsValid() { return valid_; } -static GrPixelConfig FirstSupportedConfig(GrContext* context) { -#define RETURN_IF_RENDERABLE(x) \ - if (context->caps()->isConfigRenderable((x), false)) { \ - return (x); \ +static SkColorType FirstSupportedColorType(GrContext* context, GLenum* format) { +#define RETURN_IF_RENDERABLE(x, y) \ + if (context->colorTypeSupportedAsSurface((x))) { \ + *format = (y); \ + return (x); \ } - RETURN_IF_RENDERABLE(kRGBA_8888_GrPixelConfig); - RETURN_IF_RENDERABLE(kRGBA_4444_GrPixelConfig); - RETURN_IF_RENDERABLE(kRGB_565_GrPixelConfig); - return kUnknown_GrPixelConfig; + RETURN_IF_RENDERABLE(kRGBA_8888_SkColorType, GL_RGBA8_OES); + RETURN_IF_RENDERABLE(kARGB_4444_SkColorType, GL_RGBA4); + RETURN_IF_RENDERABLE(kRGB_565_SkColorType, GL_RGB565); + return kUnknown_SkColorType; } static sk_sp WrapOnscreenSurface(GrContext* context, const SkISize& size, intptr_t fbo) { + + GLenum format; + const SkColorType color_type = FirstSupportedColorType(context, &format); + const GrGLFramebufferInfo framebuffer_info = { .fFBOID = static_cast(fbo), + .fFormat = format, }; - const GrPixelConfig pixel_config = FirstSupportedConfig(context); GrBackendRenderTarget render_target(size.fWidth, // width size.fHeight, // height 0, // sample count 0, // stencil bits (TODO) - pixel_config, // pixel config framebuffer_info // framebuffer info ); @@ -108,6 +115,7 @@ static sk_sp WrapOnscreenSurface(GrContext* context, context, // gr context render_target, // render target GrSurfaceOrigin::kBottomLeft_GrSurfaceOrigin, // origin + color_type, // color type colorspace, // colorspace &surface_props // surface properties ); -- GitLab