diff options
author | Jason Sams <jsams@google.com> | 2013-04-13 19:48:36 -0700 |
---|---|---|
committer | Jason Sams <jsams@google.com> | 2013-04-14 02:56:03 +0000 |
commit | 9bf189228fdb0ec14b284f8bd543d5f9137997cc (patch) | |
tree | be5ebeea9340aa4c718cae968e34d3d9cab34e8e /graphics/java | |
parent | 02d56d90e01e20db8424de94a14fe59dc94f19c0 (diff) | |
download | frameworks_base-9bf189228fdb0ec14b284f8bd543d5f9137997cc.zip frameworks_base-9bf189228fdb0ec14b284f8bd543d5f9137997cc.tar.gz frameworks_base-9bf189228fdb0ec14b284f8bd543d5f9137997cc.tar.bz2 |
Revert GC thread changes
This is not quite a straight revery, some manual edits were necessary.
The original CL didn't undergo sufficient design review or testing. Revert until the regressions can be sorted out.
Bug 8585185
This reverts commit 6dacf8355a0692b52c49f603f43317772cb36175
This reverts commit f8c033db1edf36a0ab09568c3142054f0be2d1a1
Change-Id: Ie7215bdf881332e822603547e92f810f595077fc
Diffstat (limited to 'graphics/java')
5 files changed, 2 insertions, 99 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index ea29b7d..5d1990a 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -277,21 +277,13 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Invalid usage combination."); } } - if (t != null) { - // don't need to account for USAGE_SHARED Allocations - if ((usage & USAGE_SHARED) == 0) { - int numBytes = t.getCount() * t.getElement().getBytesSize(); - rs.addAllocSizeForGC(numBytes); - mGCSize = numBytes; - } - } + mType = t; mUsage = usage; if (t != null) { updateCacheInfo(t); } - } private void validateIsInt32() { @@ -355,12 +347,6 @@ public class Allocation extends BaseObj { mType.updateFromNative(); updateCacheInfo(mType); } - // don't need to account for USAGE_SHARED Allocations - if ((mUsage & USAGE_SHARED) == 0) { - int numBytes = mType.getCount() * mType.getElement().getBytesSize(); - mRS.addAllocSizeForGC(numBytes); - mGCSize = numBytes; - } } /** @@ -1264,7 +1250,6 @@ public class Allocation extends BaseObj { if (type.getID(rs) == 0) { throw new RSInvalidStateException("Bad Type"); } - int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); @@ -1414,6 +1399,7 @@ public class Allocation extends BaseObj { return alloc; } + int id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage); if (id == 0) { throw new RSRuntimeException("Load failed."); diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index c2ebc9f..f464f9b 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -71,9 +71,6 @@ public class BaseObj { private int mID; private boolean mDestroyed; private String mName; - - int mGCSize; - RenderScript mRS; /** @@ -138,9 +135,6 @@ public class BaseObj { throw new RSInvalidStateException("Object already destroyed."); } mDestroyed = true; - if (mGCSize != 0) { - mRS.removeAllocSizeForGC(mGCSize); - } mRS.nObjDestroy(mID); } diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 33639dc..6f614c3 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -18,9 +18,7 @@ package android.renderscript; import java.io.File; import java.lang.reflect.Field; -import java.util.concurrent.locks.*; -import android.app.ActivityManager; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; @@ -804,8 +802,6 @@ public class RenderScript { int mContext; @SuppressWarnings({"FieldCanBeLocal"}) MessageThread mMessageThread; - GCThread mGCThread; - Element mElement_U8; Element mElement_I8; @@ -1095,60 +1091,6 @@ public class RenderScript { } } - static class GCThread extends Thread { - RenderScript mRS; - boolean mRun = true; - - long currentSize = 0; - long targetSize; // call System.gc after 512MB of allocs - - final Lock lock = new ReentrantLock(); - final Condition cond = lock.newCondition(); - - GCThread(RenderScript rs) { - super("RSGCThread"); - mRS = rs; - - } - - public void run() { - ActivityManager am = (ActivityManager)mRS.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE); - ActivityManager.MemoryInfo meminfo = new ActivityManager.MemoryInfo(); - am.getMemoryInfo(meminfo); - targetSize = (long)(meminfo.totalMem * .5f); - - while(mRun) { - System.gc(); - lock.lock(); - try { - cond.awaitUninterruptibly(); - } finally { - lock.unlock(); - } - } - - Log.d(LOG_TAG, "GCThread exiting."); - } - - public synchronized void addAllocSize(long bytes) { - currentSize += bytes; - if (currentSize >= targetSize) { - lock.lock(); - try { - cond.signal(); - } finally { - lock.unlock(); - } - } - } - - public synchronized void removeAllocSize(long bytes) { - currentSize -= bytes; - } - - } - - RenderScript(Context ctx) { if (ctx != null) { mApplicationContext = ctx.getApplicationContext(); @@ -1171,15 +1113,6 @@ public class RenderScript { return create(ctx, sdkVersion, ContextType.NORMAL); } - void addAllocSizeForGC(int bytes) { - mGCThread.addAllocSize(bytes); - } - - void removeAllocSizeForGC(int bytes) { - mGCThread.removeAllocSize(bytes); - } - - /** * Create a basic RenderScript context. * @@ -1196,9 +1129,7 @@ public class RenderScript { throw new RSDriverException("Failed to create RS context."); } rs.mMessageThread = new MessageThread(rs); - rs.mGCThread = new GCThread(rs); rs.mMessageThread.start(); - rs.mGCThread.start(); return rs; } @@ -1253,11 +1184,8 @@ public class RenderScript { validate(); nContextDeinitToClient(mContext); mMessageThread.mRun = false; - mGCThread.mRun = false; - mGCThread.addAllocSize(0); try { mMessageThread.join(); - mGCThread.join(); } catch(InterruptedException e) { } diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java index fad8838..52034b1 100644 --- a/graphics/java/android/renderscript/RenderScriptGL.java +++ b/graphics/java/android/renderscript/RenderScriptGL.java @@ -198,9 +198,6 @@ public class RenderScriptGL extends RenderScript { } mMessageThread = new MessageThread(this); mMessageThread.start(); - mGCThread = new GCThread(this); - mGCThread.start(); - } /** diff --git a/graphics/java/android/renderscript/ScriptC.java b/graphics/java/android/renderscript/ScriptC.java index 2f69775..221f760 100644 --- a/graphics/java/android/renderscript/ScriptC.java +++ b/graphics/java/android/renderscript/ScriptC.java @@ -60,8 +60,6 @@ public class ScriptC extends Script { throw new RSRuntimeException("Loading of ScriptC script failed."); } setID(id); - mGCSize = 2 * 1024 * 1024; - rs.addAllocSizeForGC(mGCSize); } /** |