Title: [211780] releases/WebKitGTK/webkit-2.14/Source/WebCore
Revision
211780
Author
carlo...@webkit.org
Date
2017-02-07 01:31:53 -0800 (Tue, 07 Feb 2017)

Log Message

Merge r210847 - [GTK] [TextureMapper] [GLES2] Draw repeated patterns for NPOT textures manually
https://bugs.webkit.org/show_bug.cgi?id=167118

Reviewed by Žan Doberšek.

When using GLES2 without the GL_OES_texture_npot extension, some implementations fail to properly
draw repeated patters from a texture (using GL_REPEAT). For those cases, perform the repetition
manually using the shader.

Covered by existent tests.

* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::driverSupportsNPOTTextures):
(WebCore::TextureMapperGL::drawTexture):
(WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
* platform/graphics/texmap/TextureMapperShaderProgram.cpp:
(WebCore::TextureMapperShaderProgram::create):
* platform/graphics/texmap/TextureMapperShaderProgram.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (211779 => 211780)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2017-02-07 09:00:10 UTC (rev 211779)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog	2017-02-07 09:31:53 UTC (rev 211780)
@@ -1,3 +1,24 @@
+2017-01-18  Miguel Gomez  <mago...@igalia.com>
+
+        [GTK] [TextureMapper] [GLES2] Draw repeated patterns for NPOT textures manually
+        https://bugs.webkit.org/show_bug.cgi?id=167118
+
+        Reviewed by Žan Doberšek.
+
+        When using GLES2 without the GL_OES_texture_npot extension, some implementations fail to properly
+        draw repeated patters from a texture (using GL_REPEAT). For those cases, perform the repetition
+        manually using the shader.
+
+        Covered by existent tests.
+
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::driverSupportsNPOTTextures):
+        (WebCore::TextureMapperGL::drawTexture):
+        (WebCore::TextureMapperGL::drawTexturedQuadWithProgram):
+        * platform/graphics/texmap/TextureMapperShaderProgram.cpp:
+        (WebCore::TextureMapperShaderProgram::create):
+        * platform/graphics/texmap/TextureMapperShaderProgram.h:
+
 2017-01-10  Zan Dobersek  <zdober...@igalia.com>
 
         [CoordinatedGraphics] TextureMapperPlatformLayerProxy is constantly getting activated

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (211779 => 211780)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2017-02-07 09:00:10 UTC (rev 211779)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2017-02-07 09:31:53 UTC (rev 211780)
@@ -417,6 +417,16 @@
     drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : ShouldBlend, textureGL.size(), targetRect, matrix, opacity, exposedEdges);
 }
 
+static bool driverSupportsNPOTTextures(GraphicsContext3D& context)
+{
+    if (context.isGLES2Compliant()) {
+        static bool supportsNPOTTextures = context.getExtensions()->supports("GL_OES_texture_npot");
+        return supportsNPOTTextures;
+    }
+
+    return true;
+}
+
 void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges)
 {
     bool useRect = flags & ShouldUseARBTextureRect;
@@ -433,6 +443,8 @@
         options |= TextureMapperShaderProgram::Antialiasing;
         flags |= ShouldAntialias;
     }
+    if (wrapMode() == RepeatWrap && !driverSupportsNPOTTextures(*m_context3D))
+        options |= TextureMapperShaderProgram::ManualRepeat;
 
     RefPtr<FilterOperation> filter = data().filterInfo ? data().filterInfo->filter: 0;
     GC3Duint filterContentTextureID = 0;
@@ -554,7 +566,7 @@
     GC3Denum target = flags & ShouldUseARBTextureRect ? GC3Denum(Extensions3D::TEXTURE_RECTANGLE_ARB) : GC3Denum(GraphicsContext3D::TEXTURE_2D);
     m_context3D->bindTexture(target, texture);
     m_context3D->uniform1i(program.samplerLocation(), 0);
-    if (wrapMode() == RepeatWrap) {
+    if (wrapMode() == RepeatWrap && driverSupportsNPOTTextures(*m_context3D)) {
         m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::REPEAT);
         m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::REPEAT);
     }

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp (211779 => 211780)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp	2017-02-07 09:00:10 UTC (rev 211779)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp	2017-02-07 09:31:53 UTC (rev 211780)
@@ -159,6 +159,7 @@
 
         void noop(inout vec4 dummyParameter) { }
         void noop(inout vec4 dummyParameter, vec2 texCoord) { }
+        void noop(inout vec2 dummyParameter) { }
 
         float antialias() { return smoothstep(0., 1., v_antialias); }
 
@@ -170,6 +171,8 @@
 
         vec2 vertexTransformTexCoord() { return v_transformedTexCoord; }
 
+        void applyManualRepeat(inout vec2 pos) { pos = fract(pos); }
+
         void applyTexture(inout vec4 color, vec2 texCoord) { color = SamplerFunction(s_sampler, texCoord); }
         void applyOpacity(inout vec4 color) { color *= u_opacity; }
         void applyAntialiasing(inout vec4 color) { color *= antialias(); }
@@ -281,6 +284,7 @@
         {
             vec4 color = vec4(1., 1., 1., 1.);
             vec2 texCoord = transformTexCoord();
+            applyManualRepeatIfNeeded(texCoord);
             applyTextureIfNeeded(color, texCoord);
             applySolidColorIfNeeded(color);
             applyAntialiasingIfNeeded(color);
@@ -323,6 +327,7 @@
     SET_APPLIER_FROM_OPTIONS(BlurFilter);
     SET_APPLIER_FROM_OPTIONS(AlphaBlur);
     SET_APPLIER_FROM_OPTIONS(ContentTexture);
+    SET_APPLIER_FROM_OPTIONS(ManualRepeat);
 
     StringBuilder vertexShaderBuilder;
     vertexShaderBuilder.append(optionsApplierBuilder.toString());

Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h (211779 => 211780)


--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h	2017-02-07 09:00:10 UTC (rev 211779)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h	2017-02-07 09:31:53 UTC (rev 211780)
@@ -60,7 +60,8 @@
         OpacityFilter    = 1L << 13,
         BlurFilter       = 1L << 14,
         AlphaBlur        = 1L << 15,
-        ContentTexture   = 1L << 16
+        ContentTexture   = 1L << 16,
+        ManualRepeat     = 1L << 17
     };
 
     typedef unsigned Options;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to