public boolean prepareRenderscriptAllocations(Bitmap bitmap) { RenderScript RS = getRenderScriptContext(); boolean needsUpdate = false; if (mOutPixelsAllocation == null || mInPixelsAllocation == null || bitmap.getWidth() != mWidth || bitmap.getHeight() != mHeight) { destroyPixelAllocations(); Bitmap bitmapBuffer = bitmap; if (bitmap.getConfig() == null || bitmap.getConfig() != BITMAP_CONFIG) { bitmapBuffer = bitmap.copy(BITMAP_CONFIG, true); } mOutPixelsAllocation = Allocation.createFromBitmap( RS, bitmapBuffer, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); mInPixelsAllocation = Allocation.createTyped(RS, mOutPixelsAllocation.getType()); needsUpdate = true; } if (RS != null) { mInPixelsAllocation.copyFrom(bitmap); } if (bitmap.getWidth() != mWidth || bitmap.getHeight() != mHeight) { mWidth = bitmap.getWidth(); mHeight = bitmap.getHeight(); needsUpdate = true; } if (DEBUG) { Log.v(LOGTAG, "prepareRenderscriptAllocations: " + needsUpdate + " in " + getName()); } return needsUpdate; }
public synchronized void reset() { synchronized (CachingPipeline.class) { if (getRenderScriptContext() == null) { return; } mOriginalBitmap = null; // just a reference to the bitmap in ImageLoader if (mResizedOriginalBitmap != null) { mResizedOriginalBitmap.recycle(); mResizedOriginalBitmap = null; } if (mOriginalAllocation != null) { mOriginalAllocation.destroy(); mOriginalAllocation = null; } if (mFiltersOnlyOriginalAllocation != null) { mFiltersOnlyOriginalAllocation.destroy(); mFiltersOnlyOriginalAllocation = null; } mPreviewScaleFactor = 1.0f; mHighResPreviewScaleFactor = 1.0f; destroyPixelAllocations(); } }