Automatically scale animated webp post-decode in Android

Due to limitations in libwebp and the constraints of the Skia API, decoding animated webp images into a scaled bitmap won't be correct (similar to this bug: https://b.corp.google.com/issues/40038560).
However for android we can make it so that post-decode scaling is automatically applied instead of decoding into a scaled bitmap while not breaking any requirements for this API: https://developer.android.com/reference/android/graphics/ImageDecoder#setTargetSize(int,%20int).

For reference this change makes it such that the scaling is applied to the fMatrix by modifying computeSampleSize here: https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/src/android/SkAnimatedImage.cpp;drc=e56bb46671597b175df302e5b3b2b6c26c7a7d04;l=97

Bug: 375423074
Change-Id: I9c73524042380c2d739746b900b7c0aa6173ce7f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/936537
Commit-Queue: Daniel Dilan <danieldilan@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 13db23b..d179e54 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -412,6 +412,9 @@
      *  If a scanline decode is in progress, scanline mode will end, requiring the client to call
      *  startScanlineDecode() in order to return to decoding scanlines.
      *
+     *  For certain codecs, reading into a smaller bitmap than the original dimensions may not
+     *  produce correct results (e.g. animated webp).
+     *
      *  @return Result kSuccess, or another value explaining the type of failure.
      */
     Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options*);
diff --git a/src/codec/SkAndroidCodec.cpp b/src/codec/SkAndroidCodec.cpp
index c2eaefa..c51250b 100644
--- a/src/codec/SkAndroidCodec.cpp
+++ b/src/codec/SkAndroidCodec.cpp
@@ -347,7 +347,7 @@
     }
 }
 
-static bool supports_any_down_scale(const SkCodec* codec) {
+static bool is_webp(const SkCodec* codec) {
     return codec->getEncodedFormat() == SkEncodedImageFormat::kWEBP;
 }
 
@@ -383,7 +383,11 @@
                                      std::max(1, desiredSize->height()));
     }
 
-    if (supports_any_down_scale(fCodec.get())) {
+    if (is_webp(fCodec.get())) {
+        if (fCodec->getFrameCount() > 1) {
+           // Cannot downscale animated webp
+           *desiredSize = origDims;
+        }
         return 1;
     }