diff options
author | Romain Guy <romainguy@google.com> | 2010-06-24 19:30:36 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2010-06-24 19:30:36 -0700 |
commit | 9d5316e3f56d138504565ff311145ac01621dff4 (patch) | |
tree | 40c79ba098de4624fbe38cb400c6ac4fe7340673 /libs/hwui/Matrix.cpp | |
parent | a18dbdf420fabebb83e7403d000384a8d98daffa (diff) |
Add colored rectangles implementation in OpenGLRenderer.
Drawing two rectangles one after the other discards the second one because of
Z buffering issues. This will be fixed in another changelist.
Change-Id: Ida1b3cde8a78e60cacc07e477abc44def527ff67
Diffstat (limited to 'libs/hwui/Matrix.cpp')
-rw-r--r-- | libs/hwui/Matrix.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index cbbce382f2fe..c097d7f9b592 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_TAG "UIMatrix" +#define LOG_TAG "Matrix" #include <math.h> #include <stdlib.h> @@ -27,6 +27,7 @@ #include "Matrix.h" namespace android { +namespace uirenderer { void Matrix4::loadIdentity() { mMat[0] = 1.0f; @@ -175,6 +176,21 @@ void Matrix4::loadOrtho(float left, float right, float bottom, float top, float mMat[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 tx = mMat[12]; + const float ty = mMat[13]; + + MUL_ADD_STORE(r.left, sx, tx); + MUL_ADD_STORE(r.right, sx, tx); + MUL_ADD_STORE(r.top, sy, ty); + MUL_ADD_STORE(r.bottom, sy, ty); +} + void Matrix4::dump() const { LOGD("Matrix4["); LOGD(" %f %f %f %f", mMat[0], mMat[4], mMat[ 8], mMat[12]); @@ -184,4 +200,5 @@ void Matrix4::dump() const { LOGD("]"); } -}; +}; // namespace uirenderer +}; // namespace android |