Search in sources :

Example 11 with GcSnapshot

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

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 12 with GcSnapshot

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

the class Canvas_Delegate method native_skew.

@LayoutlibDelegate
public static void native_skew(long nativeCanvas, float kx, float ky) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
    if (canvasDelegate == null) {
        return;
    }
    // get the current top graphics2D object.
    GcSnapshot g = canvasDelegate.getSnapshot();
    // get its current matrix
    AffineTransform currentTx = g.getTransform();
    // get the AffineTransform for the given skew.
    float[] mtx = Matrix_Delegate.getSkew(kx, ky);
    AffineTransform matrixTx = Matrix_Delegate.getAffineTransform(mtx);
    // combine them so that the given matrix is applied after.
    currentTx.preConcatenate(matrixTx);
    // give it to the graphics2D as a new matrix replacing all previous transform
    g.setTransform(currentTx);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GcSnapshot(com.android.layoutlib.bridge.impl.GcSnapshot) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 13 with GcSnapshot

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

the class Canvas_Delegate method native_skew.

@LayoutlibDelegate
public static void native_skew(long nativeCanvas, float kx, float ky) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
    if (canvasDelegate == null) {
        return;
    }
    // get the current top graphics2D object.
    GcSnapshot g = canvasDelegate.getSnapshot();
    // get its current matrix
    AffineTransform currentTx = g.getTransform();
    // get the AffineTransform for the given skew.
    float[] mtx = Matrix_Delegate.getSkew(kx, ky);
    AffineTransform matrixTx = Matrix_Delegate.getAffineTransform(mtx);
    // combine them so that the given matrix is applied after.
    currentTx.preConcatenate(matrixTx);
    // give it to the graphics2D as a new matrix replacing all previous transform
    g.setTransform(currentTx);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) GcSnapshot(com.android.layoutlib.bridge.impl.GcSnapshot) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 14 with GcSnapshot

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

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 15 with GcSnapshot

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

the class Canvas_Delegate method native_skew.

@LayoutlibDelegate
public static void native_skew(long nativeCanvas, float kx, float ky) {
    // get the delegate from the native int.
    Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
    if (canvasDelegate == null) {
        return;
    }
    // get the current top graphics2D object.
    GcSnapshot g = canvasDelegate.getSnapshot();
    // get its current matrix
    AffineTransform currentTx = g.getTransform();
    // get the AffineTransform for the given skew.
    float[] mtx = Matrix_Delegate.getSkew(kx, ky);
    AffineTransform matrixTx = Matrix_Delegate.getAffineTransform(mtx);
    // combine them so that the given matrix is applied after.
    currentTx.preConcatenate(matrixTx);
    // give it to the graphics2D as a new matrix replacing all previous transform
    g.setTransform(currentTx);
}
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