diff options
author | Romain Guy <romainguy@android.com> | 2010-06-25 13:41:57 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2010-06-25 13:41:57 -0700 |
commit | c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6c (patch) | |
tree | e9fa1c80906aa67991fea69f664fdddc94897327 /libs/hwui/Matrix.cpp | |
parent | 5b7e333cf2f91c94e37dbb7024fa38da3db34619 (diff) |
Implement quickReject() and drawRect().
The OpenGL ES 2.0 renderer can now draw colored rectangles. At least there's
something on screen now.
Change-Id: I80a13ccc1dd56784edf74f2670a364f30700234a
Diffstat (limited to 'libs/hwui/Matrix.cpp')
-rw-r--r-- | libs/hwui/Matrix.cpp | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index c097d7f9b592..59b7fefe41b6 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -30,95 +30,95 @@ namespace android { namespace uirenderer { void Matrix4::loadIdentity() { - mMat[0] = 1.0f; - mMat[1] = 0.0f; - mMat[2] = 0.0f; - mMat[3] = 0.0f; - - mMat[4] = 0.0f; - mMat[5] = 1.0f; - mMat[6] = 0.0f; - mMat[7] = 0.0f; - - mMat[8] = 0.0f; - mMat[9] = 0.0f; - mMat[10] = 1.0f; - mMat[11] = 0.0f; - - mMat[12] = 0.0f; - mMat[13] = 0.0f; - mMat[14] = 0.0f; - mMat[15] = 1.0f; + data[0] = 1.0f; + data[1] = 0.0f; + data[2] = 0.0f; + data[3] = 0.0f; + + data[4] = 0.0f; + data[5] = 1.0f; + data[6] = 0.0f; + data[7] = 0.0f; + + data[8] = 0.0f; + data[9] = 0.0f; + data[10] = 1.0f; + data[11] = 0.0f; + + data[12] = 0.0f; + data[13] = 0.0f; + data[14] = 0.0f; + data[15] = 1.0f; } void Matrix4::load(const float* v) { - memcpy(mMat, v, sizeof(mMat)); + memcpy(data, v, sizeof(data)); } void Matrix4::load(const Matrix4& v) { - memcpy(mMat, v.mMat, sizeof(mMat)); + memcpy(data, v.data, sizeof(data)); } void Matrix4::load(const SkMatrix& v) { - memset(mMat, 0, sizeof(mMat)); + memset(data, 0, sizeof(data)); - mMat[0] = v[SkMatrix::kMScaleX]; - mMat[4] = v[SkMatrix::kMSkewX]; - mMat[12] = v[SkMatrix::kMTransX]; + data[0] = v[SkMatrix::kMScaleX]; + data[4] = v[SkMatrix::kMSkewX]; + data[12] = v[SkMatrix::kMTransX]; - mMat[1] = v[SkMatrix::kMSkewY]; - mMat[5] = v[SkMatrix::kMScaleY]; - mMat[13] = v[SkMatrix::kMTransY]; + data[1] = v[SkMatrix::kMSkewY]; + data[5] = v[SkMatrix::kMScaleY]; + data[13] = v[SkMatrix::kMTransY]; - mMat[3] = v[SkMatrix::kMPersp0]; - mMat[7] = v[SkMatrix::kMPersp1]; - mMat[15] = v[SkMatrix::kMPersp2]; + data[3] = v[SkMatrix::kMPersp0]; + data[7] = v[SkMatrix::kMPersp1]; + data[15] = v[SkMatrix::kMPersp2]; - mMat[10] = 1.0f; + data[10] = 1.0f; } void Matrix4::copyTo(SkMatrix& v) const { v.reset(); - v.set(SkMatrix::kMScaleX, mMat[0]); - v.set(SkMatrix::kMSkewX, mMat[4]); - v.set(SkMatrix::kMTransX, mMat[12]); + v.set(SkMatrix::kMScaleX, data[0]); + v.set(SkMatrix::kMSkewX, data[4]); + v.set(SkMatrix::kMTransX, data[12]); - v.set(SkMatrix::kMSkewY, mMat[1]); - v.set(SkMatrix::kMScaleY, mMat[5]); - v.set(SkMatrix::kMTransY, mMat[13]); + v.set(SkMatrix::kMSkewY, data[1]); + v.set(SkMatrix::kMScaleY, data[5]); + v.set(SkMatrix::kMTransY, data[13]); - v.set(SkMatrix::kMPersp0, mMat[3]); - v.set(SkMatrix::kMPersp1, mMat[7]); - v.set(SkMatrix::kMPersp2, mMat[15]); + v.set(SkMatrix::kMPersp0, data[3]); + v.set(SkMatrix::kMPersp1, data[7]); + v.set(SkMatrix::kMPersp2, data[15]); } void Matrix4::copyTo(float* v) const { - memcpy(v, mMat, sizeof(mMat)); + memcpy(v, data, sizeof(data)); } void Matrix4::loadTranslate(float x, float y, float z) { loadIdentity(); - mMat[12] = x; - mMat[13] = y; - mMat[14] = z; + data[12] = x; + data[13] = y; + data[14] = z; } void Matrix4::loadScale(float sx, float sy, float sz) { loadIdentity(); - mMat[0] = sx; - mMat[5] = sy; - mMat[10] = sz; + data[0] = sx; + data[5] = sy; + data[10] = sz; } void Matrix4::loadRotate(float angle, float x, float y, float z) { - mMat[3] = 0.0f; - mMat[7] = 0.0f; - mMat[11] = 0.0f; - mMat[12] = 0.0f; - mMat[13] = 0.0f; - mMat[14] = 0.0f; - mMat[15] = 1.0f; + data[3] = 0.0f; + data[7] = 0.0f; + data[11] = 0.0f; + data[12] = 0.0f; + data[13] = 0.0f; + data[14] = 0.0f; + data[15] = 1.0f; angle *= float(M_PI / 180.0f); float c = cosf(angle); @@ -133,15 +133,15 @@ void Matrix4::loadRotate(float angle, float x, float y, float z) { const float ys = y * s; const float zs = z * s; - mMat[0] = x * x * nc + c; - mMat[4] = xy * nc - zs; - mMat[8] = zx * nc + ys; - mMat[1] = xy * nc + zs; - mMat[5] = y * y * nc + c; - mMat[9] = yz * nc - xs; - mMat[2] = zx * nc - ys; - mMat[6] = yz * nc + xs; - mMat[10] = z * z * nc + c; + data[0] = x * x * nc + c; + data[4] = xy * nc - zs; + data[8] = zx * nc + ys; + data[1] = xy * nc + zs; + data[5] = y * y * nc + c; + data[9] = yz * nc - xs; + data[2] = zx * nc - ys; + data[6] = yz * nc + xs; + data[10] = z * z * nc + c; } void Matrix4::loadMultiply(const Matrix4& u, const Matrix4& v) { @@ -152,7 +152,7 @@ void Matrix4::loadMultiply(const Matrix4& u, const Matrix4& v) { float w = 0; for (int j = 0 ; j < 4 ; j++) { - const float e = v.get(i,j); + const float e = v.get(i, j); x += u.get(j, 0) * e; y += u.get(j, 1) * e; z += u.get(j, 2) * e; @@ -168,22 +168,22 @@ void Matrix4::loadMultiply(const Matrix4& u, const Matrix4& v) { void Matrix4::loadOrtho(float left, float right, float bottom, float top, float near, float far) { loadIdentity(); - mMat[0] = 2.0f / (right - left); - mMat[5] = 2.0f / (top - bottom); - mMat[10] = -2.0f / (far - near); - mMat[12] = -(right + left) / (right - left); - mMat[13] = -(top + bottom) / (top - bottom); - mMat[14] = -(far + near) / (far - near); + data[0] = 2.0f / (right - left); + data[5] = 2.0f / (top - bottom); + data[10] = -2.0f / (far - near); + data[12] = -(right + left) / (right - left); + data[13] = -(top + bottom) / (top - bottom); + data[14] = -(far + near) / (far - near); } #define MUL_ADD_STORE(a, b, c) a = (a) * (b) + (c) void Matrix4::mapRect(Rect& r) const { - const float sx = mMat[0]; - const float sy = mMat[5]; + const float sx = data[0]; + const float sy = data[5]; - const float tx = mMat[12]; - const float ty = mMat[13]; + const float tx = data[12]; + const float ty = data[13]; MUL_ADD_STORE(r.left, sx, tx); MUL_ADD_STORE(r.right, sx, tx); @@ -193,10 +193,10 @@ void Matrix4::mapRect(Rect& r) const { void Matrix4::dump() const { LOGD("Matrix4["); - LOGD(" %f %f %f %f", mMat[0], mMat[4], mMat[ 8], mMat[12]); - LOGD(" %f %f %f %f", mMat[1], mMat[5], mMat[ 9], mMat[13]); - LOGD(" %f %f %f %f", mMat[2], mMat[6], mMat[10], mMat[14]); - LOGD(" %f %f %f %f", mMat[3], mMat[7], mMat[11], mMat[15]); + LOGD(" %f %f %f %f", data[0], data[4], data[ 8], data[12]); + LOGD(" %f %f %f %f", data[1], data[5], data[ 9], data[13]); + LOGD(" %f %f %f %f", data[2], data[6], data[10], data[14]); + LOGD(" %f %f %f %f", data[3], data[7], data[11], data[15]); LOGD("]"); } |