API cleanup for renderscript. This will be a multiproject commit.
Change-Id: Ida62d3a155285a20725be9daa62217faef1c3734
diff --git a/graphics/java/android/renderscript/Matrix4f.java b/graphics/java/android/renderscript/Matrix4f.java
index ea97509..219d93b 100644
--- a/graphics/java/android/renderscript/Matrix4f.java
+++ b/graphics/java/android/renderscript/Matrix4f.java
@@ -71,7 +71,7 @@
}
public void load(Matrix4f src) {
- System.arraycopy(mMat, 0, src, 0, 16);
+ System.arraycopy(mMat, 0, src.getArray(), 0, 16);
}
public void loadRotate(float rot, float x, float y, float z) {
@@ -180,6 +180,32 @@
loadFrustum(left, right, bottom, top, near, far);
}
+ public void loadProjectionNormalized(int w, int h) {
+ // range -1,1 in the narrow axis at z = 0.
+ Matrix4f m1 = new Matrix4f();
+ Matrix4f m2 = new Matrix4f();
+
+ if(w > h) {
+ float aspect = ((float)w) / h;
+ m1.loadFrustum(-aspect,aspect, -1,1, 1,100);
+ } else {
+ float aspect = ((float)h) / w;
+ m1.loadFrustum(-1,1, -aspect,aspect, 1,100);
+ }
+
+ m2.loadRotate(180, 0, 1, 0);
+ m1.loadMultiply(m1, m2);
+
+ m2.loadScale(-2, 2, 1);
+ m1.loadMultiply(m1, m2);
+
+ m2.loadTranslate(0, 0, 2);
+ m1.loadMultiply(m1, m2);
+
+ load(m1);
+ }
+
+
public void multiply(Matrix4f rhs) {
Matrix4f tmp = new Matrix4f();
tmp.loadMultiply(this, rhs);