mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
VulkanSurface and GPUSurfaceGL no longer use GrPixelConfig (flutter/engine#4814)
* VulkanSurface and GPUSurfaceGL no longer use GrPixelConfig * fix 565 * fix gpu_surface_gl changes
This commit is contained in:
parent
2b4e8a5af5
commit
2bd16b8a3b
@ -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
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user