Exemplo n.º 1
0
  @Override
  public Bitmap snapshot(int doc, int gs, boolean transparent) {
    final Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
    final CanvasAdapter canvasAdapter = new CanvasAdapter(this, mImageCache);
    final Longs docs = new Longs(doc, 0);

    bitmap.eraseColor(transparent ? Color.TRANSPARENT : mBkColor);
    int n = drawShapes(docs, gs, null, new Canvas(bitmap), canvasAdapter, false);
    Log.d(TAG, "snapshot(doc): " + n);
    canvasAdapter.delete();

    return bitmap;
  }
Exemplo n.º 2
0
  @Override
  public void tearDown() {
    if (mViewAdapter == null) {
      return;
    }

    ViewUtil.onRemoveView(this);
    mViewAdapter.stop(null);

    if (mImageCache != null) {
      synchronized (mImageCache) {
        mImageCache.clear();
      }
      mImageCache = null;
    }
    if (mRegenBitmap != null) {
      synchronized (mRegenBitmap) {
        mRegenBitmap.recycle();
      }
      mRegenBitmap = null;
    }
    if (mCachedBitmap != null) {
      synchronized (mCachedBitmap) {
        mCachedBitmap.recycle();
      }
      mCachedBitmap = null;
    }
    synchronized (GiCoreView.class) {
      mCoreView.destoryView(mViewAdapter);
      mViewAdapter.delete();
      mViewAdapter = null;
      mCoreView.delete();
      mCoreView = null;
    }
    if (mCanvasOnDraw != null) {
      mCanvasOnDraw.delete();
      mCanvasOnDraw = null;
    }
    if (mCanvasRegen != null) {
      mCanvasRegen.delete();
      mCanvasRegen = null;
    }
    if (mGestureListener != null) {
      mGestureListener.release();
      mGestureListener = null;
    }
    mGestureDetector = null;
    mMainView = null;
  }
Exemplo n.º 3
0
  @Override
  public Bitmap snapshot(boolean transparent) {
    if (mCachedBitmap != null && transparent == (mBkColor == Color.TRANSPARENT)) {
      synchronized (mCachedBitmap) {
        return mCachedBitmap.copy(Config.ARGB_8888, false);
      }
    }

    final Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
    final CanvasAdapter canvasAdapter = new CanvasAdapter(this, mImageCache);

    bitmap.eraseColor(transparent ? Color.TRANSPARENT : mBkColor);
    int n = drawShapes(new Canvas(bitmap), canvasAdapter, false);
    Log.d(TAG, "snapshot: " + n);
    canvasAdapter.delete();

    return bitmap;
  }
Exemplo n.º 4
0
  private int drawShapes(
      Longs docs, int gs, Longs shapes, Canvas canvas, CanvasAdapter adapter, boolean dyndraw) {
    int n = 0;

    if (adapter.beginPaint(canvas)) {
      if (mCachedBitmap == null || !dyndraw) {
        if (this.getBackground() != null) {
          this.getBackground().draw(canvas);
        }
        n = mCoreView.drawAll(docs, gs, adapter);
      } else if (mCachedBitmap != null) {
        synchronized (mCachedBitmap) {
          canvas.drawBitmap(mCachedBitmap, 0, 0, null);
          n++;
        }
      }
      if (dyndraw) {
        mCoreView.dynDraw(shapes, gs, adapter);
      }
      adapter.endPaint();
    }

    return n;
  }