aboutsummaryrefslogtreecommitdiff
path: root/drm/DrmPlane.cpp
diff options
context:
space:
mode:
authorMatvii Zorin <matvii.zorin@globallogic.com>2021-01-31 14:45:05 +0200
committerMatvii Zorin <matvii.zorin@globallogic.com>2021-04-06 12:46:22 +0300
commit67a89d33b82caf45997bcdd3ca7690b5bd3ebef5 (patch)
treea1e4be71aa72b954dd082de36c8026e6e9ae6c18 /drm/DrmPlane.cpp
parentb865227a2528d8a9d5ada90d1409dda47094b602 (diff)
downloaddrm_hwcomposer-67a89d33b82caf45997bcdd3ca7690b5bd3ebef5.tar.gz
drm_hwcomposer: Move ValidatePlane method into DrmPlane
It is more common to validate the layer for the proper object. Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Diffstat (limited to 'drm/DrmPlane.cpp')
-rw-r--r--drm/DrmPlane.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/drm/DrmPlane.cpp b/drm/DrmPlane.cpp
index 2967a7a..b841189 100644
--- a/drm/DrmPlane.cpp
+++ b/drm/DrmPlane.cpp
@@ -164,6 +164,57 @@ bool DrmPlane::GetCrtcSupported(const DrmCrtc &crtc) const {
return ((1 << crtc.pipe()) & possible_crtc_mask_) != 0;
}
+bool DrmPlane::IsValidForLayer(DrmHwcLayer *layer) {
+ if ((rotation_property_.id() == 0) &&
+ layer->transform != DrmHwcTransform::kIdentity) {
+ ALOGV("Rotation is not supported on plane %d", id_);
+ return false;
+ }
+
+ if (alpha_property_.id() == 0 && layer->alpha != 0xffff) {
+ ALOGV("Alpha is not supported on plane %d", id_);
+ return false;
+ }
+
+ if (blend_property_.id() == 0) {
+ if ((layer->blending != DrmHwcBlending::kNone) &&
+ (layer->blending != DrmHwcBlending::kPreMult)) {
+ ALOGV("Blending is not supported on plane %d", id_);
+ return false;
+ }
+ } else {
+ int ret = 0;
+ uint64_t blend = 0;
+
+ switch (layer->blending) {
+ case DrmHwcBlending::kPreMult:
+ std::tie(blend,
+ ret) = blend_property_.GetEnumValueWithName("Pre-multiplied");
+ break;
+ case DrmHwcBlending::kCoverage:
+ std::tie(blend, ret) = blend_property_.GetEnumValueWithName("Coverage");
+ break;
+ case DrmHwcBlending::kNone:
+ default:
+ std::tie(blend, ret) = blend_property_.GetEnumValueWithName("None");
+ break;
+ }
+ if (ret) {
+ ALOGV("Expected a valid blend mode on plane %d", id_);
+ return false;
+ }
+ }
+
+ uint32_t format = layer->buffer->format;
+ if (!IsFormatSupported(format)) {
+ ALOGV("Plane %d does not supports %c%c%c%c format", id_, format,
+ format >> 8, format >> 16, format >> 24);
+ return false;
+ }
+
+ return true;
+}
+
uint32_t DrmPlane::type() const {
return type_;
}