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(); } }
private void onViewportChanged() { mCurrentGLPictureSet.recomputeTransformMatrices(); mNextGLPictureSet.recomputeTransformMatrices(); if (mSurfaceCreated) { mCallbacks.requestRender(); } }
public void onSurfaceChanged(GL10 unused, int width, int height) { GLES20.glViewport(0, 0, width, height); hintViewportSize(width, height); if (!mDemoMode && !mPreview) { // Reset art detail viewports ArtDetailViewport.getInstance().setViewport(0, 0, 0, 0, 0, false); ArtDetailViewport.getInstance().setViewport(1, 0, 0, 0, 0, false); } mCurrentGLPictureSet.recomputeTransformMatrices(); mNextGLPictureSet.recomputeTransformMatrices(); recomputeMaxPrescaledBlurPixels(); }
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(); }
public void destroy() { mCurrentGLPictureSet.destroyPictures(); mNextGLPictureSet.destroyPictures(); }