Java Code Examples for android.graphics.Matrix#MSKEW_X

The following examples show how to use android.graphics.Matrix#MSKEW_X . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowStateAnimator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void seamlesslyRotate(SurfaceControl.Transaction t, int oldRotation, int newRotation) {
    final WindowState w = mWin;

    // We rotated the screen, but have not received a new buffer with the correct size yet. In
    // the mean time, we rotate the buffer we have to the new orientation.
    final Matrix transform = mService.mTmpTransform;
    transformToRotation(oldRotation, newRotation, w.mFrame.width(), w.mFrame.height(),
            transform);
    transform.getValues(mService.mTmpFloats);

    float DsDx = mService.mTmpFloats[Matrix.MSCALE_X];
    float DtDx = mService.mTmpFloats[Matrix.MSKEW_Y];
    float DtDy = mService.mTmpFloats[Matrix.MSKEW_X];
    float DsDy = mService.mTmpFloats[Matrix.MSCALE_Y];
    float nx = mService.mTmpFloats[Matrix.MTRANS_X];
    float ny = mService.mTmpFloats[Matrix.MTRANS_Y];
    mSurfaceController.setPosition(t, nx, ny, false);
    mSurfaceController.setMatrix(t, DsDx * w.mHScale, DtDx * w.mVScale, DtDy
            * w.mHScale, DsDy * w.mVScale, false);
}
 
Example 2
Source File: MatrixUtils.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * android.graphics.Matrixの3x3行列をOpenGLの4x4(列優先)行列に変換する
 * (アフィン変換のみ)
 * |a11 a12 a13|  |0 1 2|      |a11 a12   0 a13|   |0 4 8  12|
 * |a21 a22 a23|  |3 4 5|      |a21 a22   0 a23|   |1 5 9  13|
 * |a31 a32 a33|  |6 7 8| =>   |  0   0   1   0|   |2 6 10 14|
 *                             |a31 a32   0 a33|   |3 7 11 15|
 * @param transform
 * @param result
 * @return
 */
@NonNull
@Size(min=16)
public static float[] toGLMatrix(@NonNull final Matrix transform,
	@NonNull @Size(min=16) final float[] result,
	@NonNull @Size(min=9) final float[] aMatrix) {

	transform.getValues(aMatrix);
	result[ 0] = aMatrix[Matrix.MSCALE_X];
	result[ 1] = aMatrix[Matrix.MSKEW_Y];
	result[ 2] = 0;
	result[ 3] = aMatrix[Matrix.MPERSP_0];
	result[ 4] = aMatrix[Matrix.MSKEW_X];
	result[ 5] = aMatrix[Matrix.MSCALE_Y];
	result[ 6] = 0;
	result[ 7] = aMatrix[Matrix.MPERSP_1];
	result[ 8] = 0;
	result[ 9] = 0;
	result[10] = 1;
	result[11] = 0;
	result[12] = aMatrix[Matrix.MTRANS_X];
	result[13] = aMatrix[Matrix.MTRANS_Y];
	result[14] = 0;
	result[15] = aMatrix[Matrix.MPERSP_2];
	return result;
}
 
Example 3
Source File: MatrixUtils.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * OpenGLの4x4(列優先)行列をandroid.graphics.Matrixの3x3行列に変換する
 * (アフィン変換のみ)
 * @param transform
 * @param result
 * @param aMatrix
 * @return
 */
public static Matrix toAndroidMatrix(
	@NonNull @Size(min=16)final float[] transform,
	@NonNull final Matrix result,
	@NonNull @Size(min=9) final float[] aMatrix) {

	aMatrix[Matrix.MSCALE_X] = transform[ 0];
	aMatrix[Matrix.MSKEW_Y] = transform[ 1];
	aMatrix[Matrix.MPERSP_0] = transform[ 3];
	aMatrix[Matrix.MSKEW_X] = transform[ 4];
	aMatrix[Matrix.MSCALE_Y] = transform[ 5];
	aMatrix[Matrix.MPERSP_1] = transform[ 7];
	aMatrix[Matrix.MTRANS_X] = transform[12];
	aMatrix[Matrix.MTRANS_Y] = transform[13];
	aMatrix[Matrix.MPERSP_2] = transform[15];
	result.setValues(aMatrix);

	return result;
}
 
Example 4
Source File: SketchUtils.java    From sketch with Apache License 2.0 6 votes vote down vote up
/**
 * 从 {@link Matrix} 中获取旋转角度
 */
public static int getMatrixRotateDegrees(@NonNull Matrix matrix) {
    synchronized (MATRIX_VALUES) {
        matrix.getValues(MATRIX_VALUES);
        final float skewX = MATRIX_VALUES[Matrix.MSKEW_X];
        final float scaleX = MATRIX_VALUES[Matrix.MSCALE_X];
        final int degrees = (int) Math.round(Math.atan2(skewX, scaleX) * (180 / Math.PI));
        if (degrees < 0) {
            return Math.abs(degrees);
        } else if (degrees > 0) {
            return 360 - degrees;
        } else {
            return 0;
        }
    }
}
 
Example 5
Source File: GLMatrix.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static float[] LoadGraphicsMatrix(Matrix matrix) {
    float m[] = new float[16];
    float v[] = new float[9];
    matrix.getValues(v);

    m[0] = v[Matrix.MSCALE_X]; //m.a;
    m[1] = v[Matrix.MSKEW_X]; //m.b;
    m[2] = 0.0f;
    m[3] = 0.0f;

    m[4] = v[Matrix.MSKEW_Y]; //m.c;
    m[5] = v[Matrix.MSCALE_Y]; //m.d;
    m[6] = 0.0f;
    m[7] = 0.0f;

    m[8] = 0.0f;
    m[9] = 0.0f;
    m[10] = 1.0f;
    m[11] = 0.0f;

    m[12] = v[Matrix.MTRANS_X]; //m.tx;
    m[13] = v[Matrix.MTRANS_Y]; //m.ty;
    m[14] = 0.0f;
    m[15] = 1.0f;

    return m;
}
 
Example 6
Source File: CoupleChartGestureListener.java    From shinny-futures-android with GNU General Public License v3.0 5 votes vote down vote up
private void syncCharts() {
    Matrix srcMatrix;
    float[] srcVals = new float[9];
    Matrix dstMatrix;
    float[] dstVals = new float[9];
    // get src chart translation matrix:
    srcMatrix = srcChart.getViewPortHandler().getMatrixTouch();
    srcMatrix.getValues(srcVals);
    // apply X axis scaling and position to dst charts:
    for (Chart dstChart : dstCharts) {
        dstMatrix = dstChart.getViewPortHandler().getMatrixTouch();
        dstMatrix.getValues(dstVals);

        dstVals[Matrix.MSCALE_X] = srcVals[Matrix.MSCALE_X];
        dstVals[Matrix.MSKEW_X] = srcVals[Matrix.MSKEW_X];
        dstVals[Matrix.MTRANS_X] = srcVals[Matrix.MTRANS_X];
        dstVals[Matrix.MSKEW_Y] = srcVals[Matrix.MSKEW_Y];
        dstVals[Matrix.MSCALE_Y] = srcVals[Matrix.MSCALE_Y];
        dstVals[Matrix.MTRANS_Y] = srcVals[Matrix.MTRANS_Y];
        dstVals[Matrix.MPERSP_0] = srcVals[Matrix.MPERSP_0];
        dstVals[Matrix.MPERSP_1] = srcVals[Matrix.MPERSP_1];
        dstVals[Matrix.MPERSP_2] = srcVals[Matrix.MPERSP_2];

        dstMatrix.setValues(dstVals);
        dstChart.getViewPortHandler().refresh(dstMatrix, dstChart, true);
    }
}
 
Example 7
Source File: CoupleChartGestureListener.java    From StockChart-MPAndroidChart with MIT License 5 votes vote down vote up
public void syncCharts() {
    if (dstCharts == null) {
        return;
    }
    Matrix srcMatrix;
    float[] srcVals = new float[9];
    Matrix dstMatrix;
    float[] dstVals = new float[9];
    // get src chart translation matrix:
    srcMatrix = srcChart.getViewPortHandler().getMatrixTouch();
    srcMatrix.getValues(srcVals);

    // apply X axis scaling and position to dst charts:
    for (Chart dstChart : dstCharts) {
        if (dstChart.getVisibility() == View.VISIBLE) {
            dstMatrix = dstChart.getViewPortHandler().getMatrixTouch();
            dstMatrix.getValues(dstVals);

            dstVals[Matrix.MSCALE_X] = srcVals[Matrix.MSCALE_X];
            dstVals[Matrix.MSKEW_X] = srcVals[Matrix.MSKEW_X];
            dstVals[Matrix.MTRANS_X] = srcVals[Matrix.MTRANS_X];
            dstVals[Matrix.MSKEW_Y] = srcVals[Matrix.MSKEW_Y];
            dstVals[Matrix.MSCALE_Y] = srcVals[Matrix.MSCALE_Y];
            dstVals[Matrix.MTRANS_Y] = srcVals[Matrix.MTRANS_Y];
            dstVals[Matrix.MPERSP_0] = srcVals[Matrix.MPERSP_0];
            dstVals[Matrix.MPERSP_1] = srcVals[Matrix.MPERSP_1];
            dstVals[Matrix.MPERSP_2] = srcVals[Matrix.MPERSP_2];

            dstMatrix.setValues(dstVals);
            dstChart.getViewPortHandler().refresh(dstMatrix, dstChart, true);
        }
    }
}
 
Example 8
Source File: GLMatrix.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static float[] LoadGraphicsMatrix(Matrix matrix) {
    float m[] = new float[16];
    float v[] = new float[9];
    matrix.getValues(v);

    m[0] = v[Matrix.MSCALE_X]; //m.a;
    m[1] = v[Matrix.MSKEW_X]; //m.b;
    m[2] = 0.0f;
    m[3] = 0.0f;

    m[4] = v[Matrix.MSKEW_Y]; //m.c;
    m[5] = v[Matrix.MSCALE_Y]; //m.d;
    m[6] = 0.0f;
    m[7] = 0.0f;

    m[8] = 0.0f;
    m[9] = 0.0f;
    m[10] = 1.0f;
    m[11] = 0.0f;

    m[12] = v[Matrix.MTRANS_X]; //m.tx;
    m[13] = v[Matrix.MTRANS_Y]; //m.ty;
    m[14] = 0.0f;
    m[15] = 1.0f;

    return m;
}
 
Example 9
Source File: CoupleChartGestureListener.java    From android-kline with Apache License 2.0 5 votes vote down vote up
public void syncCharts() {
    Matrix srcMatrix;
    float[] srcVals = new float[9];
    Matrix dstMatrix;
    float[] dstVals = new float[9];
    // get src chart translation matrix:
    srcMatrix = srcChart.getViewPortHandler().getMatrixTouch();
    srcMatrix.getValues(srcVals);
    // apply X axis scaling and position to dst charts:
    for (Chart dstChart : dstCharts) {
        dstMatrix = dstChart.getViewPortHandler().getMatrixTouch();
        dstMatrix.getValues(dstVals);

        dstVals[Matrix.MSCALE_X] = srcVals[Matrix.MSCALE_X];
        dstVals[Matrix.MSKEW_X] = srcVals[Matrix.MSKEW_X];
        dstVals[Matrix.MTRANS_X] = srcVals[Matrix.MTRANS_X];
        dstVals[Matrix.MSKEW_Y] = srcVals[Matrix.MSKEW_Y];
        dstVals[Matrix.MSCALE_Y] = srcVals[Matrix.MSCALE_Y];
        dstVals[Matrix.MTRANS_Y] = srcVals[Matrix.MTRANS_Y];
        dstVals[Matrix.MPERSP_0] = srcVals[Matrix.MPERSP_0];
        dstVals[Matrix.MPERSP_1] = srcVals[Matrix.MPERSP_1];
        dstVals[Matrix.MPERSP_2] = srcVals[Matrix.MPERSP_2];

        dstMatrix.setValues(dstVals);
        dstChart.getViewPortHandler().refresh(dstMatrix, dstChart, true);
    }
}
 
Example 10
Source File: GLMatrix.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static float[] LoadGraphicsMatrix(Matrix matrix) {
    float m[] = new float[16];
    float v[] = new float[9];
    matrix.getValues(v);

    m[0] = v[Matrix.MSCALE_X]; //m.a;
    m[1] = v[Matrix.MSKEW_X]; //m.b;
    m[2] = 0.0f;
    m[3] = 0.0f;

    m[4] = v[Matrix.MSKEW_Y]; //m.c;
    m[5] = v[Matrix.MSCALE_Y]; //m.d;
    m[6] = 0.0f;
    m[7] = 0.0f;

    m[8] = 0.0f;
    m[9] = 0.0f;
    m[10] = 1.0f;
    m[11] = 0.0f;

    m[12] = v[Matrix.MTRANS_X]; //m.tx;
    m[13] = v[Matrix.MTRANS_Y]; //m.ty;
    m[14] = 0.0f;
    m[15] = 1.0f;

    return m;
}
 
Example 11
Source File: GLMatrix.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static float[] LoadGraphicsMatrix(Matrix matrix) {
    float m[] = new float[16];
    float v[] = new float[9];
    matrix.getValues(v);

    m[0] = v[Matrix.MSCALE_X]; //m.a;
    m[1] = v[Matrix.MSKEW_X]; //m.b;
    m[2] = 0.0f;
    m[3] = 0.0f;

    m[4] = v[Matrix.MSKEW_Y]; //m.c;
    m[5] = v[Matrix.MSCALE_Y]; //m.d;
    m[6] = 0.0f;
    m[7] = 0.0f;

    m[8] = 0.0f;
    m[9] = 0.0f;
    m[10] = 1.0f;
    m[11] = 0.0f;

    m[12] = v[Matrix.MTRANS_X]; //m.tx;
    m[13] = v[Matrix.MTRANS_Y]; //m.ty;
    m[14] = 0.0f;
    m[15] = 1.0f;

    return m;
}
 
Example 12
Source File: ImageViewUtil.java    From PhotoViewCropper with Apache License 2.0 4 votes vote down vote up
public static float getXSkew(Matrix matrix){
    float[] f = new float[9];
    matrix.getValues(f);
    return f[Matrix.MSKEW_X];
}