pull/37/head
kunfei 5 years ago
parent c90e50c99c
commit da73619a28
  1. 47
      app/src/main/java/io/legado/app/ui/widget/page/curl/CurlMesh.java

@ -830,7 +830,7 @@ public class CurlMesh {
private int mCapacity; private int mCapacity;
private int mSize; private int mSize;
public Array(int capacity) { Array(int capacity) {
mCapacity = capacity; mCapacity = capacity;
mArray = new Object[capacity]; mArray = new Object[capacity];
} }
@ -839,9 +839,7 @@ public class CurlMesh {
if (index < 0 || index > mSize || mSize >= mCapacity) { if (index < 0 || index > mSize || mSize >= mCapacity) {
throw new IndexOutOfBoundsException(); throw new IndexOutOfBoundsException();
} }
for (int i = mSize; i > index; --i) { System.arraycopy(mArray, index, mArray, index + 1, mSize - index);
mArray[i] = mArray[i - 1];
}
mArray[index] = item; mArray[index] = item;
++mSize; ++mSize;
} }
@ -880,9 +878,8 @@ public class CurlMesh {
throw new IndexOutOfBoundsException(); throw new IndexOutOfBoundsException();
} }
T item = (T) mArray[index]; T item = (T) mArray[index];
for (int i = index; i < mSize - 1; ++i) { if (mSize - 1 - index >= 0)
mArray[i] = mArray[i + 1]; System.arraycopy(mArray, index + 1, mArray, index, mSize - 1 - index);
}
--mSize; --mSize;
return item; return item;
} }
@ -897,34 +894,34 @@ public class CurlMesh {
* Holder for shadow vertex information. * Holder for shadow vertex information.
*/ */
private class ShadowVertex { private class ShadowVertex {
public double mPenumbraColor; double mPenumbraColor;
public double mPenumbraX; double mPenumbraX;
public double mPenumbraY; double mPenumbraY;
public double mPosX; double mPosX;
public double mPosY; double mPosY;
public double mPosZ; double mPosZ;
} }
/** /**
* Holder for vertex information. * Holder for vertex information.
*/ */
private class Vertex { private class Vertex {
public int mColor; int mColor;
public float mColorFactor; float mColorFactor;
public double mPenumbraX; double mPenumbraX;
public double mPenumbraY; double mPenumbraY;
public double mPosX; double mPosX;
public double mPosY; double mPosY;
public double mPosZ; double mPosZ;
public double mTexX; double mTexX;
public double mTexY; double mTexY;
public Vertex() { Vertex() {
mPosX = mPosY = mPosZ = mTexX = mTexY = 0; mPosX = mPosY = mPosZ = mTexX = mTexY = 0;
mColorFactor = 1.0f; mColorFactor = 1.0f;
} }
public void rotateZ(double theta) { void rotateZ(double theta) {
double cos = Math.cos(theta); double cos = Math.cos(theta);
double sin = Math.sin(theta); double sin = Math.sin(theta);
double x = mPosX * cos + mPosY * sin; double x = mPosX * cos + mPosY * sin;

Loading…
Cancel
Save