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

Commit e222e359 authored by Chris Craik's avatar Chris Craik
Browse files

Disable shadow casting for transparent BitmapDrawables

bug:17013977
Change-Id: I26328c21360432bb34d3f19858dfdc0e6aede057
parent fdee9b44
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.graphics.drawable;

import android.annotation.NonNull;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
@@ -27,6 +28,7 @@ import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
@@ -597,6 +599,16 @@ public class BitmapDrawable extends Drawable {
        mOpticalInsets = Insets.of(left, top, right, bottom);
    }

    @Override
    public void getOutline(@NonNull Outline outline) {
        super.getOutline(outline);
        if (mBitmapState.mBitmap.hasAlpha()) {
            // Bitmaps with alpha can't report a non-0 alpha,
            // since they may not fill their rectangular bounds
            outline.setAlpha(0.0f);
        }
    }

    @Override
    public void setAlpha(int alpha) {
        final int oldAlpha = mBitmapState.mPaint.getAlpha();