Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2678ba9 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[GLUtils] Add support for GL_SRGB8_ALPHA8.

When a GL surface is configured as EGL_GL_COLORSPACE_SRGB_KHR, the pixel value
from fragment shader will be gamma-ed, to de-gamma the pixel value in fragment
shader, the texture uploaded through glTexImage2D needs to specify the internal
format as GL_SRGB8_ALPHA8. For backward compatibility, GLUtils should never
pick this internal format by itself, but it should allow developer to pass this
internal format if they really want to.

BUG: N/A
Test: Build, flash, boot and run my own test apk
Change-Id: Ic43c2f2e3533ebb41c1a85b33964c1f19ac74a7c
parent 043a3a71
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -622,13 +622,17 @@ void util_multiplyMV(JNIEnv *env, jclass clazz,

// ---------------------------------------------------------------------------

// The internal format is no longer the same as pixel format, per Table 2 in
// https://www.khronos.org/registry/OpenGL-Refpages/es3.1/html/glTexImage2D.xhtml
static int checkInternalFormat(SkColorType colorType, int internalformat,
    int type)
{
    switch(colorType) {
        case kN32_SkColorType:
            return (type == GL_UNSIGNED_BYTE &&
                internalformat == GL_RGBA) ? 0 : -1;
                    internalformat == GL_RGBA) ||
                (type == GL_UNSIGNED_BYTE &&
                 internalformat == GL_SRGB8_ALPHA8) ? 0 : -1;
        case kAlpha_8_SkColorType:
            return (type == GL_UNSIGNED_BYTE &&
                internalformat == GL_ALPHA) ? 0 : -1;