提交 60befc2c 编写于 作者: B Brian Salomon 提交者: Jason Simmons

VulkanSurface and GPUSurfaceGL no longer use GrPixelConfig (#4814)

* VulkanSurface and GPUSurfaceGL no longer use GrPixelConfig

* fix 565

* fix gpu_surface_gl changes
上级 e102ae3d
......@@ -152,6 +152,8 @@ bool VulkanSurface::AllocateDeviceMemory(sk_sp<GrContext> 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<GrContext> 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<GrContext> 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<GrContext> context,
SkSurface::MakeFromBackendRenderTarget(context.get(), //
sk_render_target, //
kTopLeft_GrSurfaceOrigin, //
color_type, //
nullptr, //
&sk_surface_props //
);
......
......@@ -80,6 +80,7 @@ class VulkanSurface : public flow::SceneUpdateContext::SurfaceProducerSurface {
bool SetupSkiaSurface(sk_sp<GrContext> context,
const SkISize& size,
SkColorType color_type,
const VkImageCreateInfo& image_create_info,
const VkMemoryRequirements& memory_reqs);
......
......@@ -4,6 +4,9 @@
#include "gpu_surface_gl.h"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#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<SkSurface> 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<GrGLuint>(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<SkSurface> WrapOnscreenSurface(GrContext* context,
context, // gr context
render_target, // render target
GrSurfaceOrigin::kBottomLeft_GrSurfaceOrigin, // origin
color_type, // color type
colorspace, // colorspace
&surface_props // surface properties
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册