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

Commit e124f74d authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter Committed by android-build-merger
Browse files

Merge changes If4271719,I9c9b5de9,I46a26a67 into oc-dr1-dev

am: ddd9c712

Change-Id: I842bfeea8bea812f2ff2adb87387fc129bcb68c3
parents 146c41fa ddd9c712
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -127,7 +127,14 @@ cc_library_shared {
        "EGL/Loader.cpp",
        "EGL/BlobCache.cpp",
    ],
    shared_libs: ["libvndksupport"],
    shared_libs: [
        "libvndksupport",
        "android.hardware.configstore@1.0",
        "android.hardware.configstore-utils",
        "libhidlbase",
        "libhidltransport",
        "libutils",
    ],
    static_libs: ["libEGL_getProcAddress"],
    ldflags: ["-Wl,--exclude-libs=ALL"],
    export_include_dirs: ["EGL/include"],
+39 −7
Original line number Diff line number Diff line
@@ -87,10 +87,6 @@ char const * const gBuiltinExtensionString =
        "EGL_ANDROID_get_native_client_buffer "
        "EGL_ANDROID_front_buffer_auto_refresh "
        "EGL_ANDROID_get_frame_timestamps "
        "EGL_EXT_gl_colorspace_scrgb "
        "EGL_EXT_gl_colorspace_scrgb_linear "
        "EGL_EXT_gl_colorspace_display_p3_linear "
        "EGL_EXT_gl_colorspace_display_p3 "
        ;

char const * const gExtensionString  =
@@ -529,19 +525,25 @@ static EGLBoolean stripColorSpaceAttribute(egl_display_ptr dp, const EGLint* att
    return stripped;
}

static EGLBoolean getColorSpaceAttribute(egl_display_ptr dp, const EGLint* attrib_list,
                                         EGLint& colorSpace, android_dataspace& dataSpace) {
static EGLBoolean getColorSpaceAttribute(egl_display_ptr dp, NativeWindowType window,
                                         const EGLint* attrib_list, EGLint& colorSpace,
                                         android_dataspace& dataSpace) {
    colorSpace = EGL_GL_COLORSPACE_LINEAR_KHR;
    dataSpace = HAL_DATASPACE_UNKNOWN;

    if (attrib_list && dp->haveExtension("EGL_KHR_gl_colorspace")) {
        for (const EGLint* attr = attrib_list; *attr != EGL_NONE; attr += 2) {
            if (*attr == EGL_GL_COLORSPACE_KHR) {
                colorSpace = attr[1];
                bool found = false;
                bool verify = true;
                // Verify that color space is allowed
                if (colorSpace == EGL_GL_COLORSPACE_SRGB_KHR ||
                    colorSpace == EGL_GL_COLORSPACE_LINEAR_KHR) {
                    // SRGB and LINEAR are always supported when EGL_KHR_gl_colorspace
                    // is available, so no need to verify.
                    found = true;
                    verify = false;
                } else if (colorSpace == EGL_EXT_gl_colorspace_bt2020_linear &&
                           dp->haveExtension("EGL_EXT_gl_colorspace_bt2020_linear")) {
                    found = true;
@@ -564,6 +566,31 @@ static EGLBoolean getColorSpaceAttribute(egl_display_ptr dp, const EGLint* attri
                if (!found) {
                    return false;
                }
                if (verify && window) {
                    bool wide_color_support = true;
                    // Ordinarily we'd put a call to native_window_get_wide_color_support
                    // at the beginning of the function so that we'll have the
                    // result when needed elsewhere in the function.
                    // However, because eglCreateWindowSurface is called by SurfaceFlinger and
                    // SurfaceFlinger is required to answer the call below we would
                    // end up in a deadlock situation. By moving the call to only happen
                    // if the application has specifically asked for wide-color we avoid
                    // the deadlock with SurfaceFlinger since it will not ask for a
                    // wide-color surface.
                    int err = native_window_get_wide_color_support(window, &wide_color_support);

                    if (err) {
                        ALOGE("getColorSpaceAttribute: invalid window (win=%p) "
                              "failed (%#x) (already connected to another API?)",
                              window, err);
                        return false;
                    }
                    if (!wide_color_support) {
                        // Application has asked for a wide-color colorspace but
                        // wide-color support isn't available on the display the window is on.
                        return false;
                    }
                }
                // Only change the dataSpace from default if the application
                // has explicitly set the color space with a EGL_GL_COLORSPACE_KHR attribute.
                dataSpace = modifyBufferDataspace(dataSpace, colorSpace);
@@ -573,6 +600,11 @@ static EGLBoolean getColorSpaceAttribute(egl_display_ptr dp, const EGLint* attri
    return true;
}

static EGLBoolean getColorSpaceAttribute(egl_display_ptr dp, const EGLint* attrib_list,
                                         EGLint& colorSpace, android_dataspace& dataSpace) {
    return getColorSpaceAttribute(dp, NULL, attrib_list, colorSpace, dataSpace);
}

void getNativePixelFormat(EGLDisplay dpy, egl_connection_t* cnx, EGLConfig config, EGLint& format) {
    // Set the native window's buffers format to match what this config requests.
    // Whether to use sRGB gamma is not part of the EGLconfig, but is part
@@ -667,7 +699,7 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
        // now select correct colorspace and dataspace based on user's attribute list
        EGLint colorSpace;
        android_dataspace dataSpace;
        if (!getColorSpaceAttribute(dp, attrib_list, colorSpace, dataSpace)) {
        if (!getColorSpaceAttribute(dp, window, attrib_list, colorSpace, dataSpace)) {
            ALOGE("error invalid colorspace: %d", colorSpace);
            return setError(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
        }
+18 −0
Original line number Diff line number Diff line
@@ -30,6 +30,12 @@
#include "Loader.h"
#include <cutils/properties.h>

#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
#include <configstore/Utils.h>

using namespace android::hardware::configstore;
using namespace android::hardware::configstore::V1_0;

// ----------------------------------------------------------------------------
namespace android {
// ----------------------------------------------------------------------------
@@ -192,6 +198,18 @@ EGLBoolean egl_display_t::initialize(EGLint *major, EGLint *minor) {
        mClientApiString = sClientApiString;

        mExtensionString = gBuiltinExtensionString;

        bool wideColorBoardConfig =
                getBool<ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::hasWideColorDisplay>(
                        false);

        // Add wide-color extensions if device can support wide-color
        if (wideColorBoardConfig) {
            mExtensionString.append(
                    "EGL_EXT_gl_colorspace_scrgb EGL_EXT_gl_colorspace_scrgb_linear "
                    "EGL_EXT_gl_colorspace_display_p3_linear EGL_EXT_gl_colorspace_display_p3 ");
        }

        char const* start = gExtensionString;
        do {
            // length of the extension name
+5 −0
Original line number Diff line number Diff line
@@ -442,6 +442,11 @@ void DisplayDevice::setActiveColorMode(android_color_mode_t mode) {
android_color_mode_t DisplayDevice::getActiveColorMode() const {
    return mActiveColorMode;
}

void DisplayDevice::setCompositionDataSpace(android_dataspace dataspace) {
    ANativeWindow* const window = mNativeWindow.get();
    native_window_set_buffers_data_space(window, dataspace);
}
#endif

// ----------------------------------------------------------------------------
+1 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ public:
#ifdef USE_HWC2
    android_color_mode_t getActiveColorMode() const;
    void setActiveColorMode(android_color_mode_t mode);
    void setCompositionDataSpace(android_dataspace dataspace);
#endif

    /* ------------------------------------------------------------------------
Loading