diff options
author | Romain Guy <romainguy@google.com> | 2010-08-11 19:35:53 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2010-08-11 19:35:53 -0700 |
commit | 959c91f7f7b4f921d341264f5b4ef54e702a0df0 (patch) | |
tree | 0b6e7264bf5680cb2dea83cf587449fde9802034 | |
parent | 943fbb4f4006273ae5983da42143d721ae05dfd4 (diff) | |
download | frameworks_base-959c91f7f7b4f921d341264f5b4ef54e702a0df0.zip frameworks_base-959c91f7f7b4f921d341264f5b4ef54e702a0df0.tar.gz frameworks_base-959c91f7f7b4f921d341264f5b4ef54e702a0df0.tar.bz2 |
Bunch of fixes.
Fixes memory leak, fixes multiple context support, fix 3d transforms.
Change-Id: I7462cfbc57857dbd4de4e76b9d4cba58a1bce77b
-rw-r--r-- | core/java/android/view/HardwareRenderer.java | 10 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 12 | ||||
-rw-r--r-- | libs/hwui/Snapshot.h | 21 |
3 files changed, 36 insertions, 7 deletions
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index cd6b820..44bd6d4 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -300,7 +300,6 @@ public abstract class HardwareRenderer { */ if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) { throw new RuntimeException("eglMakeCurrent failed"); - } return mEglContext.getGL(); @@ -374,6 +373,15 @@ public abstract class HardwareRenderer { attachInfo.mIgnoreDirtyState = true; view.mPrivateFlags |= View.DRAWN; + // TODO: Don't check the current context when we have one per UI thread + // TODO: Use a threadlocal flag to know whether the surface has changed + if (mEgl.eglGetCurrentContext() != mEglContext || + mEgl.eglGetCurrentSurface(EGL10.EGL_DRAW) != mEglSurface) { + if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) { + throw new RuntimeException("eglMakeCurrent failed"); + } + } + onPreDraw(); Canvas canvas = mCanvas; diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index aaf7564..3c1fe2a 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -160,7 +160,9 @@ OpenGLRenderer::~OpenGLRenderer() { mTextureCache.clear(); mLayerCache.clear(); mGradientCache.clear(); + mPathCache.clear(); mPatchCache.clear(); + mProgramCache.clear(); } /////////////////////////////////////////////////////////////////////////////// @@ -410,8 +412,14 @@ const Rect& OpenGLRenderer::getClipBounds() { } bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) { - Rect r(left, top, right, bottom); - mSnapshot->transform.mapRect(r); + SkRect sr; + sr.set(left, top, right, bottom); + + SkMatrix m; + mSnapshot->transform.copyTo(m); + m.mapRect(&sr); + + Rect r(sr.fLeft, sr.fTop, sr.fRight, sr.fBottom); return !mSnapshot->clipRect.intersects(r); } diff --git a/libs/hwui/Snapshot.h b/libs/hwui/Snapshot.h index 399ae68..342e5b1 100644 --- a/libs/hwui/Snapshot.h +++ b/libs/hwui/Snapshot.h @@ -96,9 +96,14 @@ public: bool clip(float left, float top, float right, float bottom, SkRegion::Op op) { bool clipped = false; - Rect r(left, top, right, bottom); - transform.mapRect(r); + SkRect sr; + sr.set(left, top, right, bottom); + SkMatrix m; + transform.copyTo(m); + m.mapRect(&sr); + + Rect r(sr.fLeft, sr.fTop, sr.fRight, sr.fBottom); switch (op) { case SkRegion::kDifference_Op: break; @@ -137,8 +142,16 @@ public: if (flags & Snapshot::kFlagDirtyLocalClip) { mat4 inverse; inverse.loadInverse(transform); - localClip.set(clipRect); - inverse.mapRect(localClip); + + SkRect sr; + sr.set(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom); + + SkMatrix m; + inverse.copyTo(m); + m.mapRect(&sr); + + localClip.set(sr.fLeft, sr.fTop, sr.fRight, sr.fBottom); + flags &= ~Snapshot::kFlagDirtyLocalClip; } return localClip; |