summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Derek Sollenberger <djsollen@google.com> 2021-05-18 18:19:13 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-05-18 18:19:13 +0000
commitceca281c0818b22d2e3db5b823d659d11445d63b (patch)
tree5ea81fb130b6cabeaf86c60ecb9e6f3a7c8c811d
parent82fb77a8139ff24da6f04f0ccd95cc38b35e81ba (diff)
parent4f9959fc3a71ff39bf582d3d127e250322731a1d (diff)
Merge "Avoid clipping for common SysUI interactions with roundedCorners." into sc-dev
-rw-r--r--libs/renderengine/skia/SkiaGLRenderEngine.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.cpp b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
index 8059bc16a0..6cc3d37aba 100644
--- a/libs/renderengine/skia/SkiaGLRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
@@ -1101,8 +1101,8 @@ inline std::pair<SkRRect, SkRRect> SkiaGLRenderEngine::getBoundsAndClip(
SkRRect clip;
if (cornerRadius > 0) {
- // it the crop and the bounds are equivalent then we don't need a clip
- if (bounds == crop) {
+ // it the crop and the bounds are equivalent or there is no crop then we don't need a clip
+ if (bounds == crop || crop.isEmpty()) {
return {SkRRect::MakeRectXY(bounds, cornerRadius, cornerRadius), clip};
}
@@ -1116,34 +1116,47 @@ inline std::pair<SkRRect, SkRRect> SkiaGLRenderEngine::getBoundsAndClip(
const auto insetCrop = crop.makeInset(cornerRadius, cornerRadius);
+ const bool leftEqual = bounds.fLeft == crop.fLeft;
+ const bool topEqual = bounds.fTop == crop.fTop;
+ const bool rightEqual = bounds.fRight == crop.fRight;
+ const bool bottomEqual = bounds.fBottom == crop.fBottom;
+
// compute the UpperLeft corner radius
- if (bounds.fLeft == crop.fLeft && bounds.fTop == crop.fTop) {
+ if (leftEqual && topEqual) {
radii[0].set(cornerRadius, cornerRadius);
- } else if (bounds.fLeft > insetCrop.fLeft && bounds.fTop > insetCrop.fTop) {
+ } else if ((leftEqual && bounds.fTop >= insetCrop.fTop) ||
+ (topEqual && bounds.fLeft >= insetCrop.fLeft) ||
+ insetCrop.contains(bounds.fLeft, bounds.fTop)) {
radii[0].set(0, 0);
} else {
intersectionIsRoundRect = false;
}
// compute the UpperRight corner radius
- if (bounds.fRight == crop.fRight && bounds.fTop == crop.fTop) {
+ if (rightEqual && topEqual) {
radii[1].set(cornerRadius, cornerRadius);
- } else if (bounds.fRight < insetCrop.fRight && bounds.fTop > insetCrop.fTop) {
+ } else if ((rightEqual && bounds.fTop >= insetCrop.fTop) ||
+ (topEqual && bounds.fRight <= insetCrop.fRight) ||
+ insetCrop.contains(bounds.fRight, bounds.fTop)) {
radii[1].set(0, 0);
} else {
intersectionIsRoundRect = false;
}
// compute the BottomRight corner radius
- if (bounds.fRight == crop.fRight && bounds.fBottom == crop.fBottom) {
+ if (rightEqual && bottomEqual) {
radii[2].set(cornerRadius, cornerRadius);
- } else if (bounds.fRight < insetCrop.fRight && bounds.fBottom < insetCrop.fBottom) {
+ } else if ((rightEqual && bounds.fBottom <= insetCrop.fBottom) ||
+ (bottomEqual && bounds.fRight <= insetCrop.fRight) ||
+ insetCrop.contains(bounds.fRight, bounds.fBottom)) {
radii[2].set(0, 0);
} else {
intersectionIsRoundRect = false;
}
// compute the BottomLeft corner radius
- if (bounds.fLeft == crop.fLeft && bounds.fBottom == crop.fBottom) {
+ if (leftEqual && bottomEqual) {
radii[3].set(cornerRadius, cornerRadius);
- } else if (bounds.fLeft > insetCrop.fLeft && bounds.fBottom < insetCrop.fBottom) {
+ } else if ((leftEqual && bounds.fBottom <= insetCrop.fBottom) ||
+ (bottomEqual && bounds.fLeft >= insetCrop.fLeft) ||
+ insetCrop.contains(bounds.fLeft, bounds.fBottom)) {
radii[3].set(0, 0);
} else {
intersectionIsRoundRect = false;