In short, my application supports both Opengl and Dawn backends.
When I open support for both Dawn and Opengl, it looks like this.
skia_enable_gpu = true
skia_use_metal = true
skia_use_gl = true
skia_use_dawn=true
skia_use_vulkan=false
application will fail when using Opengl to build SkSurface.
If I turn off the compile option on the Dawn backend, everything is fine
GrGLFramebufferInfo info;
info.fFBOID = (GLuint)framebuffer;
info.fFormat = format;
GrBackendRenderTarget target(width, height, 0, 0, info);
SkSurfaceProps surface_props;
auto surface = SkSurface::MakeFromBackendRenderTarget(
env->gr_context_.get(),
target,
kBottomLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType,
nullptr,
&surface_props);
I'm pretty sure info.fFormat= format; Is a valid value.
But when I tracked down the Skia code, I realized
this file skia/src/gpu/ganesh/GrBackendSurface.cpp and In the following code
#ifdef SK_GL
GrBackendRenderTarget::GrBackendRenderTarget(int width,
int height,
int sampleCnt,
int stencilBits,
const GrGLFramebufferInfo& glInfo)
: fWidth(width)
, fHeight(height)
, fSampleCnt(std::max(1, sampleCnt))
, fStencilBits(stencilBits)
, fBackend(GrBackendApi::kOpenGL)
, fGLInfo(glInfo) {
fIsValid = SkToBool(glInfo.fFormat); // the glInfo must have a valid format
}
#endif
glInfo.fFormat It just magically becomes 0, so Is it a hidden memory error?
My platform is MAC system M1 chip.