docs: private int prepareCanvasWithClosestCachedFrame(int previousFrameNumber, Canvas canvas) {
      for (int index = previousFrameNumber; index >= 0; index--) {
        FrameNeededResult neededResult = isFrameNeededForRendering(index);
        switch (neededResult) {
          case REQUIRED:
            AnimatedDrawableFrameInfo frameInfo = mAnimatedDrawableBackend.getFrameInfo(index);
            CloseableReference<Bitmap> startBitmap = mCallback.getCachedBitmap(index);
            if (startBitmap != null) {
              try {
                canvas.drawBitmap(startBitmap.get(), 0, 0, null);
                if (frameInfo.disposalMethod == DisposalMethod.DISPOSE_TO_BACKGROUND) {
                  disposeToBackground(canvas, frameInfo);
                }
                return index + 1;
              } finally {
                startBitmap.close();
              }
            } else {
              if (isKeyFrame(index)) {
                return index;
              } else {
                // Keep going.
                break;
              }
            }
          case NOT_REQUIRED:
            return index + 1;
          case ABORT:
            return index;
          case SKIP:
          default:
            // Keep going.
        }
      }
      return 0;
    }