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

Commit b6e53f48 authored by Xavier Ducrohet's avatar Xavier Ducrohet
Browse files

LayoutLib: add a few misc implementations.

Change-Id: I586f1d5ecc4f254fc04ea1171eb499d06ac592eb
parent 46a32924
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.impl.DelegateManager;
import com.android.layoutlib.bridge.impl.GcSnapshot;

import android.graphics.Bitmap.Config;
import android.graphics.Paint_Delegate.FontInfo;
import android.text.TextUtils;

@@ -98,8 +99,13 @@ public final class Canvas_Delegate {
    // ---- native methods ----

    /*package*/ static boolean isOpaque(Canvas thisCanvas) {
        // FIXME
        throw new UnsupportedOperationException();
        // get the delegate from the native int.
        Canvas_Delegate canvasDelegate = sManager.getDelegate(thisCanvas.mNativeCanvas);
        if (canvasDelegate == null) {
            return false;
        }

        return canvasDelegate.mBitmap.getConfig() == Config.RGB_565;
    }

    /*package*/ static int getWidth(Canvas thisCanvas) {
@@ -511,8 +517,19 @@ public final class Canvas_Delegate {
    }

    /*package*/ static void native_getCTM(int canvas, int matrix) {
        // FIXME
        throw new UnsupportedOperationException();
        // get the delegate from the native int.
        Canvas_Delegate canvasDelegate = sManager.getDelegate(canvas);
        if (canvasDelegate == null) {
            return;
        }

        Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(matrix);
        if (matrixDelegate == null) {
            return;
        }

        AffineTransform transform = canvasDelegate.getSnapshot().getTransform();
        matrixDelegate.set(Matrix_Delegate.makeValues(transform));
    }

    /*package*/ static boolean native_quickReject(int nativeCanvas,
+14 −2
Original line number Diff line number Diff line
@@ -83,6 +83,14 @@ public final class Matrix_Delegate {
        System.arraycopy(matrix.mValues, 0, mValues, 0, MATRIX_SIZE);
    }

    /**
     * Sets the content of the matrix with the content of another matrix represented as an array
     * of values.
     */
    public void set(float[] values) {
        System.arraycopy(values, 0, mValues, 0, MATRIX_SIZE);
    }

    /**
     * Resets the matrix to be the identity matrix.
     */
@@ -105,7 +113,7 @@ public final class Matrix_Delegate {
        return true;
    }

    public static Matrix_Delegate make(AffineTransform matrix) {
    public static float[] makeValues(AffineTransform matrix) {
        float[] values = new float[MATRIX_SIZE];
        values[0] = (float) matrix.getScaleX();
        values[1] = (float) matrix.getShearX();
@@ -117,7 +125,11 @@ public final class Matrix_Delegate {
        values[7] = 0.f;
        values[8] = 1.f;

        return new Matrix_Delegate(values);
        return values;
    }

    public static Matrix_Delegate make(AffineTransform matrix) {
        return new Matrix_Delegate(makeValues(matrix));
    }

    public boolean mapRect(RectF dst, RectF src) {
+1 −1
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ public class Paint_Delegate {
    /*package*/ static void nSetShadowLayer(Paint thisPaint, float radius, float dx, float dy,
            int color) {
        // FIXME
        throw new UnsupportedOperationException();
        Bridge.getLog().fidelityWarning(null, "Paint.setShadowLayer is not supported.", null);
    }

    /*package*/ static float getTextSize(Paint thisPaint) {
+12 −18
Original line number Diff line number Diff line
@@ -237,8 +237,7 @@ public final class Path_Delegate {
        pathDelegate.quadTo(x1, y1, x2, y2);
    }

    /*package*/ static void native_rQuadTo(int nPath, float dx1, float dy1,
                                              float dx2, float dy2) {
    /*package*/ static void native_rQuadTo(int nPath, float dx1, float dy1, float dx2, float dy2) {
        Path_Delegate pathDelegate = sManager.getDelegate(nPath);
        if (pathDelegate == null) {
            return;
@@ -295,8 +294,8 @@ public final class Path_Delegate {
        pathDelegate.addRect(rect.left, rect.top, rect.right, rect.bottom, dir);
    }

    /*package*/ static void native_addRect(int nPath, float left, float top,
                                            float right, float bottom, int dir) {
    /*package*/ static void native_addRect(int nPath,
            float left, float top, float right, float bottom, int dir) {
        Path_Delegate pathDelegate = sManager.getDelegate(nPath);
        if (pathDelegate == null) {
            return;
@@ -310,8 +309,7 @@ public final class Path_Delegate {
        throw new UnsupportedOperationException();
    }

    /*package*/ static void native_addCircle(int nPath, float x, float y,
                                                float radius, int dir) {
    /*package*/ static void native_addCircle(int nPath, float x, float y, float radius, int dir) {
        // FIXME
        throw new UnsupportedOperationException();
    }
@@ -328,21 +326,18 @@ public final class Path_Delegate {
        throw new UnsupportedOperationException();
    }

    /*package*/ static void native_addRoundRect(int nPath, RectF r,
                                                   float[] radii, int dir) {
    /*package*/ static void native_addRoundRect(int nPath, RectF r, float[] radii, int dir) {
        // FIXME
        throw new UnsupportedOperationException();
    }

    /*package*/ static void native_addPath(int nPath, int src, float dx,
                                              float dy) {
    /*package*/ static void native_addPath(int nPath, int src, float dx, float dy) {
        // FIXME
        throw new UnsupportedOperationException();
    }

    /*package*/ static void native_addPath(int nPath, int src) {
        // FIXME
        throw new UnsupportedOperationException();
        native_addPath(nPath, src, 0, 0);
    }

    /*package*/ static void native_addPath(int nPath, int src, int matrix) {
@@ -350,8 +345,7 @@ public final class Path_Delegate {
        throw new UnsupportedOperationException();
    }

    /*package*/ static void native_offset(int nPath, float dx, float dy,
                                             int dst_path) {
    /*package*/ static void native_offset(int nPath, float dx, float dy, int dst_path) {
        Path_Delegate pathDelegate = sManager.getDelegate(nPath);
        if (pathDelegate == null) {
            return;