diff options
author | Marissa Wall <marissaw@google.com> | 2016-09-07 12:06:26 -0700 |
---|---|---|
committer | Marissa Wall <marissaw@google.com> | 2017-03-02 13:06:21 -0800 |
commit | 578192bd3498d8c49ead61428275f5b020906bfb (patch) | |
tree | d6723ada534211c7d18d7fe65f12164862e7f2a0 | |
parent | bdbc508d9faf131e8408fceac2bfff5ca7927b84 (diff) | |
download | flounder-578192bd3498d8c49ead61428275f5b020906bfb.tar.gz |
hwc2: color and hdr requests
Add explicit non-support for color and hdr requests. Any color or hdr request
from the client must be composited by the client.
Test: Add "TARGET_USES_HWC2 := true" to BoardConfig.mk.
Recompile.
Run testcases: https://android-review.googlesource.com/#/q/project:
platform/frameworks/native+branch:master+topic:test-hwc2
Change-Id: I0b545470a05ea53e46a51fe4cbb5551759334990
-rw-r--r-- | hwc2/hwc2.cpp | 35 | ||||
-rw-r--r-- | hwc2/hwc2.h | 32 | ||||
-rw-r--r-- | hwc2/hwc2_dev.cpp | 52 | ||||
-rw-r--r-- | hwc2/hwc2_display.cpp | 78 |
4 files changed, 180 insertions, 17 deletions
diff --git a/hwc2/hwc2.cpp b/hwc2/hwc2.cpp index e2a5ebc..1aadf19 100644 --- a/hwc2/hwc2.cpp +++ b/hwc2/hwc2.cpp @@ -120,11 +120,11 @@ hwc2_error_t get_client_target_support(hwc2_device_t *device, dataspace); } -hwc2_error_t get_color_modes(hwc2_device_t* /*device*/, - hwc2_display_t /*display*/, uint32_t* /*out_num_modes*/, - android_color_mode_t* /*out_modes*/) +hwc2_error_t get_color_modes(hwc2_device_t *device, hwc2_display_t display, + uint32_t *out_num_modes, android_color_mode_t *out_modes) { - return HWC2_ERROR_NONE; + hwc2_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev; + return dev->get_color_modes(display, out_num_modes, out_modes); } hwc2_error_t get_display_attribute(hwc2_device_t *device, @@ -173,12 +173,14 @@ hwc2_error_t get_doze_support(hwc2_device_t *device, hwc2_display_t display, return dev->get_doze_support(display, out_support); } -hwc2_error_t get_hdr_capabilities(hwc2_device_t* /*device*/, - hwc2_display_t /*display*/, uint32_t* /*out_num_types*/, - android_hdr_t* /*out_types*/, float* /*out_max_luminance*/, - float* /*out_max_average_luminance*/, float* /*out_min_luminance*/) +hwc2_error_t get_hdr_capabilities(hwc2_device_t *device, hwc2_display_t display, + uint32_t *out_num_types, android_hdr_t *out_types, + float *out_max_luminance, float *out_max_average_luminance, + float *out_min_luminance) { - return HWC2_ERROR_NONE; + hwc2_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev; + return dev->get_hdr_capabilities(display, out_num_types, out_types, + out_max_luminance, out_max_average_luminance, out_min_luminance); } hwc2_error_t get_release_fences(hwc2_device_t *device, hwc2_display_t display, @@ -213,17 +215,18 @@ hwc2_error_t set_client_target(hwc2_device_t *device, hwc2_display_t display, damage); } -hwc2_error_t set_color_mode(hwc2_device_t* /*device*/, - hwc2_display_t /*display*/, android_color_mode_t /*mode*/) +hwc2_error_t set_color_mode(hwc2_device_t *device, hwc2_display_t display, + android_color_mode_t mode) { - return HWC2_ERROR_NONE; + hwc2_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev; + return dev->set_color_mode(display, mode); } -hwc2_error_t set_color_transform(hwc2_device_t* /*device*/, - hwc2_display_t /*display*/, const float* /*matrix*/, - android_color_transform_t /*hint*/) +hwc2_error_t set_color_transform(hwc2_device_t *device, hwc2_display_t display, + const float *matrix, android_color_transform_t hint) { - return HWC2_ERROR_NONE; + hwc2_dev *dev = reinterpret_cast<hwc2_context *>(device)->hwc2_dev; + return dev->set_color_transform(display, matrix, hint); } hwc2_error_t set_output_buffer(hwc2_device_t* /*device*/, diff --git a/hwc2/hwc2.h b/hwc2/hwc2.h index 1893037..158df38 100644 --- a/hwc2/hwc2.h +++ b/hwc2/hwc2.h @@ -414,6 +414,7 @@ public: /* Display present functions */ hwc2_error_t validate_display(uint32_t *out_num_types, uint32_t *out_num_requests); + void force_client_composition(); void assign_composition(); hwc2_error_t get_changed_composition_types(uint32_t *out_num_elements, @@ -450,6 +451,17 @@ public: hwc2_error_t set_active_config(struct adf_hwc_helper *adf_helper, hwc2_config_t config); + /* Color/hdr functions */ + hwc2_error_t get_color_modes(uint32_t *out_num_modes, + android_color_mode_t *out_modes) const; + hwc2_error_t set_color_mode(android_color_mode_t mode); + hwc2_error_t get_hdr_capabilities(uint32_t *out_num_types, + android_hdr_t *out_types, float *out_max_luminance, + float *out_max_average_luminance, + float *out_min_luminance) const; + hwc2_error_t set_color_transform(const float *color_matrix, + android_color_transform_t color_hint); + /* Client target functions */ hwc2_error_t get_client_target_support(uint32_t width, uint32_t height, android_pixel_format_t format, @@ -545,6 +557,13 @@ private: /* The current power mode of the display */ hwc2_power_mode_t power_mode; + /* Color transform which will be applied after composition */ + std::array<float, 16> color_matrix; + + /* A hit value which may be used instead of the given matrix unless it is + * HAL_COLOR_TRANSFORM_ARBITRARY */ + android_color_transform_t color_hint; + /* Sync fence object which will be signaled after the device has finished * reading from the buffer presented in the prior frame */ android::base::unique_fd release_fence; @@ -603,6 +622,19 @@ public: hwc2_config_t *out_config) const; hwc2_error_t set_active_config(hwc2_display_t dpy_id, hwc2_config_t config); + /* Color/hdr functions */ + hwc2_error_t get_color_modes(hwc2_display_t dpy_id, uint32_t *out_num_modes, + android_color_mode_t *out_modes) const; + hwc2_error_t set_color_mode(hwc2_display_t dpy_id, + android_color_mode_t mode); + hwc2_error_t get_hdr_capabilities(hwc2_display_t dpy_id, + uint32_t *out_num_types, android_hdr_t *out_types, + float *out_max_luminance, float *out_max_average_luminance, + float *out_min_luminance) const; + hwc2_error_t set_color_transform(hwc2_display_t dpy_id, + const float *color_matrix, + android_color_transform_t color_hint); + /* Client target functions */ hwc2_error_t get_client_target_support(hwc2_display_t dpy_id, uint32_t width, uint32_t height, diff --git a/hwc2/hwc2_dev.cpp b/hwc2/hwc2_dev.cpp index 5b4eec9..c568d3e 100644 --- a/hwc2/hwc2_dev.cpp +++ b/hwc2/hwc2_dev.cpp @@ -241,6 +241,58 @@ hwc2_error_t hwc2_dev::set_active_config(hwc2_display_t dpy_id, return it->second.set_active_config(adf_helper, config); } +hwc2_error_t hwc2_dev::get_color_modes(hwc2_display_t dpy_id, + uint32_t *out_num_modes, android_color_mode_t *out_modes) const +{ + auto it = displays.find(dpy_id); + if (it == displays.end()) { + ALOGE("dpy %" PRIu64 ": invalid display handle", dpy_id); + return HWC2_ERROR_BAD_DISPLAY; + } + + return it->second.get_color_modes(out_num_modes, out_modes); +} + +hwc2_error_t hwc2_dev::set_color_mode(hwc2_display_t dpy_id, + android_color_mode_t mode) +{ + auto it = displays.find(dpy_id); + if (it == displays.end()) { + ALOGE("dpy %" PRIu64 ": invalid display handle", dpy_id); + return HWC2_ERROR_BAD_DISPLAY; + } + + return it->second.set_color_mode(mode); +} + +hwc2_error_t hwc2_dev::get_hdr_capabilities(hwc2_display_t dpy_id, + uint32_t *out_num_types, android_hdr_t *out_types, + float *out_max_luminance, float *out_max_average_luminance, + float *out_min_luminance) const +{ + auto it = displays.find(dpy_id); + if (it == displays.end()) { + ALOGE("dpy %" PRIu64 ": invalid display handle", dpy_id); + return HWC2_ERROR_BAD_DISPLAY; + } + + return it->second.get_hdr_capabilities(out_num_types, out_types, + out_max_luminance, out_max_average_luminance, + out_min_luminance); +} + +hwc2_error_t hwc2_dev::set_color_transform(hwc2_display_t dpy_id, + const float *color_matrix, android_color_transform_t color_hint) +{ + auto it = displays.find(dpy_id); + if (it == displays.end()) { + ALOGE("dpy %" PRIu64 ": invalid display handle", dpy_id); + return HWC2_ERROR_BAD_DISPLAY; + } + + return it->second.set_color_transform(color_matrix, color_hint); +} + hwc2_error_t hwc2_dev::get_client_target_support(hwc2_display_t dpy_id, uint32_t width, uint32_t height, android_pixel_format_t format, android_dataspace_t dataspace) diff --git a/hwc2/hwc2_display.cpp b/hwc2/hwc2_display.cpp index fd24e4c..0bed1e9 100644 --- a/hwc2/hwc2_display.cpp +++ b/hwc2/hwc2_display.cpp @@ -44,6 +44,8 @@ hwc2_display::hwc2_display(hwc2_display_t id, int adf_intf_fd, configs(), active_config(0), power_mode(power_mode), + color_matrix(), + color_hint(HAL_COLOR_TRANSFORM_IDENTITY), release_fence(-1), adf_intf_fd(adf_intf_fd), adf_dev(adf_dev) @@ -149,7 +151,10 @@ hwc2_error_t hwc2_display::validate_display(uint32_t *out_num_types, clear_windows(); changed_comp_types.clear(); - assign_composition(); + if (color_hint != HAL_COLOR_TRANSFORM_IDENTITY) + force_client_composition(); + else + assign_composition(); *out_num_requests = 0; *out_num_types = changed_comp_types.size(); @@ -166,6 +171,15 @@ hwc2_error_t hwc2_display::validate_display(uint32_t *out_num_types, return HWC2_ERROR_NONE; } +void hwc2_display::force_client_composition() +{ + for (auto &lyr: layers) { + hwc2_composition_t comp_type = lyr.second.get_comp_type(); + if (comp_type != HWC2_COMPOSITION_CLIENT) + changed_comp_types.emplace(lyr.second.get_id(), comp_type); + } +} + void hwc2_display::assign_composition() { hwc2_error_t ret; @@ -638,6 +652,68 @@ hwc2_error_t hwc2_display::set_active_config( return HWC2_ERROR_NONE; } +hwc2_error_t hwc2_display::get_color_modes(uint32_t *out_num_modes, + android_color_mode_t *out_modes) const +{ + *out_num_modes = 1; + if (out_modes) + *out_modes = HAL_COLOR_MODE_NATIVE; + + return HWC2_ERROR_NONE; +} + +hwc2_error_t hwc2_display::set_color_mode(android_color_mode_t mode) +{ + switch (mode) { + case HAL_COLOR_MODE_NATIVE: + return HWC2_ERROR_NONE; + case HAL_COLOR_MODE_STANDARD_BT601_625: + case HAL_COLOR_MODE_STANDARD_BT601_625_UNADJUSTED: + case HAL_COLOR_MODE_STANDARD_BT601_525: + case HAL_COLOR_MODE_STANDARD_BT601_525_UNADJUSTED: + case HAL_COLOR_MODE_STANDARD_BT709: + case HAL_COLOR_MODE_DCI_P3: + case HAL_COLOR_MODE_SRGB: + case HAL_COLOR_MODE_ADOBE_RGB: + ALOGE("dpy %" PRIu64 ": unsupported color mode", id); + return HWC2_ERROR_UNSUPPORTED; + default: + ALOGE("dpy %" PRIu64 ": invalid color mode", id); + return HWC2_ERROR_BAD_PARAMETER; + } + +} + +hwc2_error_t hwc2_display::get_hdr_capabilities(uint32_t *out_num_types, + android_hdr_t* /*out_types*/, float* /*out_max_luminance*/, + float* /*out_max_average_luminance*/, + float* /*out_min_luminance*/) const +{ + *out_num_types = 0; + return HWC2_ERROR_NONE; +} + +hwc2_error_t hwc2_display::set_color_transform(const float *color_matrix, + android_color_transform_t color_hint) +{ + switch (color_hint) { + case HAL_COLOR_TRANSFORM_IDENTITY: + case HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX: + case HAL_COLOR_TRANSFORM_VALUE_INVERSE: + case HAL_COLOR_TRANSFORM_GRAYSCALE: + case HAL_COLOR_TRANSFORM_CORRECT_PROTANOPIA: + case HAL_COLOR_TRANSFORM_CORRECT_DEUTERANOPIA: + case HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA: + memcpy(this->color_matrix.data(), color_matrix, + this->color_matrix.size()); + this->color_hint = color_hint; + return HWC2_ERROR_NONE; + default: + ALOGE("dpy %" PRIu64 ": invalid color transform hint", id); + return HWC2_ERROR_BAD_PARAMETER; + } +} + hwc2_error_t hwc2_display::get_client_target_support(uint32_t width, uint32_t height, android_pixel_format_t format, android_dataspace_t dataspace) |