summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/TextureView.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/view/TextureView.java')
-rw-r--r--core/java/android/view/TextureView.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 53a6bcb..b72222e 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -19,6 +19,7 @@ package android.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
@@ -104,6 +105,9 @@ public class TextureView extends View {
private boolean mOpaque = true;
+ private final Matrix mMatrix = new Matrix();
+ private boolean mMatrixChanged;
+
private final Object[] mLock = new Object[0];
private boolean mUpdateLayer;
@@ -312,6 +316,11 @@ public class TextureView extends View {
applyUpdate();
+ if (mMatrixChanged) {
+ mLayer.setTransform(mMatrix);
+ mMatrixChanged = false;
+ }
+
return mLayer;
}
@@ -358,6 +367,50 @@ public class TextureView extends View {
}
/**
+ * <p>Sets the transform to associate with this texture view.
+ * The specified transform applies to the underlying surface
+ * texture and does not affect the size or position of the view
+ * itself, only of its content.</p>
+ *
+ * <p>Some transforms might prevent the content from drawing
+ * all the pixels contained within this view's bounds. In such
+ * situations, make sure this texture view is not marked opaque.</p>
+ *
+ * @param transform The transform to apply to the content of
+ * this view.
+ *
+ * @see #getTransform(android.graphics.Matrix)
+ * @see #isOpaque()
+ * @see #setOpaque(boolean)
+ */
+ public void setTransform(Matrix transform) {
+ mMatrix.set(transform);
+ mMatrixChanged = true;
+ invalidate();
+ }
+
+ /**
+ * Returns the transform associated with this texture view.
+ *
+ * @param transform The {@link Matrix} in which to copy the current
+ * transform. Can be null.
+ *
+ * @return The specified matrix if not null or a new {@link Matrix}
+ * instance otherwise.
+ *
+ * @see #setTransform(android.graphics.Matrix)
+ */
+ public Matrix getTransform(Matrix transform) {
+ if (transform == null) {
+ transform = new Matrix();
+ }
+
+ transform.set(mMatrix);
+
+ return transform;
+ }
+
+ /**
* <p>Returns a {@link android.graphics.Bitmap} representation of the content
* of the associated surface texture. If the surface texture is not available,
* this method returns null.</p>