From 03a6821950bc85d5ae36dbd5fcc8d22b7e0c1d72 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 7 Feb 2017 13:58:52 +0200 Subject: PlaneType to bitmask --- kms++/inc/kms++/plane.h | 6 +++--- kms++/src/plane.cpp | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/kms++/inc/kms++/plane.h b/kms++/inc/kms++/plane.h index d50e539..26f3951 100644 --- a/kms++/inc/kms++/plane.h +++ b/kms++/inc/kms++/plane.h @@ -7,9 +7,9 @@ namespace kms enum class PlaneType { - Overlay = 0, - Primary = 1, - Cursor = 2, + Overlay = 1 << 0, + Primary = 1 << 1, + Cursor = 1 << 2, }; struct PlanePriv; diff --git a/kms++/src/plane.cpp b/kms++/src/plane.cpp index 10aaeda..e19910b 100644 --- a/kms++/src/plane.cpp +++ b/kms++/src/plane.cpp @@ -50,10 +50,20 @@ bool Plane::supports_format(PixelFormat fmt) const PlaneType Plane::plane_type() const { - if (card().has_has_universal_planes()) - return (PlaneType)get_prop_value("type"); - else + if (card().has_has_universal_planes()) { + switch (get_prop_value("type")) { + case DRM_PLANE_TYPE_OVERLAY: + return PlaneType::Overlay; + case DRM_PLANE_TYPE_PRIMARY: + return PlaneType::Primary; + case DRM_PLANE_TYPE_CURSOR: + return PlaneType::Cursor; + default: + throw invalid_argument("Bad plane type"); + } + } else { return PlaneType::Overlay; + } } vector Plane::get_formats() const -- cgit v1.2.3