diff options
author | Linux Build Service Account <lnxbuild@quicinc.com> | 2017-10-19 19:19:05 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-10-19 19:19:05 -0700 |
commit | cb1ff73e8edb9b9d105bac42abbce61390858986 (patch) | |
tree | 7464429d6fd365be523b18d05b44ceeed9bdbe12 /sdm/libs/hwc2/hwc_layers.cpp | |
parent | 59f05790f1d7efee8453bd82b71c8747cb0f17d7 (diff) | |
parent | 2c23e58cd29cff24886737f07153e3b4ec659797 (diff) | |
download | display-cb1ff73e8edb9b9d105bac42abbce61390858986.tar.gz |
Merge "hwc2: Parameter validation and bounds checks"
Diffstat (limited to 'sdm/libs/hwc2/hwc_layers.cpp')
-rw-r--r-- | sdm/libs/hwc2/hwc_layers.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp index 1881ccad..2599f18d 100644 --- a/sdm/libs/hwc2/hwc_layers.cpp +++ b/sdm/libs/hwc2/hwc_layers.cpp @@ -410,8 +410,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<uint8_t>(std::round(255.0f * alpha)); + if (layer_->plane_alpha != plane_alpha) { geometry_changes_ |= kPlaneAlpha; layer_->plane_alpha = plane_alpha; @@ -461,8 +466,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) { |