Minor fixes to SurfaceTexture transform matrix.

- Sometimes, the applyUpdate was applied through draw() and the
  underlying matrix was not updated in time, causing "jitter".  Add a
  matrix update call in draw().

- Switch to invalidateParentIfNeeded() in setTransform().

Change-Id: I1cf9cdfe78f9d989821cdc9600984fc826430211
This commit is contained in:
Alexandre Elias
2011-08-19 16:03:16 -07:00
parent 30867d8bdf
commit c01391fb4e

View File

@@ -261,6 +261,7 @@ public class TextureView extends View {
@Override
public final void draw(Canvas canvas) {
applyUpdate();
applyTransformMatrix();
}
/**
@@ -315,11 +316,7 @@ public class TextureView extends View {
}
applyUpdate();
if (mMatrixChanged) {
mLayer.setTransform(mMatrix);
mMatrixChanged = false;
}
applyTransformMatrix();
return mLayer;
}
@@ -386,7 +383,7 @@ public class TextureView extends View {
public void setTransform(Matrix transform) {
mMatrix.set(transform);
mMatrixChanged = true;
invalidate();
invalidateParentIfNeeded();
}
/**
@@ -410,6 +407,13 @@ public class TextureView extends View {
return transform;
}
private void applyTransformMatrix() {
if (mMatrixChanged) {
mLayer.setTransform(mMatrix);
mMatrixChanged = false;
}
}
/**
* <p>Returns a {@link android.graphics.Bitmap} representation of the content
* of the associated surface texture. If the surface texture is not available,