Exemplo n.º 1
0
  public void setIsBlurred(final boolean isBlurred, final boolean artDetailMode) {
    if (artDetailMode && !isBlurred && !mDemoMode && !mPreview) {
      // Reset art detail viewport
      ArtDetailViewport.getInstance().setViewport(0, 0, 0, 0, 0, false);
      ArtDetailViewport.getInstance().setViewport(1, 0, 0, 0, 0, false);
    }

    mBlurRelatedToArtDetailMode = artDetailMode;
    mIsBlurred = isBlurred;
    mBlurAnimator.cancel();
    mBlurAnimator
        .to(isBlurred ? mBlurKeyframes : 0)
        .withDuration(BLUR_ANIMATION_DURATION * (mDemoMode ? 5 : 1))
        .withEndListener(
            new Runnable() {
              @Override
              public void run() {
                if (isBlurred && artDetailMode) {
                  System.gc();
                }
              }
            })
        .start();
    mCallbacks.requestRender();
  }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
    private void recomputeTransformMatrices() {
      float screenToBitmapAspectRatio = mAspectRatio / mBitmapAspectRatio;

      // Ensure the bitmap is wider than the screen relatively by applying zoom
      // if necessary. Vary width but keep height the same.
      float zoom = Math.max(1f, 1.15f * screenToBitmapAspectRatio);

      // Total scale factors in both zoom and scale due to aspect ratio.
      float totalScale = zoom / screenToBitmapAspectRatio;

      mCurrentViewport.left =
          MathUtil.interpolate(
              -1f
                  * Math.min(
                      1f,
                      screenToBitmapAspectRatio), // remove screenToBitmapAspectRatio to unconstrain
                                                  // panning amount
              1f * Math.min(1f, screenToBitmapAspectRatio),
              mNormalOffsetX * (totalScale - 1) / totalScale);
      mCurrentViewport.right = mCurrentViewport.left + 2f / totalScale;
      mCurrentViewport.bottom = -1f / zoom;
      mCurrentViewport.top = 1f / zoom;

      float focusAmount = (mBlurKeyframes - mBlurAnimator.currentValue()) / mBlurKeyframes;
      if (mBlurRelatedToArtDetailMode && focusAmount > 0) {
        RectF artDetailViewport = ArtDetailViewport.getInstance().getViewport(mId);
        if (artDetailViewport.width() == 0 || artDetailViewport.height() == 0) {
          if (!mDemoMode && !mPreview) {
            // reset art detail viewport
            ArtDetailViewport.getInstance()
                .setViewport(
                    mId,
                    MathUtil.uninterpolate(-1, 1, mCurrentViewport.left),
                    MathUtil.uninterpolate(1, -1, mCurrentViewport.top),
                    MathUtil.uninterpolate(-1, 1, mCurrentViewport.right),
                    MathUtil.uninterpolate(1, -1, mCurrentViewport.bottom),
                    false);
          }
        } else {
          // interpolate
          mCurrentViewport.left =
              MathUtil.interpolate(
                  mCurrentViewport.left,
                  MathUtil.interpolate(-1, 1, artDetailViewport.left),
                  focusAmount);
          mCurrentViewport.top =
              MathUtil.interpolate(
                  mCurrentViewport.top,
                  MathUtil.interpolate(1, -1, artDetailViewport.top),
                  focusAmount);
          mCurrentViewport.right =
              MathUtil.interpolate(
                  mCurrentViewport.right,
                  MathUtil.interpolate(-1, 1, artDetailViewport.right),
                  focusAmount);
          mCurrentViewport.bottom =
              MathUtil.interpolate(
                  mCurrentViewport.bottom,
                  MathUtil.interpolate(1, -1, artDetailViewport.bottom),
                  focusAmount);
        }
      }

      Matrix.orthoM(
          mPMatrix,
          0,
          mCurrentViewport.left,
          mCurrentViewport.right,
          mCurrentViewport.bottom,
          mCurrentViewport.top,
          1,
          10);
    }