1 /* 2 * Copyright 2023 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrGLBackendSurface_DEFINED 9 #define GrGLBackendSurface_DEFINED 10 11 #include "include/gpu/ganesh/gl/GrGLTypes.h" 12 #include "include/private/base/SkAPI.h" 13 14 #include <string_view> 15 16 class GrBackendFormat; 17 class GrBackendTexture; 18 class GrBackendRenderTarget; 19 20 namespace skgpu { enum class Mipmapped : bool; } 21 22 namespace GrBackendFormats { 23 SK_API GrBackendFormat MakeGL(GrGLenum format, GrGLenum target); 24 25 SK_API GrGLFormat AsGLFormat(const GrBackendFormat&); 26 SK_API GrGLenum AsGLFormatEnum(const GrBackendFormat&); 27 } // namespace GrBackendFormats 28 29 namespace GrBackendTextures { 30 // The GrGLTextureInfo must have a valid fFormat. 31 SK_API GrBackendTexture MakeGL(int width, 32 int height, 33 skgpu::Mipmapped, 34 const GrGLTextureInfo& glInfo, 35 std::string_view label = {}); 36 37 // If the backend API is GL, copies a snapshot of the GrGLTextureInfo struct into the passed in 38 // pointer and returns true. Otherwise returns false if the backend API is not GL. 39 SK_API bool GetGLTextureInfo(const GrBackendTexture&, GrGLTextureInfo*); 40 41 // Call this to indicate that the texture parameters have been modified in the GL context 42 // externally to GrContext. 43 SK_API void GLTextureParametersModified(GrBackendTexture*); 44 } // namespace GrBackendTextures 45 46 namespace GrBackendRenderTargets { 47 // The GrGLTextureInfo must have a valid fFormat. If wrapping in an SkSurface we require the 48 // stencil bits to be either 0, 8 or 16. 49 SK_API GrBackendRenderTarget MakeGL(int width, 50 int height, 51 int sampleCnt, 52 int stencilBits, 53 const GrGLFramebufferInfo& glInfo); 54 55 SK_API bool GetGLFramebufferInfo(const GrBackendRenderTarget&, GrGLFramebufferInfo*); 56 } // namespace GrBackendRenderTargets 57 58 #endif 59