use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.
the class View method getMatrix.
/**
* The transform matrix of this view, which is calculated based on the current
* rotation, scale, and pivot properties.
*
* @see #getRotation()
* @see #getScaleX()
* @see #getScaleY()
* @see #getPivotX()
* @see #getPivotY()
* @return The current transform matrix for the view
*/
public Matrix getMatrix() {
ensureTransformationInfo();
final Matrix matrix = mTransformationInfo.mMatrix;
mRenderNode.getMatrix(matrix);
return matrix;
}
use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.
the class View method toGlobalMotionEvent.
/**
* Transforms a motion event from view-local coordinates to on-screen
* coordinates.
*
* @param ev the view-local motion event
* @return false if the transformation could not be applied
* @hide
*/
public boolean toGlobalMotionEvent(MotionEvent ev) {
final AttachInfo info = mAttachInfo;
if (info == null) {
return false;
}
final Matrix m = info.mTmpMatrix;
m.set(Matrix.IDENTITY_MATRIX);
transformMatrixToGlobal(m);
ev.transform(m);
return true;
}
use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.
the class AppIconLoader method getResizedBitmap.
/**
* Resize the app icon to the size we need to save space in our LRU cache.
* Normal we could assume that all app icons have the same default AOSP defined size.
* The reality shows that a lot apps do not care about and add just one big icon for
* all screen resolution.
*/
private static Drawable getResizedBitmap(Drawable source, Context context, float scaleFactor) {
if (source == null) {
return null;
}
final int iconSize = (int) (context.getResources().getDimensionPixelSize(R.dimen.recent_app_icon_size) * scaleFactor);
final Bitmap bitmap = ImageHelper.drawableToBitmap(source);
final Bitmap scaledBitmap = Bitmap.createBitmap(iconSize, iconSize, Config.ARGB_8888);
final float ratioX = iconSize / (float) bitmap.getWidth();
final float ratioY = iconSize / (float) bitmap.getHeight();
final float middleX = iconSize / 2.0f;
final float middleY = iconSize / 2.0f;
final Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
paint.setAntiAlias(true);
final Matrix scaleMatrix = new Matrix();
scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);
final Canvas canvas = new Canvas(scaledBitmap);
canvas.setMatrix(scaleMatrix);
canvas.drawBitmap(bitmap, middleX - bitmap.getWidth() / 2, middleY - bitmap.getHeight() / 2, paint);
return new BitmapDrawable(context.getResources(), scaledBitmap);
}
use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.
the class ActivityTransitionCoordinator method setSharedElementState.
protected ArrayList<SharedElementOriginalState> setSharedElementState(Bundle sharedElementState, final ArrayList<View> snapshots) {
ArrayList<SharedElementOriginalState> originalImageState = new ArrayList<SharedElementOriginalState>();
if (sharedElementState != null) {
Matrix tempMatrix = new Matrix();
RectF tempRect = new RectF();
final int numSharedElements = mSharedElements.size();
for (int i = 0; i < numSharedElements; i++) {
View sharedElement = mSharedElements.get(i);
String name = mSharedElementNames.get(i);
SharedElementOriginalState originalState = getOldSharedElementState(sharedElement, name, sharedElementState);
originalImageState.add(originalState);
setSharedElementState(sharedElement, name, sharedElementState, tempMatrix, tempRect, null);
}
}
if (mListener != null) {
mListener.onSharedElementStart(mSharedElementNames, mSharedElements, snapshots);
}
return originalImageState;
}
use of android.graphics.Matrix in project android_frameworks_base by ResurrectionRemix.
the class ActivityTransitionCoordinator method getSharedElementParentMatrix.
private void getSharedElementParentMatrix(View view, Matrix matrix) {
final int index = mSharedElementParentMatrices == null ? -1 : mSharedElements.indexOf(view);
if (index < 0) {
matrix.reset();
ViewParent viewParent = view.getParent();
if (viewParent instanceof ViewGroup) {
// Find the location in the view's parent
ViewGroup parent = (ViewGroup) viewParent;
parent.transformMatrixToLocal(matrix);
matrix.postTranslate(parent.getScrollX(), parent.getScrollY());
}
} else {
// The indices of mSharedElementParentMatrices matches the
// mSharedElement matrices.
Matrix parentMatrix = mSharedElementParentMatrices.get(index);
matrix.set(parentMatrix);
}
}
Aggregations