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

Commit b7b877a4 authored by Xavier Ducrohet's avatar Xavier Ducrohet Committed by Android Git Automerger
Browse files

am 0a98226e: Merge 9d76581f from honeycomb. do not merge.

* commit '0a98226e':
  Merge 9d76581f from honeycomb. do not merge.
parents a82a219a 0a98226e
Loading
Loading
Loading
Loading
+48 −25
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Arc2D;
import java.awt.image.BufferedImage;
import java.util.List;

@@ -297,7 +298,7 @@ public final class Canvas_Delegate {
            Paint paint) {
        draw(thisCanvas.mNativeCanvas, paint.mNativePaint, false /*compositeOnly*/,
                false /*forceSrcMode*/, new GcSnapshot.Drawable() {
                    public void draw(Graphics2D graphics, Paint_Delegate paint) {
                    public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
                        for (int i = 0 ; i < count ; i += 4) {
                            graphics.drawLine((int)pts[i + offset], (int)pts[i + offset + 1],
                                    (int)pts[i + offset + 2], (int)pts[i + offset + 3]);
@@ -321,13 +322,13 @@ public final class Canvas_Delegate {
            Canvas_Delegate newDelegate = new Canvas_Delegate(bitmapDelegate);

            return sManager.addNewDelegate(newDelegate);
        } else {
        }

        // create a new Canvas_Delegate and return its new native int.
        Canvas_Delegate newDelegate = new Canvas_Delegate();

        return sManager.addNewDelegate(newDelegate);
    }
    }

    @LayoutlibDelegate
    /*package*/ static int initGL() {
@@ -668,7 +669,7 @@ public final class Canvas_Delegate {

        draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
                new GcSnapshot.Drawable() {
                    public void draw(Graphics2D graphics, Paint_Delegate paint) {
                    public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
                        graphics.drawLine((int)startX, (int)startY, (int)stopX, (int)stopY);
                    }
        });
@@ -686,8 +687,8 @@ public final class Canvas_Delegate {

        draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
                new GcSnapshot.Drawable() {
                    public void draw(Graphics2D graphics, Paint_Delegate paint) {
                        int style = paint.getStyle();
                    public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
                        int style = paintDelegate.getStyle();

                        // draw
                        if (style == Paint.Style.FILL.nativeInt ||
@@ -710,8 +711,8 @@ public final class Canvas_Delegate {
        if (oval.right > oval.left && oval.bottom > oval.top) {
            draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
                    new GcSnapshot.Drawable() {
                        public void draw(Graphics2D graphics, Paint_Delegate paint) {
                            int style = paint.getStyle();
                        public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
                            int style = paintDelegate.getStyle();

                            // draw
                            if (style == Paint.Style.FILL.nativeInt ||
@@ -740,10 +741,32 @@ public final class Canvas_Delegate {

    @LayoutlibDelegate
    /*package*/ static void native_drawArc(int nativeCanvas,
            RectF oval, float startAngle, float sweep, boolean useCenter, int paint) {
        // FIXME
        Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
                "Canvas.drawArc is not supported.", null, null /*data*/);
            final RectF oval, final float startAngle, final float sweep,
            final boolean useCenter, int paint) {
        if (oval.right > oval.left && oval.bottom > oval.top) {
            draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
                    new GcSnapshot.Drawable() {
                        public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
                            int style = paintDelegate.getStyle();

                            Arc2D.Float arc = new Arc2D.Float(
                                    oval.left, oval.top, oval.width(), oval.height(),
                                    -startAngle, -sweep,
                                    useCenter ? Arc2D.PIE : Arc2D.OPEN);

                            // draw
                            if (style == Paint.Style.FILL.nativeInt ||
                                    style == Paint.Style.FILL_AND_STROKE.nativeInt) {
                                graphics.fill(arc);
                            }

                            if (style == Paint.Style.STROKE.nativeInt ||
                                    style == Paint.Style.FILL_AND_STROKE.nativeInt) {
                                graphics.draw(arc);
                            }
                        }
            });
        }
    }

    @LayoutlibDelegate
@@ -752,8 +775,8 @@ public final class Canvas_Delegate {

        draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
                new GcSnapshot.Drawable() {
                    public void draw(Graphics2D graphics, Paint_Delegate paint) {
                        int style = paint.getStyle();
                    public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
                        int style = paintDelegate.getStyle();

                        // draw
                        if (style == Paint.Style.FILL.nativeInt ||
@@ -784,9 +807,9 @@ public final class Canvas_Delegate {

        draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
                new GcSnapshot.Drawable() {
                    public void draw(Graphics2D graphics, Paint_Delegate paint) {
                    public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
                        Shape shape = pathDelegate.getJavaShape();
                        int style = paint.getStyle();
                        int style = paintDelegate.getStyle();

                        if (style == Paint.Style.FILL.nativeInt ||
                                style == Paint.Style.FILL_AND_STROKE.nativeInt) {
@@ -965,23 +988,23 @@ public final class Canvas_Delegate {
            final float startX, final float startY, int paint) {
        draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
                new GcSnapshot.Drawable() {
            public void draw(Graphics2D graphics, Paint_Delegate paint) {
            public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
                // WARNING: the logic in this method is similar to Paint_Delegate.measureText.
                // Any change to this method should be reflected in Paint.measureText
                // Paint.TextAlign indicates how the text is positioned relative to X.
                // LEFT is the default and there's nothing to do.
                float x = startX;
                float y = startY;
                if (paint.getTextAlign() != Paint.Align.LEFT.nativeInt) {
                    float m = paint.measureText(text, index, count);
                    if (paint.getTextAlign() == Paint.Align.CENTER.nativeInt) {
                if (paintDelegate.getTextAlign() != Paint.Align.LEFT.nativeInt) {
                    float m = paintDelegate.measureText(text, index, count);
                    if (paintDelegate.getTextAlign() == Paint.Align.CENTER.nativeInt) {
                        x -= m / 2;
                    } else if (paint.getTextAlign() == Paint.Align.RIGHT.nativeInt) {
                    } else if (paintDelegate.getTextAlign() == Paint.Align.RIGHT.nativeInt) {
                        x -= m;
                    }
                }

                List<FontInfo> fonts = paint.getFonts();
                List<FontInfo> fonts = paintDelegate.getFonts();

                if (fonts.size() > 0) {
                    FontInfo mainFont = fonts.get(0);
+4 −5
Original line number Diff line number Diff line
@@ -365,7 +365,7 @@ public final class Path_Delegate {
        // because x/y is the center of the circle, need to offset this by the radius
        pathDelegate.mPath.append(new Arc2D.Float(
                oval.left, oval.top, oval.width(), oval.height(),
                startAngle, sweepAngle, Arc2D.OPEN), false);
                -startAngle, -sweepAngle, Arc2D.OPEN), false);
    }

    @LayoutlibDelegate
@@ -707,10 +707,9 @@ public final class Path_Delegate {
     *                    mod 360.
     * @param forceMoveTo If true, always begin a new contour with the arc
     */
    private void arcTo(RectF oval, float startAngle, float sweepAngle,
                      boolean forceMoveTo) {
        Arc2D arc = new Arc2D.Float(oval.left, oval.top, oval.width(), oval.height(), startAngle,
                sweepAngle, Arc2D.OPEN);
    private void arcTo(RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) {
        Arc2D arc = new Arc2D.Float(oval.left, oval.top, oval.width(), oval.height(), -startAngle,
                -sweepAngle, Arc2D.OPEN);
        mPath.append(arc, true /*connect*/);

        resetLastPointFromPath();