Search in sources :

Example 1 with GcSnapshot

use of com.android.layoutlib.bridge.impl.GcSnapshot in project android_frameworks_base by ResurrectionRemix.

the class Canvas_Delegate method native_setMatrix.

@LayoutlibDelegate
public static void native_setMatrix(long nCanvas, long nMatrix) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
    if (canvasDelegate == null) {
        return;
    }
    Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
    if (matrixDelegate == null) {
        return;
    }
    // get the current top graphics2D object.
    GcSnapshot snapshot = canvasDelegate.getSnapshot();
    // get the AffineTransform of the given matrix
    AffineTransform matrixTx = matrixDelegate.getAffineTransform();
    // give it to the graphics2D as a new matrix replacing all previous transform
    snapshot.setTransform(matrixTx);
    if (matrixDelegate.hasPerspective()) {
        assert false;
        Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Canvas#setMatrix(android.graphics.Matrix) only " + "supports affine transformations.", null, null);
    }
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GcSnapshot(com.android.layoutlib.bridge.impl.GcSnapshot) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 2 with GcSnapshot

use of com.android.layoutlib.bridge.impl.GcSnapshot in project android_frameworks_base by DirtyUnicorns.

the class Canvas_Delegate method native_concat.

@LayoutlibDelegate
public static void native_concat(long nCanvas, long nMatrix) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
    if (canvasDelegate == null) {
        return;
    }
    Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
    if (matrixDelegate == null) {
        return;
    }
    // get the current top graphics2D object.
    GcSnapshot snapshot = canvasDelegate.getSnapshot();
    // get its current matrix
    AffineTransform currentTx = snapshot.getTransform();
    // get the AffineTransform of the given matrix
    AffineTransform matrixTx = matrixDelegate.getAffineTransform();
    // combine them so that the given matrix is applied after.
    currentTx.concatenate(matrixTx);
    // give it to the graphics2D as a new matrix replacing all previous transform
    snapshot.setTransform(currentTx);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GcSnapshot(com.android.layoutlib.bridge.impl.GcSnapshot) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 3 with GcSnapshot

use of com.android.layoutlib.bridge.impl.GcSnapshot in project platform_frameworks_base by android.

the class Canvas_Delegate method native_setMatrix.

@LayoutlibDelegate
public static void native_setMatrix(long nCanvas, long nMatrix) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
    if (canvasDelegate == null) {
        return;
    }
    Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
    if (matrixDelegate == null) {
        return;
    }
    // get the current top graphics2D object.
    GcSnapshot snapshot = canvasDelegate.getSnapshot();
    // get the AffineTransform of the given matrix
    AffineTransform matrixTx = matrixDelegate.getAffineTransform();
    // give it to the graphics2D as a new matrix replacing all previous transform
    snapshot.setTransform(matrixTx);
    if (matrixDelegate.hasPerspective()) {
        assert false;
        Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Canvas#setMatrix(android.graphics.Matrix) only " + "supports affine transformations.", null, null);
    }
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GcSnapshot(com.android.layoutlib.bridge.impl.GcSnapshot) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 4 with GcSnapshot

use of com.android.layoutlib.bridge.impl.GcSnapshot in project platform_frameworks_base by android.

the class Canvas_Delegate method native_concat.

@LayoutlibDelegate
public static void native_concat(long nCanvas, long nMatrix) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
    if (canvasDelegate == null) {
        return;
    }
    Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
    if (matrixDelegate == null) {
        return;
    }
    // get the current top graphics2D object.
    GcSnapshot snapshot = canvasDelegate.getSnapshot();
    // get its current matrix
    AffineTransform currentTx = snapshot.getTransform();
    // get the AffineTransform of the given matrix
    AffineTransform matrixTx = matrixDelegate.getAffineTransform();
    // combine them so that the given matrix is applied after.
    currentTx.concatenate(matrixTx);
    // give it to the graphics2D as a new matrix replacing all previous transform
    snapshot.setTransform(currentTx);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GcSnapshot(com.android.layoutlib.bridge.impl.GcSnapshot) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 5 with GcSnapshot

use of com.android.layoutlib.bridge.impl.GcSnapshot in project android_frameworks_base by crdroidandroid.

the class Canvas_Delegate method native_setMatrix.

@LayoutlibDelegate
public static void native_setMatrix(long nCanvas, long nMatrix) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
    if (canvasDelegate == null) {
        return;
    }
    Matrix_Delegate matrixDelegate = Matrix_Delegate.getDelegate(nMatrix);
    if (matrixDelegate == null) {
        return;
    }
    // get the current top graphics2D object.
    GcSnapshot snapshot = canvasDelegate.getSnapshot();
    // get the AffineTransform of the given matrix
    AffineTransform matrixTx = matrixDelegate.getAffineTransform();
    // give it to the graphics2D as a new matrix replacing all previous transform
    snapshot.setTransform(matrixTx);
    if (matrixDelegate.hasPerspective()) {
        assert false;
        Bridge.getLog().fidelityWarning(LayoutLog.TAG_MATRIX_AFFINE, "android.graphics.Canvas#setMatrix(android.graphics.Matrix) only " + "supports affine transformations.", null, null);
    }
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GcSnapshot(com.android.layoutlib.bridge.impl.GcSnapshot) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Aggregations

GcSnapshot (com.android.layoutlib.bridge.impl.GcSnapshot)15 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)15 AffineTransform (java.awt.geom.AffineTransform)15