Changeset 242084 in webkit


Ignore:
Timestamp:
Feb 26, 2019 7:11:29 AM (5 years ago)
Author:
Philippe Normand
Message:

[EGL] Runtime support for RGB565 pixel layout
https://bugs.webkit.org/show_bug.cgi?id=194817

Reviewed by Carlos Garcia Campos.

Currently our graphics pipeline always relies on a ARGB8888 (32
bpp) pixel configuration. On some low-end (old) embedded platforms
the graphics driver is sometimes optimized for 16 bpp
configurations, such as RGB565. On those platforms the application
can now set the WEBKIT_EGL_PIXEL_LAYOUT environment variable to
"RGB565" to adjust to the best pixel configuration supported by
the screen and graphics driver.

  • platform/graphics/egl/GLContextEGL.cpp:

(WebCore::GLContextEGL::getEGLConfig):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242082 r242084  
     12019-02-26  Philippe Normand  <pnormand@igalia.com>
     2
     3        [EGL] Runtime support for RGB565 pixel layout
     4        https://bugs.webkit.org/show_bug.cgi?id=194817
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Currently our graphics pipeline always relies on a ARGB8888 (32
     9        bpp) pixel configuration. On some low-end (old) embedded platforms
     10        the graphics driver is sometimes optimized for 16 bpp
     11        configurations, such as RGB565. On those platforms the application
     12        can now set the WEBKIT_EGL_PIXEL_LAYOUT environment variable to
     13        "RGB565" to adjust to the best pixel configuration supported by
     14        the screen and graphics driver.
     15
     16        * platform/graphics/egl/GLContextEGL.cpp:
     17        (WebCore::GLContextEGL::getEGLConfig):
     18
    1192019-02-26  Philippe Normand  <pnormand@igalia.com> and Carlos Garcia Campos  <cgarcia@igalia.com>
    220
  • trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp

    r229663 r242084  
    5353#include <cairo-gl.h>
    5454#endif
     55
     56#include <wtf/Vector.h>
    5557
    5658namespace WebCore {
     
    101103        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
    102104#endif
    103         EGL_RED_SIZE, 8,
    104         EGL_GREEN_SIZE, 8,
    105         EGL_BLUE_SIZE, 8,
     105        EGL_RED_SIZE, 1,
     106        EGL_GREEN_SIZE, 1,
     107        EGL_BLUE_SIZE, 1,
     108        EGL_ALPHA_SIZE, 1,
    106109        EGL_STENCIL_SIZE, 8,
    107         EGL_ALPHA_SIZE, 8,
    108110        EGL_SURFACE_TYPE, EGL_NONE,
    109111        EGL_NONE
    110112    };
     113
     114    bool isRGB565 = false;
     115    if (const char* environmentVariable = getenv("WEBKIT_EGL_PIXEL_LAYOUT")) {
     116        if (!strcmp(environmentVariable, "RGB565")) {
     117            isRGB565 = true;
     118            // EGL_RED_SIZE
     119            attributeList[3] = 5;
     120            // EGL_GREEN_SIZE
     121            attributeList[5] = 6;
     122            // EGL_BLUE_SIZE
     123            attributeList[7] = 5;
     124            // EGL_ALPHA_SIZE
     125            attributeList[9] = 0;
     126        } else
     127            WTFLogAlways("Unknown pixel layout %s, falling back to RGBA8888", environmentVariable);
     128    }
    111129
    112130    switch (surfaceType) {
     
    123141    }
    124142
     143    EGLint count;
     144    if (!eglChooseConfig(display, attributeList, nullptr, 0, &count))
     145        return false;
     146
    125147    EGLint numberConfigsReturned;
    126     return eglChooseConfig(display, attributeList, config, 1, &numberConfigsReturned) && numberConfigsReturned;
     148    Vector<EGLConfig> configs(count);
     149    if (!eglChooseConfig(display, attributeList, isRGB565 ? reinterpret_cast<EGLConfig*>(configs.data()) : config, isRGB565 ? count : 1, &numberConfigsReturned) || !numberConfigsReturned)
     150        return false;
     151
     152    if (!isRGB565)
     153        return true;
     154
     155    auto index = configs.findMatching([&](EGLConfig value) {
     156        EGLint redSize, greenSize, blueSize, alphaSize;
     157        eglGetConfigAttrib(display, value, EGL_RED_SIZE, &redSize);
     158        eglGetConfigAttrib(display, value, EGL_GREEN_SIZE, &greenSize);
     159        eglGetConfigAttrib(display, value, EGL_BLUE_SIZE, &blueSize);
     160        eglGetConfigAttrib(display, value, EGL_ALPHA_SIZE, &alphaSize);
     161        return (redSize == 5 && greenSize == 6 && blueSize == 5 && !alphaSize);
     162    });
     163
     164    if (index != notFound) {
     165        *config = configs[index];
     166        return true;
     167    }
     168    return false;
    127169}
    128170
Note: See TracChangeset for help on using the changeset viewer.