Use unnormalized coords all the way through with GL_TEXTURE_RECTANGLE textures.
We used to unnormalize them in the shader via SkSL.
This allows us to support GL_TEXTURE_RECTANGLE without having textureSize()
available in GLSL.
Change-Id: Ibe63a302228811933ef000251db4cad9aaf4f2ea
Reviewed-on: https://skia-review.googlesource.com/c/174068
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 73e1f9d..9f26a7c 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -227,11 +227,7 @@
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(3, 1) || ctxInfo.hasExtension("GL_ARB_texture_rectangle") ||
ctxInfo.hasExtension("GL_ANGLE_texture_rectangle")) {
- // We also require textureSize() support for rectangle 2D samplers which was added in
- // GLSL 1.40.
- if (ctxInfo.glslGeneration() >= k140_GrGLSLGeneration) {
- fRectangleTextureSupport = true;
- }
+ fRectangleTextureSupport = true;
}
} else {
// Command buffer exposes this in GL ES context for Chromium reasons,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index df10ffd..63bf032 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3739,11 +3739,13 @@
sy0 = sh - sy0;
sy1 = sh - sy1;
}
- // src rect edges in normalized texture space (0 to 1)
- sx0 /= sw;
- sx1 /= sw;
- sy0 /= sh;
- sy1 /= sh;
+ if (srcTex->texturePriv().textureType() != GrTextureType::kRectangle) {
+ // src rect edges in normalized texture space (0 to 1)
+ sx0 /= sw;
+ sx1 /= sw;
+ sy0 /= sh;
+ sy1 /= sh;
+ }
GL_CALL(Uniform4f(fCopyPrograms[progIdx].fPosXformUniform, dx1 - dx0, dy1 - dy0, dx0, dy0));
GL_CALL(Uniform4f(fCopyPrograms[progIdx].fTexCoordXformUniform,