Changeset 205452 in webkit


Ignore:
Timestamp:
Sep 5, 2016 7:22:07 AM (8 years ago)
Author:
Gustavo Noronha Silva
Message:

[GTK] GL_PACK_ROW_LENGTH is not available in GLES2
https://bugs.webkit.org/show_bug.cgi?id=161484

Reviewed by Carlos Garcia Campos.

  • UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:

(WebKit::AcceleratedBackingStoreWayland::paint): when under GLES2 we cannot rely on
GL_PACK_ROW_LENGTH; use glReadPixel directly when stride matches width, read line
by line manually otherwise. Colour conversion is also required to get the data out
correctly.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r205431 r205452  
     12016-09-05  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
     2
     3        [GTK] GL_PACK_ROW_LENGTH is not available in GLES2
     4        https://bugs.webkit.org/show_bug.cgi?id=161484
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
     9        (WebKit::AcceleratedBackingStoreWayland::paint): when under GLES2 we cannot rely on
     10        GL_PACK_ROW_LENGTH; use glReadPixel directly when stride matches width, read line
     11        by line manually otherwise. Colour conversion is also required to get the data out
     12        correctly.
     13
    1142016-09-05  Carlos Garcia Campos  <cgarcia@igalia.com>
    215
  • trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp

    r205116 r205452  
    9090
    9191    glPixelStorei(GL_PACK_ALIGNMENT, 4);
     92
     93#if USE(OPENGL_ES_2)
     94    unsigned char* data = cairo_image_surface_get_data(m_surface.get());
     95    if (cairo_image_surface_get_stride(m_surface.get()) == textureSize.width() * 4)
     96        glReadPixels(0, 0, textureSize.width(), textureSize.height(), GL_RGBA, GL_UNSIGNED_BYTE, data);
     97    else {
     98        int strideBytes = cairo_image_surface_get_stride(m_surface.get());
     99        for (int i = 0; i < textureSize.height(); i++) {
     100            unsigned char* dataOffset = data + i * strideBytes;
     101            glReadPixels(0, i, textureSize.width(), 1, GL_RGBA, GL_UNSIGNED_BYTE, dataOffset);
     102        }
     103    }
     104
     105    // Convert to BGRA.
     106    int totalBytes = size.width() * size.height() * 4;
     107    for (int i = 0; i < totalBytes; i += 4)
     108        std::swap(data[i], data[i + 2]);
     109#else
    92110    glPixelStorei(GL_PACK_ROW_LENGTH, cairo_image_surface_get_stride(m_surface.get()) / 4);
    93 #if USE(OPENGL_ES_2)
    94     glReadPixels(0, 0, textureSize.width(), textureSize.height(), GL_RGBA, GL_UNSIGNED_BYTE, cairo_image_surface_get_data(m_surface.get()));
    95 #else
    96111    glReadPixels(0, 0, textureSize.width(), textureSize.height(), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, cairo_image_surface_get_data(m_surface.get()));
     112    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
    97113#endif
    98     glPixelStorei(GL_PACK_ROW_LENGTH, 0);
    99114
    100115    glBindFramebuffer(GL_FRAMEBUFFER, 0);
Note: See TracChangeset for help on using the changeset viewer.