From 2c23e58cd29cff24886737f07153e3b4ec659797 Mon Sep 17 00:00:00 2001 From: Varun Arora Date: Tue, 10 Oct 2017 15:07:13 -0700 Subject: hwc2: Parameter validation and bounds checks - Introduce use of GetDozeSupport Change-Id: Ic7edcd14b0c390fbd58f6be05b983a40b75c90eb CRs-Fixed: 2114346 --- sdm/libs/hwc2/hwc_layers.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sdm/libs/hwc2/hwc_layers.cpp') diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp index fee67b44..13a67cf5 100644 --- a/sdm/libs/hwc2/hwc_layers.cpp +++ b/sdm/libs/hwc2/hwc_layers.cpp @@ -406,8 +406,13 @@ HWC2::Error HWCLayer::SetCursorPosition(int32_t x, int32_t y) { } HWC2::Error HWCLayer::SetLayerPlaneAlpha(float alpha) { - // Conversion of float alpha in range 0.0 to 1.0 similar to the HWC Adapter + if (alpha < 0.0f || alpha > 1.0f) { + return HWC2::Error::BadParameter; + } + + // Conversion of float alpha in range 0.0 to 1.0 similar to the HWC Adapter uint8_t plane_alpha = static_cast(std::round(255.0f * alpha)); + if (layer_->plane_alpha != plane_alpha) { geometry_changes_ |= kPlaneAlpha; layer_->plane_alpha = plane_alpha; @@ -457,8 +462,10 @@ HWC2::Error HWCLayer::SetLayerTransform(HWC2::Transform transform) { layer_transform.flip_vertical = true; break; case HWC2::Transform::None: - // do nothing break; + default: + // bad transform + return HWC2::Error::BadParameter; } if (layer_transform_ != layer_transform) { -- cgit v1.2.3