diff options
| author | Jason Sams <jsams@google.com> | 2015-03-18 19:44:36 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-03-18 19:44:37 +0000 |
| commit | 1aadd3474177e6946ea0aae03f0628e436d0cf87 (patch) | |
| tree | 9633423e39408a99ab35e7cb3c41110e6d62ff58 /rs/java | |
| parent | 28e6aeca3aad075ef4fd7aab08cd1ad1ff9eb555 (diff) | |
| parent | 1e68bac5f80b64beceaa60e6c2d560ab26c8d72d (diff) | |
Merge "Avoid duplicate surface creation."
Diffstat (limited to 'rs/java')
| -rw-r--r-- | rs/java/android/renderscript/Allocation.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java index c6afa2cc3920..523c8fb7b189 100644 --- a/rs/java/android/renderscript/Allocation.java +++ b/rs/java/android/renderscript/Allocation.java @@ -76,6 +76,8 @@ public class Allocation extends BaseObj { new HashMap<Long, Allocation>(); OnBufferAvailableListener mBufferNotifier; + private Surface mGetSurfaceSurface = null; + private Element.DataType validateObjectIsPrimitiveArray(Object d, boolean checkType) { final Class c = d.getClass(); if (!c.isArray()) { @@ -1990,7 +1992,12 @@ public class Allocation extends BaseObj { if ((mUsage & USAGE_IO_INPUT) == 0) { throw new RSInvalidStateException("Allocation is not a surface texture."); } - return mRS.nAllocationGetSurface(getID(mRS)); + + if (mGetSurfaceSurface == null) { + mGetSurfaceSurface = mRS.nAllocationGetSurface(getID(mRS)); + } + + return mGetSurfaceSurface; } /** |
