52#define GL(F) GR_GL_CALL(ctxInfo.glContext()->gl(), F)
54 auto dContext = ctxInfo.directContext();
55 GrGpu* gpu = dContext->priv().getGpu();
68 bool supportRectangle;
76 GL(GenTextures(claimedIDs.
size(), claimedIDs.
begin()));
78 auto resetBindings = [&] {
80 for (
int u = 0; u < numUnits; ++u) {
82 for (
auto target : targets) {
83 GL(BindTexture(
target.fName, claimedIDs[
i++]));
87 auto checkBindings = [&] {
89 for (
int u = 0; u < numUnits; ++u) {
91 for (
auto target : targets) {
93 GL(GetIntegerv(
target.fQuery, &boundID));
94 if (boundID != (
int) claimedIDs[
i] && boundID != 0) {
95 ERRORF(
reporter,
"Unit %d, target 0x%04x has ID %d bound. Expected %u or 0.", u,
96 target.fName, boundID, claimedIDs[
i]);
105 dContext->flushAndSubmit();
107 dContext->resetContext();
110 static constexpr SkISize kDims = {10, 10};
121 "TextureBindingsResetTest");
123 dContext->resetGLTextureBindings();
126 dContext->resetContext();
132 surf->getCanvas()->clear(0x80FF0000);
133 auto img = surf->makeImageSnapshot();
135 surf->getCanvas()->save();
136 surf->getCanvas()->scale(0.25, 0.25);
137 surf->getCanvas()->drawImage(img.get(), 0, 0,
SkSamplingOptions({1.0f/3, 1.0f/3}),
nullptr);
138 surf->getCanvas()->restore();
140 dContext->resetGLTextureBindings();
143 dContext->resetContext();
145 if (supportExternal) {
155 GrEGLImage eglImage = ctxInfo.glContext()->texture2DToEGLImage(info2D.
fID);
158 infoExternal.
fID = ctxInfo.glContext()->eglImageToExternalTexture(eglImage);
167 dContext->resetContext();
175 surf->getCanvas()->drawImage(img, 0, 0);
178 dContext->resetGLTextureBindings();
181 GL(DeleteTextures(1, &infoExternal.
fID));
182 ctxInfo.glContext()->destroyEGLImage(eglImage);
183 dContext->deleteBackendTexture(texture2D);
184 dContext->resetContext();
187 if (supportRectangle) {
191 if (rectangleTexture.
isValid()) {
199 surf->getCanvas()->drawImage(img, 0, 0);
202 dContext->resetGLTextureBindings();
205 dContext->deleteBackendTexture(rectangleTexture);
209 GL(DeleteTextures(claimedIDs.
size(), claimedIDs.
begin()));
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define GR_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
#define GR_GL_TEXTURE_BINDING_2D
#define GR_GL_TEXTURE_BINDING_EXTERNAL
#define GR_GL_TEXTURE_RECTANGLE
#define GR_GL_TEXTURE_EXTERNAL
#define GR_GL_TEXTURE_BINDING_RECTANGLE
@ kTopLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorBLUE
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GANESH_TEST_FOR_GL_CONTEXT(name, reporter, context_info, ctsEnforcement)
const GrShaderCaps * shaderCaps() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
bool rectangleTextureSupport() const
Are textures with GL_TEXTURE_RECTANGLE type supported.
const GrGLCaps & glCaps() const
const GrCaps * caps() const
sk_sp< GrTexture > createTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, GrRenderable renderable, int renderTargetSampleCnt, skgpu::Budgeted budgeted, GrProtected isProtected, GrColorType textureColorType, GrColorType srcColorType, const GrMipLevel texels[], int texelLevelCount, std::string_view label)
void push_back(const T &v)
uint32_t uint32_t * format
SK_API GrBackendTexture MakeGL(int width, int height, skgpu::Mipmapped, const GrGLTextureInfo &glInfo, std::string_view label={})
SK_API bool GetGLTextureInfo(const GrBackendTexture &, GrGLTextureInfo *)
constexpr SkColor4f kTransparent
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
skgpu::Protected fProtected
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
bool fExternalTextureSupport