public void exit() {
      mRun = false;

      synchronized (this) {
        notifyAll();
      }

      try {
        this.join();
      } catch (InterruptedException e) {
      }

      mInPixelsAllocation.destroy();
      mInPixelsAllocation2.destroy();
      if (mOutPixelsAllocation != mOutDisplayAllocation) {
        mOutPixelsAllocation.destroy();
      }
      mOutDisplayAllocation.destroy();
      mRS.destroy();

      mInPixelsAllocation = null;
      mInPixelsAllocation2 = null;
      mOutPixelsAllocation = null;
      mOutDisplayAllocation = null;
      mRS = null;
    }
  private synchronized boolean updateOriginalAllocation(ImagePreset preset) {
    if (preset == null) {
      return false;
    }
    Bitmap originalBitmap = mOriginalBitmap;

    if (originalBitmap == null) {
      return false;
    }

    RenderScript RS = getRenderScriptContext();

    Allocation filtersOnlyOriginalAllocation = mFiltersOnlyOriginalAllocation;
    mFiltersOnlyOriginalAllocation =
        Allocation.createFromBitmap(
            RS, originalBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
    if (filtersOnlyOriginalAllocation != null) {
      filtersOnlyOriginalAllocation.destroy();
    }

    Allocation originalAllocation = mOriginalAllocation;
    mResizedOriginalBitmap = preset.applyGeometry(originalBitmap, mEnvironment);
    mOriginalAllocation =
        Allocation.createFromBitmap(
            RS,
            mResizedOriginalBitmap,
            Allocation.MipmapControl.MIPMAP_NONE,
            Allocation.USAGE_SCRIPT);
    if (originalAllocation != null) {
      originalAllocation.destroy();
    }

    return true;
  }
 private synchronized void destroyPixelAllocations() {
   if (DEBUG) {
     Log.v(LOGTAG, "destroyPixelAllocations in " + getName());
   }
   if (mInPixelsAllocation != null) {
     mInPixelsAllocation.destroy();
     mInPixelsAllocation = null;
   }
   if (mOutPixelsAllocation != null) {
     mOutPixelsAllocation.destroy();
     mOutPixelsAllocation = null;
   }
   mWidth = 0;
   mHeight = 0;
 }
  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();
    }
  }
Ejemplo n.º 5
0
 public void destroy() {
   if (mIndexAlloc != null) {
     mIndexAlloc.destroy();
     mIndexAlloc = null;
   }
   if (mInAlloc != null) {
     mInAlloc.destroy();
     mInAlloc = null;
   }
   if (mOutAlloc != null) {
     mOutAlloc.destroy();
     mOutAlloc = null;
   }
   if (mIndexAlloc2 != null) {
     mIndexAlloc2.destroy();
     mIndexAlloc2 = null;
   }
   if (mInAlloc2 != null) {
     mInAlloc2.destroy();
     mInAlloc2 = null;
   }
   if (mOutAlloc2 != null) {
     mOutAlloc2.destroy();
     mOutAlloc2 = null;
   }
   if (mScript != null) {
     mScript.destroy();
     mScript = null;
   }
   if (mRS != null) {
     mRS.destroy();
     mRS = null;
   }
   mOutput = null;
   mOutputLength = -1;
   mOutput2 = null;
   mOutputLength2 = -1;
 }