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

Commit a6246b06 authored by Sebastián Franco's avatar Sebastián Franco Committed by Automerger Merge Worker
Browse files

Merge "Revert "Combining the Thumbnail bitmap with the background to fix...

Merge "Revert "Combining the Thumbnail bitmap with the background to fix background spilling in the front."" into tm-dev am: da297fb0

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/17299099

Change-Id: I30ffda32e94e7881d65bfd44d491df8d5c5a1c02
parents 7ab44c3a da297fb0
Loading
Loading
Loading
Loading
+14 −19
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ import androidx.core.graphics.ColorUtils;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Utilities;
import com.android.launcher3.icons.BitmapRenderer;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SystemUiController;
import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
@@ -162,23 +161,6 @@ public class TaskThumbnailView extends View {
        setThumbnail(task, thumbnailData, true /* refreshNow */);
    }

    /**
     * By combining the two in a single bitmap then we only have to do a single draw
     * call in the onDraw function. Also, this fixes a bug where the background was
     * visible in the corners because of anti-aliasing.
     */
    public Bitmap combineThumbnailAndBackground(Bitmap bm) {
        return BitmapRenderer.createHardwareBitmap(bm.getWidth(), bm.getHeight(), c -> {
            final boolean drawBackgroundOnly = mTask == null || mTask.isLocked;
            if (drawBackgroundOnly) {
                c.drawPaint(mBackgroundPaint);
            } else {
                c.drawPaint(mBackgroundPaint);
                c.drawBitmap(bm, 0, 0, null);
            }
        });
    }

    /** Updates the shader, paint, matrix to redraw. */
    public void refresh() {
        refresh(false);
@@ -191,7 +173,6 @@ public class TaskThumbnailView extends View {
    private void refresh(boolean shouldRefreshOverlay) {
        if (mThumbnailData != null && mThumbnailData.thumbnail != null) {
            Bitmap bm = mThumbnailData.thumbnail;
            bm = combineThumbnailAndBackground(bm);
            bm.prepareToDraw();
            mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
            mPaint.setShader(mBitmapShader);
@@ -213,6 +194,7 @@ public class TaskThumbnailView extends View {
     * <p>
     * If dimAlpha is 0, no dimming is applied; if dimAlpha is 1, the thumbnail will be the
     * extracted background color.
     *
     */
    public void setDimAlpha(float dimAlpha) {
        mDimAlpha = dimAlpha;
@@ -314,6 +296,18 @@ public class TaskThumbnailView extends View {
                return;
            }
        }

        // Always draw the background since the snapshots might be translucent or partially empty
        // (For example, tasks been reparented out of dismissing split root when drag-to-dismiss
        // split screen).
        canvas.drawRoundRect(x, y, width, height, cornerRadius, cornerRadius, mBackgroundPaint);

        final boolean drawBackgroundOnly = mTask == null || mTask.isLocked || mBitmapShader == null
                || mThumbnailData == null;
        if (drawBackgroundOnly) {
            return;
        }

        canvas.drawRoundRect(x, y, width, height, cornerRadius, cornerRadius, mPaint);
    }

@@ -344,6 +338,7 @@ public class TaskThumbnailView extends View {

    private void updateThumbnailPaintFilter() {
        ColorFilter filter = getColorFilter(mDimAlpha);
        mBackgroundPaint.setColorFilter(filter);
        int alpha = (int) (mDimAlpha * 255);
        mDimmingPaintAfterClearing.setAlpha(alpha);
        if (mBitmapShader != null) {