Skip to content

Commit

Permalink
Merge r223887 - [GTK][X11] Windy.com shows always straight wind lines
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=176718

Reviewed by Carlos Garcia Campos.

WebGL's GL_LUMINANCE_ALPHA format is not available in OpenGL when using a version >= 3.2
and a core profile. In that case, we need to replace it with GL_RG and swizzle the color
components appropriately.

No new behavior.

* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
(WebCore::GraphicsContext3D::texImage2D):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::texSubImage2D):
  • Loading branch information
magomez authored and carlosgcampos committed Oct 27, 2017
1 parent e4f41c7 commit d7578ca
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
18 changes: 18 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,21 @@
2017-10-24 Miguel Gomez <magomez@igalia.com>

[GTK][X11] Windy.com shows always straight wind lines
https://bugs.webkit.org/show_bug.cgi?id=176718

Reviewed by Carlos Garcia Campos.

WebGL's GL_LUMINANCE_ALPHA format is not available in OpenGL when using a version >= 3.2
and a core profile. In that case, we need to replace it with GL_RG and swizzle the color
components appropriately.

No new behavior.

* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
(WebCore::GraphicsContext3D::texImage2D):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::texSubImage2D):

2017-10-23 Zalan Bujtas <zalan@apple.com>

Call FrameView::scheduleSelectionUpdate when selection needs repainting after layout instead of setting the RenderView dirty.
Expand Down
Expand Up @@ -386,13 +386,30 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte
openGLFormat = GL_RGB;
#endif

if (m_usingCoreProfile && openGLInternalFormat == ALPHA) {
// We are using a core profile. This means that GL_ALPHA, which is a valid format in WebGL for texImage2D
// is not supported in OpenGL. It needs to be backed with a GL_RED plane. We change the formats to GL_RED
// (both need to be GL_ALPHA in WebGL) and instruct the texture to swizzle the red component values with
// the the alpha component values.
openGLInternalFormat = openGLFormat = RED;
texParameteri(target, TEXTURE_SWIZZLE_A, RED);
if (m_usingCoreProfile) {
// There are some format values used in WebGL that are deprecated when using a core profile, so we need
// to adapt them.
switch (openGLInternalFormat) {
case ALPHA:
// The format is a simple component containing an alpha value. It needs to be backed with a GL_RED plane.
// We change the formats to GL_RED (both need to be GL_ALPHA in WebGL) and instruct the texture to swizzle
// the red component values with the alpha component values.
openGLInternalFormat = openGLFormat = RED;
texParameteri(target, TEXTURE_SWIZZLE_A, RED);
break;
case LUMINANCE_ALPHA:
// The format has 2 components, an alpha one and a luminance one (same value for red, green and blue).
// It needs to be backed with a GL_RG plane, using the red component for the colors and the green component
// for alpha. We change the formats to GL_RG and swizzle the components.
openGLInternalFormat = openGLFormat = RG;
texParameteri(target, TEXTURE_SWIZZLE_R, RED);
texParameteri(target, TEXTURE_SWIZZLE_G, RED);
texParameteri(target, TEXTURE_SWIZZLE_B, RED);
texParameteri(target, TEXTURE_SWIZZLE_A, GREEN);
break;
default:
break;
}
}

texImage2DDirect(target, level, openGLInternalFormat, width, height, border, openGLFormat, type, pixels);
Expand Down
Expand Up @@ -1807,10 +1807,21 @@ void GraphicsContext3D::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xo
type = GL_HALF_FLOAT_ARB;
#endif

if (m_usingCoreProfile && format == ALPHA) {
// We are using a core profile. This means that GL_ALPHA, which is a valid format in WebGL for texSubImage2D
// is not supported in OpenGL. We are using GL_RED to back GL_ALPHA, so do it here as well.
format = RED;
if (m_usingCoreProfile) {
// There are some format values used in WebGL that are deprecated when using a core profile, so we need
// to adapt them, as we do in GraphicsContext3D::texImage2D().
switch (format) {
case ALPHA:
// We are using GL_RED to back GL_ALPHA, so do it here as well.
format = RED;
break;
case LUMINANCE_ALPHA:
// We are using GL_RG to back GL_LUMINANCE_ALPHA, so do it here as well.
format = RG;
break;
default:
break;
}
}

// FIXME: we will need to deal with PixelStore params when dealing with image buffers that differ from the subimage size.
Expand Down

0 comments on commit d7578ca

Please sign in to comment.