Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2eadc00 authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

Merge "Fixing issue with larger clip bounds being specified than in the view."...

Merge "Fixing issue with larger clip bounds being specified than in the view." into nyc-dev am: 608f65b1
am: 908beb79

* commit '908beb79':
  Fixing issue with larger clip bounds being specified than in the view.

Change-Id: I646992654d5a66b45e993c5696b3dd7c0eb5f0a9
parents 308af72f 908beb79
Loading
Loading
Loading
Loading
+21 −36
Original line number Diff line number Diff line
@@ -143,43 +143,28 @@ public class TaskViewThumbnail extends View {

        int viewWidth = mTaskViewRect.width();
        int viewHeight = mTaskViewRect.height();
        if (mBitmapShader != null) {

            // We are drawing the thumbnail in the same orientation, so just fit the width
            int thumbnailWidth = (int) (mThumbnailRect.width() * mThumbnailScale);
            int thumbnailHeight = (int) (mThumbnailRect.height() * mThumbnailScale);

            if (thumbnailWidth >= viewWidth && thumbnailHeight >= viewHeight) {
                // Thumbnail fills the full task view bounds, so just draw it
                canvas.drawRoundRect(0, 0, viewWidth, viewHeight, mCornerRadius, mCornerRadius,
                        mDrawPaint);
            } else {
                // Thumbnail does not fill the full task view bounds, so just draw it and fill the
                // empty areas with the background color
                int count = canvas.save();

                // Since we only want the top corners to be rounded, draw slightly beyond the
                // thumbnail height, but clip to the thumbnail height
                canvas.clipRect(0, 0, thumbnailWidth, thumbnailHeight, Region.Op.REPLACE);
                canvas.drawRoundRect(0, 0,
                        thumbnailWidth + (thumbnailWidth < viewWidth ? mCornerRadius : 0),
                        thumbnailHeight + (thumbnailHeight < viewHeight ? mCornerRadius : 0),
                        mCornerRadius, mCornerRadius, mDrawPaint);

                // In the remaining space, draw the background color
        int thumbnailWidth = Math.min(viewWidth,
                (int) (mThumbnailRect.width() * mThumbnailScale));
        int thumbnailHeight = Math.min(viewHeight,
                (int) (mThumbnailRect.height() * mThumbnailScale));
        if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) {
            // Draw the background, there will be some small overdraw with the thumbnail
            if (thumbnailWidth < viewWidth) {
                    canvas.clipRect(thumbnailWidth, 0, viewWidth, viewHeight, Region.Op.REPLACE);
                // Portrait thumbnail on a landscape task view
                canvas.drawRoundRect(Math.max(0, thumbnailWidth - mCornerRadius), 0,
                            viewWidth, viewHeight, mCornerRadius, mCornerRadius, mBgFillPaint);
                        viewWidth, viewHeight,
                        mCornerRadius, mCornerRadius, mBgFillPaint);
            }
                if (thumbnailWidth > 0 && thumbnailHeight < viewHeight) {
                    canvas.clipRect(0, thumbnailHeight, viewWidth, viewHeight, Region.Op.REPLACE);
            if (thumbnailHeight < viewHeight) {
                // Landscape thumbnail on a portrait task view
                canvas.drawRoundRect(0, Math.max(0, thumbnailHeight - mCornerRadius),
                            viewWidth, viewHeight, mCornerRadius, mCornerRadius, mBgFillPaint);
                        viewWidth, viewHeight,
                        mCornerRadius, mCornerRadius, mBgFillPaint);
            }

                canvas.restoreToCount(count);
            }
            // Draw the thumbnail
            canvas.drawRoundRect(0, 0, thumbnailWidth, thumbnailHeight,
                    mCornerRadius, mCornerRadius, mDrawPaint);
        } else {
            canvas.drawRoundRect(0, 0, viewWidth, viewHeight, mCornerRadius, mCornerRadius,
                    mBgFillPaint);