private void maybeDisposeBackground(
      Canvas canvas, float xScale, float yScale, AnimatedDrawableFrameInfo previousFrameInfo) {
    if (previousFrameInfo.disposalMethod == DisposalMethod.DISPOSE_TO_BACKGROUND) {
      int prevFrameWidth = (int) Math.ceil(previousFrameInfo.width * xScale);
      int prevFrameHeight = (int) Math.ceil(previousFrameInfo.height * yScale);
      int prevXOffset = (int) Math.ceil(previousFrameInfo.xOffset * xScale);
      int prevYOffset = (int) Math.ceil(previousFrameInfo.yOffset * yScale);
      Rect prevFrameSurface =
          new Rect(
              prevXOffset,
              prevYOffset,
              prevXOffset + prevFrameWidth,
              prevYOffset + prevFrameHeight);
      canvas.drawRect(prevFrameSurface, mTransparentPaint);
    }
  }
An {@link AnimatedDrawableBackend} that renders {@link AnimatedImage}.
animated-base/src/main/java/com/facebook/imagepipeline/animated/impl/AnimatedDrawableBackendImpl.java