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

Commit 6d8eb89d authored by John Reck's avatar John Reck
Browse files

Fast-path Drawable#setColorFilter

Some apps really like to call setColorFilter with the
same parameters, so check if there's anything to set
before creating a color filter

Change-Id: I20b8431123f9e6a333b69771b5f5f3eb7e566034
parent e94cc880
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -573,6 +573,12 @@ public abstract class Drawable {
     * </p>
     */
    public void setColorFilter(@ColorInt int color, @NonNull PorterDuff.Mode mode) {
        if (getColorFilter() instanceof PorterDuffColorFilter) {
            PorterDuffColorFilter existing = (PorterDuffColorFilter) getColorFilter();
            if (existing.getColor() == color && existing.getMode() == mode) {
                return;
            }
        }
        setColorFilter(new PorterDuffColorFilter(color, mode));
    }