Exemple #1
0
  public void onDrawFrame(GL10 unused) {
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

    Matrix.setIdentityM(mMMatrix, 0);

    boolean stillAnimating = mCrossfadeAnimator.tick();
    stillAnimating |= mBlurAnimator.tick();

    if (mBlurRelatedToArtDetailMode) {
      mCurrentGLPictureSet.recomputeTransformMatrices();
      mNextGLPictureSet.recomputeTransformMatrices();
    }

    float dimAmount = mCurrentGLPictureSet.mDimAmount;
    mCurrentGLPictureSet.drawFrame(1);
    if (mCrossfadeAnimator.isRunning()) {
      dimAmount =
          MathUtil.interpolate(
              dimAmount, mNextGLPictureSet.mDimAmount, mCrossfadeAnimator.currentValue());
      mNextGLPictureSet.drawFrame(mCrossfadeAnimator.currentValue());
    }

    mColorOverlay.setColor(
        Color.argb((int) (dimAmount * mBlurAnimator.currentValue() / mBlurKeyframes), 0, 0, 0));
    mColorOverlay.draw(mMMatrix); // don't need any perspective or anything for color overlay

    if (stillAnimating) {
      mCallbacks.requestRender();
    }
  }
Exemple #2
0
  public void setAndConsumeBitmapRegionLoader(final BitmapRegionLoader bitmapRegionLoader) {
    if (!mSurfaceCreated) {
      mQueuedNextBitmapRegionLoader = bitmapRegionLoader;
      return;
    }

    if (mCrossfadeAnimator.isRunning()) {
      if (mQueuedNextBitmapRegionLoader != null) {
        mQueuedNextBitmapRegionLoader.destroy();
      }
      mQueuedNextBitmapRegionLoader = bitmapRegionLoader;
      return;
    }

    mNextGLPictureSet.load(bitmapRegionLoader);

    mCrossfadeAnimator
        .from(0)
        .to(1)
        .withDuration(CROSSFADE_ANIMATION_DURATION)
        .withEndListener(
            new Runnable() {
              @Override
              public void run() {
                // swap current and next picturesets
                final GLPictureSet oldGLPictureSet = mCurrentGLPictureSet;
                mCurrentGLPictureSet = mNextGLPictureSet;
                mNextGLPictureSet = new GLPictureSet(oldGLPictureSet.mId);
                mCallbacks.requestRender();
                oldGLPictureSet.destroyPictures();
                System.gc();
                if (mQueuedNextBitmapRegionLoader != null) {
                  BitmapRegionLoader queuedNextBitmapRegionLoader = mQueuedNextBitmapRegionLoader;
                  mQueuedNextBitmapRegionLoader = null;
                  setAndConsumeBitmapRegionLoader(queuedNextBitmapRegionLoader);
                }
              }
            })
        .start();
    mCallbacks.requestRender();
  }