aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drmhwctwo.cpp27
-rw-r--r--include/drmhwctwo.h5
2 files changed, 28 insertions, 4 deletions
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index a1f8232..fa25d6b 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -231,8 +231,16 @@ DrmHwcTwo::HwcDisplay::HwcDisplay(ResourceManager *resource_manager,
drm_(drm),
importer_(importer),
handle_(handle),
- type_(type) {
+ type_(type),
+ color_transform_hint_(HAL_COLOR_TRANSFORM_IDENTITY) {
supported(__func__);
+
+ // clang-format off
+ color_transform_matrix_ = {1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0};
+ // clang-format on
}
void DrmHwcTwo::HwcDisplay::ClearDisplay() {
@@ -791,8 +799,18 @@ HWC2::Error DrmHwcTwo::HwcDisplay::SetColorMode(int32_t mode) {
HWC2::Error DrmHwcTwo::HwcDisplay::SetColorTransform(const float *matrix,
int32_t hint) {
supported(__func__);
- // TODO: Force client composition if we get this
- return unsupported(__func__, matrix, hint);
+ if (hint < HAL_COLOR_TRANSFORM_IDENTITY ||
+ hint > HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA)
+ return HWC2::Error::BadParameter;
+
+ if (!matrix && hint == HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX)
+ return HWC2::Error::BadParameter;
+
+ color_transform_hint_ = static_cast<android_color_transform_t>(hint);
+ if (color_transform_hint_ == HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX)
+ std::copy(matrix, matrix + MATRIX_SIZE, color_transform_matrix_.begin());
+
+ return HWC2::Error::None;
}
HWC2::Error DrmHwcTwo::HwcDisplay::SetOutputBuffer(buffer_handle_t buffer,
@@ -865,7 +883,8 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
uint32_t pixops = (df.right - df.left) * (df.bottom - df.top);
if (gpu_block || avail_planes == 0 ||
!HardwareSupportsLayerType(l.second->sf_type()) ||
- !importer_->CanImportBuffer(l.second->buffer())) {
+ !importer_->CanImportBuffer(l.second->buffer()) ||
+ color_transform_hint_ != HAL_COLOR_TRANSFORM_IDENTITY) {
gpu_block = true;
gpu_pixops += pixops;
++*num_types;
diff --git a/include/drmhwctwo.h b/include/drmhwctwo.h
index 361bce9..4a10fef 100644
--- a/include/drmhwctwo.h
+++ b/include/drmhwctwo.h
@@ -22,6 +22,7 @@
#include <hardware/hwcomposer2.h>
+#include <array>
#include <map>
namespace android {
@@ -202,6 +203,8 @@ class DrmHwcTwo : public hwc2_device_t {
void AddFenceToPresentFence(int fd);
bool HardwareSupportsLayerType(HWC2::Composition comp_type);
+ constexpr static size_t MATRIX_SIZE = 16;
+
ResourceManager *resource_manager_;
DrmDevice *drm_;
DrmDisplayCompositor compositor_;
@@ -221,6 +224,8 @@ class DrmHwcTwo : public hwc2_device_t {
HwcLayer client_layer_;
UniqueFd present_fence_;
int32_t color_mode_;
+ std::array<float, MATRIX_SIZE> color_transform_matrix_;
+ android_color_transform_t color_transform_hint_;
uint32_t frame_no_ = 0;
/* Statistics */