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

Commit 54c1c0db authored by Deepanshu Gupta's avatar Deepanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "LayoutLib: Support PorterDuffColorFilter" into lmp-preview-dev

parents 083f2714 f2af1f5d
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -627,8 +627,7 @@ public final class Canvas_Delegate {
                // set the color
                graphics.setColor(new Color(color, true /*alpha*/));

                Composite composite = PorterDuffXfermode_Delegate.getComposite(
                        PorterDuffXfermode_Delegate.getPorterDuffMode(mode), 0xFF);
                Composite composite = PorterDuffXfermode_Delegate.getComposite(mode, 0xFF);
                if (composite != null) {
                    graphics.setComposite(composite);
                }
+11 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.graphics;
import com.android.layoutlib.bridge.impl.DelegateManager;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;

import java.awt.Graphics2D;

/**
 * Delegate implementing the native methods of android.graphics.ColorFilter
 *
@@ -50,9 +52,17 @@ public abstract class ColorFilter_Delegate {
        return sManager.getDelegate(nativeShader);
    }

    public abstract boolean isSupported();
    public abstract String getSupportMessage();

    public boolean isSupported() {
        return false;
    }

    public void applyFilter(Graphics2D g, int width, int height) {
        // This should never be called directly. If supported, the sub class should override this.
        assert false;
    }

    // ---- native methods ----

    @LayoutlibDelegate
+0 −5
Original line number Diff line number Diff line
@@ -42,11 +42,6 @@ public class ColorMatrixColorFilter_Delegate extends ColorFilter_Delegate {

    // ---- Public Helper methods ----

    @Override
    public boolean isSupported() {
        return false;
    }

    @Override
    public String getSupportMessage() {
        return "ColorMatrix Color Filters are not supported.";
+0 −5
Original line number Diff line number Diff line
@@ -42,11 +42,6 @@ public class LightingColorFilter_Delegate extends ColorFilter_Delegate {

    // ---- Public Helper methods ----

    @Override
    public boolean isSupported() {
        return false;
    }

    @Override
    public String getSupportMessage() {
        return "Lighting Color Filters are not supported.";
+4 −4
Original line number Diff line number Diff line
@@ -827,8 +827,8 @@ public class Paint_Delegate {

        delegate.mColorFilter = ColorFilter_Delegate.getDelegate(filter);

        // since none of those are supported, display a fidelity warning right away
        if (delegate.mColorFilter != null && delegate.mColorFilter.isSupported() == false) {
        // Log warning if it's not supported.
        if (delegate.mColorFilter != null && !delegate.mColorFilter.isSupported()) {
            Bridge.getLog().fidelityWarning(LayoutLog.TAG_COLORFILTER,
                    delegate.mColorFilter.getSupportMessage(), null, null /*data*/);
        }
@@ -873,7 +873,7 @@ public class Paint_Delegate {
        delegate.mMaskFilter = MaskFilter_Delegate.getDelegate(maskfilter);

        // since none of those are supported, display a fidelity warning right away
        if (delegate.mMaskFilter != null && delegate.mMaskFilter.isSupported() == false) {
        if (delegate.mMaskFilter != null && !delegate.mMaskFilter.isSupported()) {
            Bridge.getLog().fidelityWarning(LayoutLog.TAG_MASKFILTER,
                    delegate.mMaskFilter.getSupportMessage(), null, null /*data*/);
        }
@@ -906,7 +906,7 @@ public class Paint_Delegate {
        delegate.mRasterizer = Rasterizer_Delegate.getDelegate(rasterizer);

        // since none of those are supported, display a fidelity warning right away
        if (delegate.mRasterizer != null && delegate.mRasterizer.isSupported() == false) {
        if (delegate.mRasterizer != null && !delegate.mRasterizer.isSupported()) {
            Bridge.getLog().fidelityWarning(LayoutLog.TAG_RASTERIZER,
                    delegate.mRasterizer.getSupportMessage(), null, null /*data*/);
        }
Loading