Merge changes from topic '62033391' into oc-dr1-dev
* changes:
Add displayId in InputDispatcher, InputTransport
Enable InputMonitors for non-default display.
diff --git a/opengl/include/EGL/eglext.h b/opengl/include/EGL/eglext.h
index 7de8c62..bb28600 100644
--- a/opengl/include/EGL/eglext.h
+++ b/opengl/include/EGL/eglext.h
@@ -682,6 +682,11 @@
#define EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362
#endif /* EGL_EXT_gl_colorspace_display_p3_linear */
+#ifndef EGL_EXT_gl_colorspace_scrgb
+#define EGL_EXT_gl_colorspace_scrgb 1
+#define EGL_GL_COLORSPACE_SCRGB_EXT 0x3351
+#endif /* EGL_EXT_gl_colorspace_scrgb */
+
#ifndef EGL_EXT_gl_colorspace_scrgb_linear
#define EGL_EXT_gl_colorspace_scrgb_linear 1
#define EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT 0x3350
diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp
index a344636..b4cc211 100644
--- a/opengl/libs/Android.bp
+++ b/opengl/libs/Android.bp
@@ -127,7 +127,14 @@
"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"],
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index c5feb89..0214b0e 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -87,9 +87,6 @@
"EGL_ANDROID_get_native_client_buffer "
"EGL_ANDROID_front_buffer_auto_refresh "
"EGL_ANDROID_get_frame_timestamps "
- "EGL_EXT_gl_colorspace_scrgb_linear "
- "EGL_EXT_gl_colorspace_display_p3_linear "
- "EGL_EXT_gl_colorspace_display_p3 "
;
char const * const gExtensionString =
@@ -467,6 +464,8 @@
return HAL_DATASPACE_DISPLAY_P3;
} else if (colorspace == EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT) {
return HAL_DATASPACE_DISPLAY_P3_LINEAR;
+ } else if (colorspace == EGL_GL_COLORSPACE_SCRGB_EXT) {
+ return HAL_DATASPACE_V0_SCRGB;
} else if (colorspace == EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT) {
return HAL_DATASPACE_V0_SCRGB_LINEAR;
}
@@ -526,25 +525,34 @@
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;
} else if (colorSpace == EGL_EXT_gl_colorspace_bt2020_pq &&
dp->haveExtension("EGL_EXT_gl_colorspace_bt2020_pq")) {
found = true;
+ } else if (colorSpace == EGL_GL_COLORSPACE_SCRGB_EXT &&
+ dp->haveExtension("EGL_EXT_gl_colorspace_scrgb")) {
+ found = true;
} else if (colorSpace == EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT &&
dp->haveExtension("EGL_EXT_gl_colorspace_scrgb_linear")) {
found = true;
@@ -558,6 +566,31 @@
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);
@@ -567,6 +600,11 @@
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
@@ -661,7 +699,7 @@
// 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);
}
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index b696920..4e5833a 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -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 @@
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
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index bd9b8aa..ea04839 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -377,11 +377,16 @@
DispSync::DispSync(const char* name) :
mName(name),
mRefreshSkipCount(0),
- mThread(new DispSyncThread(name)),
- mIgnorePresentFences(!SurfaceFlinger::hasSyncFramework){
+ mThread(new DispSyncThread(name)) {
+}
- mPresentTimeOffset = SurfaceFlinger::dispSyncPresentTimeOffset;
+DispSync::~DispSync() {}
+
+void DispSync::init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset) {
+ mIgnorePresentFences = !hasSyncFramework;
+ mPresentTimeOffset = dispSyncPresentTimeOffset;
mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
+
// set DispSync to SCHED_FIFO to minimize jitter
struct sched_param param = {0};
param.sched_priority = 2;
@@ -389,7 +394,6 @@
ALOGE("Couldn't set SCHED_FIFO for DispSyncThread");
}
-
reset();
beginResync();
@@ -405,8 +409,6 @@
}
}
-DispSync::~DispSync() {}
-
void DispSync::reset() {
Mutex::Autolock lock(mMutex);
diff --git a/services/surfaceflinger/DispSync.h b/services/surfaceflinger/DispSync.h
index 82ae795..3c34fb0 100644
--- a/services/surfaceflinger/DispSync.h
+++ b/services/surfaceflinger/DispSync.h
@@ -55,6 +55,8 @@
explicit DispSync(const char* name);
~DispSync();
+ void init(bool hasSyncFramework, int64_t dispSyncPresentTimeOffset);
+
// reset clears the resync samples and error value.
void reset();
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index a0abf12..fc60002 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -442,6 +442,11 @@
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
// ----------------------------------------------------------------------------
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index e2852a7..578f81b 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -189,6 +189,7 @@
#ifdef USE_HWC2
android_color_mode_t getActiveColorMode() const;
void setActiveColorMode(android_color_mode_t mode);
+ void setCompositionDataSpace(android_dataspace dataspace);
#endif
/* ------------------------------------------------------------------------
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
index 5b869e1..68d7a18 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
@@ -106,12 +106,6 @@
if (result != NO_ERROR) {
ALOGE("error latching next FramebufferSurface buffer: %s (%d)",
strerror(-result), result);
- return result;
- }
- result = mHwc.setClientTarget(mDisplayType, slot,
- acquireFence, buf, dataspace);
- if (result != NO_ERROR) {
- ALOGE("error posting framebuffer: %d", result);
}
return result;
#else
@@ -182,7 +176,13 @@
#else
outBuffer = mCurrentBuffer;
#endif
- return NO_ERROR;
+ status_t result =
+ mHwc.setClientTarget(mDisplayType, outSlot, outFence, outBuffer, outDataspace);
+ if (result != NO_ERROR) {
+ ALOGE("error posting framebuffer: %d", result);
+ }
+
+ return result;
}
#ifndef USE_HWC2
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 63f260a..702f32f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -195,6 +195,8 @@
hasWideColorDisplay =
getBool<ISurfaceFlingerConfigs, &ISurfaceFlingerConfigs::hasWideColorDisplay>(false);
+ mPrimaryDispSync.init(hasSyncFramework, dispSyncPresentTimeOffset);
+
// debugging stuff...
char value[PROPERTY_VALUE_MAX];
@@ -383,6 +385,7 @@
#ifdef USE_HWC2
sp<DisplayDevice> hw(getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]));
if (hw->getWideColorSupport()) {
+ hw->setCompositionDataSpace(HAL_DATASPACE_V0_SRGB);
setActiveColorModeInternal(hw, HAL_COLOR_MODE_SRGB);
}
#endif
@@ -1222,6 +1225,7 @@
hasWideColorModes && hasWideColorDisplay);
mDisplays.add(token, hw);
setActiveColorModeInternal(hw, HAL_COLOR_MODE_NATIVE);
+ hw->setCompositionDataSpace(HAL_DATASPACE_UNKNOWN);
}
void SurfaceFlinger::onHotplugReceived(HWComposer* composer, int32_t disp, bool connected) {
@@ -1871,6 +1875,7 @@
// To achieve this we suppress color mode changes until after the boot animation
if (mBootFinished) {
setActiveColorModeInternal(displayDevice, newColorMode);
+ displayDevice->setCompositionDataSpace(newDataSpace);
}
}
}
diff --git a/vulkan/api/vulkan.api b/vulkan/api/vulkan.api
index 3efc131..11161c6 100644
--- a/vulkan/api/vulkan.api
+++ b/vulkan/api/vulkan.api
@@ -1255,6 +1255,7 @@
VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT = 1000104011,
VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT = 1000104012,
VK_COLOR_SPACE_PASS_THROUGH_EXT = 1000104013,
+ VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT = 1000104014,
}
@extension("VK_EXT_debug_report") // 12
diff --git a/vulkan/include/vulkan/vulkan.h b/vulkan/include/vulkan/vulkan.h
index ee30913..f0209d6 100644
--- a/vulkan/include/vulkan/vulkan.h
+++ b/vulkan/include/vulkan/vulkan.h
@@ -3355,6 +3355,7 @@
VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT = 1000104011,
VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT = 1000104012,
VK_COLOR_SPACE_PASS_THROUGH_EXT = 1000104013,
+ VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT = 1000104014,
VK_COLOR_SPACE_BEGIN_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
VK_COLOR_SPACE_END_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
VK_COLOR_SPACE_RANGE_SIZE_KHR = (VK_COLOR_SPACE_SRGB_NONLINEAR_KHR - VK_COLOR_SPACE_SRGB_NONLINEAR_KHR + 1),
@@ -5829,7 +5830,7 @@
#endif
#define VK_EXT_swapchain_colorspace 1
-#define VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION 2
+#define VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION 3
#define VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME "VK_EXT_swapchain_colorspace"
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 651438d..069fb36 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -640,6 +640,8 @@
const VkSurfaceFormatKHR kWideColorFormats[] = {
{VK_FORMAT_R16G16B16A16_SFLOAT,
VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT},
+ {VK_FORMAT_R16G16B16A16_SFLOAT,
+ VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT},
{VK_FORMAT_A2R10G10B10_UNORM_PACK32,
VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT},
};