Search in sources :

Example 1 with Shader_Delegate

use of android.graphics.Shader_Delegate in project android_frameworks_base by DirtyUnicorns.

the class GcSnapshot method setShader.

private boolean setShader(Graphics2D g, Paint_Delegate paint) {
    Shader_Delegate shaderDelegate = paint.getShader();
    if (shaderDelegate != null) {
        if (shaderDelegate.isSupported()) {
            java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint();
            assert shaderPaint != null;
            if (shaderPaint != null) {
                g.setPaint(shaderPaint);
                return true;
            }
        } else {
            Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER, shaderDelegate.getSupportMessage(), null, /*throwable*/
            null);
        }
    }
    // if no shader, use the paint color
    g.setColor(new Color(paint.getColor(), true));
    return false;
}
Also used : Shader_Delegate(android.graphics.Shader_Delegate) Color(java.awt.Color)

Example 2 with Shader_Delegate

use of android.graphics.Shader_Delegate in project android_frameworks_base by ParanoidAndroid.

the class GcSnapshot method createCustomGraphics.

/**
     * Creates a new {@link Graphics2D} based on the {@link Paint} parameters.
     * <p/>The object must be disposed ({@link Graphics2D#dispose()}) after being used.
     */
private Graphics2D createCustomGraphics(Graphics2D original, Paint_Delegate paint, boolean compositeOnly, boolean forceSrcMode) {
    // make new one graphics
    Graphics2D g = (Graphics2D) original.create();
    if (paint.isAntiAliased()) {
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    }
    boolean customShader = false;
    // get the shader first, as it'll replace the color if it can be used it.
    if (compositeOnly == false) {
        Shader_Delegate shaderDelegate = paint.getShader();
        if (shaderDelegate != null) {
            if (shaderDelegate.isSupported()) {
                java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint();
                assert shaderPaint != null;
                if (shaderPaint != null) {
                    g.setPaint(shaderPaint);
                    customShader = true;
                }
            } else {
                Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER, shaderDelegate.getSupportMessage(), null, /*throwable*/
                null);
            }
        }
        // if no shader, use the paint color
        if (customShader == false) {
            g.setColor(new Color(paint.getColor(), true));
        }
        // set the stroke
        g.setStroke(paint.getJavaStroke());
    }
    // the alpha for the composite. Always opaque if the normal paint color is used since
    // it contains the alpha
    int alpha = (compositeOnly || customShader) ? paint.getAlpha() : 0xFF;
    if (forceSrcMode) {
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, (float) alpha / 255.f));
    } else {
        boolean customXfermode = false;
        Xfermode_Delegate xfermodeDelegate = paint.getXfermode();
        if (xfermodeDelegate != null) {
            if (xfermodeDelegate.isSupported()) {
                Composite composite = xfermodeDelegate.getComposite(alpha);
                assert composite != null;
                if (composite != null) {
                    g.setComposite(composite);
                    customXfermode = true;
                }
            } else {
                Bridge.getLog().fidelityWarning(LayoutLog.TAG_XFERMODE, xfermodeDelegate.getSupportMessage(), null, /*throwable*/
                null);
            }
        }
        // that will handle the alpha.
        if (customXfermode == false && alpha != 0xFF) {
            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) alpha / 255.f));
        }
    }
    return g;
}
Also used : Shader_Delegate(android.graphics.Shader_Delegate) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) Xfermode_Delegate(android.graphics.Xfermode_Delegate) Paint(android.graphics.Paint) Graphics2D(java.awt.Graphics2D)

Example 3 with Shader_Delegate

use of android.graphics.Shader_Delegate in project android_frameworks_base by AOSPA.

the class GcSnapshot method setShader.

private boolean setShader(Graphics2D g, Paint_Delegate paint) {
    Shader_Delegate shaderDelegate = paint.getShader();
    if (shaderDelegate != null) {
        if (shaderDelegate.isSupported()) {
            java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint();
            assert shaderPaint != null;
            if (shaderPaint != null) {
                g.setPaint(shaderPaint);
                return true;
            }
        } else {
            Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER, shaderDelegate.getSupportMessage(), null, /*throwable*/
            null);
        }
    }
    // if no shader, use the paint color
    g.setColor(new Color(paint.getColor(), true));
    return false;
}
Also used : Shader_Delegate(android.graphics.Shader_Delegate) Color(java.awt.Color)

Example 4 with Shader_Delegate

use of android.graphics.Shader_Delegate in project android_frameworks_base by ResurrectionRemix.

the class GcSnapshot method setShader.

private boolean setShader(Graphics2D g, Paint_Delegate paint) {
    Shader_Delegate shaderDelegate = paint.getShader();
    if (shaderDelegate != null) {
        if (shaderDelegate.isSupported()) {
            java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint();
            assert shaderPaint != null;
            if (shaderPaint != null) {
                g.setPaint(shaderPaint);
                return true;
            }
        } else {
            Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER, shaderDelegate.getSupportMessage(), null, /*throwable*/
            null);
        }
    }
    // if no shader, use the paint color
    g.setColor(new Color(paint.getColor(), true));
    return false;
}
Also used : Shader_Delegate(android.graphics.Shader_Delegate) Color(java.awt.Color)

Example 5 with Shader_Delegate

use of android.graphics.Shader_Delegate in project android_frameworks_base by crdroidandroid.

the class GcSnapshot method setShader.

private boolean setShader(Graphics2D g, Paint_Delegate paint) {
    Shader_Delegate shaderDelegate = paint.getShader();
    if (shaderDelegate != null) {
        if (shaderDelegate.isSupported()) {
            java.awt.Paint shaderPaint = shaderDelegate.getJavaPaint();
            assert shaderPaint != null;
            if (shaderPaint != null) {
                g.setPaint(shaderPaint);
                return true;
            }
        } else {
            Bridge.getLog().fidelityWarning(LayoutLog.TAG_SHADER, shaderDelegate.getSupportMessage(), null, /*throwable*/
            null);
        }
    }
    // if no shader, use the paint color
    g.setColor(new Color(paint.getColor(), true));
    return false;
}
Also used : Shader_Delegate(android.graphics.Shader_Delegate) Color(java.awt.Color)

Aggregations

Shader_Delegate (android.graphics.Shader_Delegate)6 Color (java.awt.Color)6 Paint (android.graphics.Paint)1 Xfermode_Delegate (android.graphics.Xfermode_Delegate)1 AlphaComposite (java.awt.AlphaComposite)1 Composite (java.awt.Composite)1 Graphics2D (java.awt.Graphics2D)1