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:
committed by
Jason Simmons
parent
2b4e8a5af5
commit
2bd16b8a3b
@@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
#include "gpu_surface_gl.h"
|
#include "gpu_surface_gl.h"
|
||||||
|
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#include <GLES2/gl2ext.h>
|
||||||
|
|
||||||
#include "flutter/glue/trace_event.h"
|
#include "flutter/glue/trace_event.h"
|
||||||
#include "lib/fxl/arraysize.h"
|
#include "lib/fxl/arraysize.h"
|
||||||
#include "lib/fxl/logging.h"
|
#include "lib/fxl/logging.h"
|
||||||
@@ -71,31 +74,35 @@ bool GPUSurfaceGL::IsValid() {
|
|||||||
return valid_;
|
return valid_;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GrPixelConfig FirstSupportedConfig(GrContext* context) {
|
static SkColorType FirstSupportedColorType(GrContext* context, GLenum* format) {
|
||||||
#define RETURN_IF_RENDERABLE(x) \
|
#define RETURN_IF_RENDERABLE(x, y) \
|
||||||
if (context->caps()->isConfigRenderable((x), false)) { \
|
if (context->colorTypeSupportedAsSurface((x))) { \
|
||||||
return (x); \
|
*format = (y); \
|
||||||
|
return (x); \
|
||||||
}
|
}
|
||||||
RETURN_IF_RENDERABLE(kRGBA_8888_GrPixelConfig);
|
RETURN_IF_RENDERABLE(kRGBA_8888_SkColorType, GL_RGBA8_OES);
|
||||||
RETURN_IF_RENDERABLE(kRGBA_4444_GrPixelConfig);
|
RETURN_IF_RENDERABLE(kARGB_4444_SkColorType, GL_RGBA4);
|
||||||
RETURN_IF_RENDERABLE(kRGB_565_GrPixelConfig);
|
RETURN_IF_RENDERABLE(kRGB_565_SkColorType, GL_RGB565);
|
||||||
return kUnknown_GrPixelConfig;
|
return kUnknown_SkColorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
static sk_sp<SkSurface> WrapOnscreenSurface(GrContext* context,
|
static sk_sp<SkSurface> WrapOnscreenSurface(GrContext* context,
|
||||||
const SkISize& size,
|
const SkISize& size,
|
||||||
intptr_t fbo) {
|
intptr_t fbo) {
|
||||||
|
|
||||||
|
GLenum format;
|
||||||
|
const SkColorType color_type = FirstSupportedColorType(context, &format);
|
||||||
|
|
||||||
const GrGLFramebufferInfo framebuffer_info = {
|
const GrGLFramebufferInfo framebuffer_info = {
|
||||||
.fFBOID = static_cast<GrGLuint>(fbo),
|
.fFBOID = static_cast<GrGLuint>(fbo),
|
||||||
|
.fFormat = format,
|
||||||
};
|
};
|
||||||
|
|
||||||
const GrPixelConfig pixel_config = FirstSupportedConfig(context);
|
|
||||||
|
|
||||||
GrBackendRenderTarget render_target(size.fWidth, // width
|
GrBackendRenderTarget render_target(size.fWidth, // width
|
||||||
size.fHeight, // height
|
size.fHeight, // height
|
||||||
0, // sample count
|
0, // sample count
|
||||||
0, // stencil bits (TODO)
|
0, // stencil bits (TODO)
|
||||||
pixel_config, // pixel config
|
|
||||||
framebuffer_info // framebuffer info
|
framebuffer_info // framebuffer info
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -108,6 +115,7 @@ static sk_sp<SkSurface> WrapOnscreenSurface(GrContext* context,
|
|||||||
context, // gr context
|
context, // gr context
|
||||||
render_target, // render target
|
render_target, // render target
|
||||||
GrSurfaceOrigin::kBottomLeft_GrSurfaceOrigin, // origin
|
GrSurfaceOrigin::kBottomLeft_GrSurfaceOrigin, // origin
|
||||||
|
color_type, // color type
|
||||||
colorspace, // colorspace
|
colorspace, // colorspace
|
||||||
&surface_props // surface properties
|
&surface_props // surface properties
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user