24 int radius = (bounds.width() + bounds.height()) / 6;
30 paint.setAntiAlias(
true);
49 static const int kMaxFrames = 2;
55 auto dimensions = codec->dimensions();
57 fTranslate = std::max(dimensions.width(), dimensions.height())
61 fSize = { fTranslate * kMaxFrames
88 for (
bool usePic : {
true,
false }) {
94 auto image = animatedImage->getCurrentFrame();
98 for (
float scale : { 1.25f, 1.0f, .75f, .5f }) {
100 for (
bool doCrop : {
false,
true }) {
101 for (
bool doPostProcess : {
false,
true }) {
103 const auto origin = codec->getOrigin();
105 auto info = androidCodec->getInfo();
111 info =
info.makeDimensions(scaledSize);
118 unscaledSize.width(), unscaledSize.height()));
120 matrix.mapRect(&cropRectFloat);
127 info, cropRect, std::move(postProcessor));
128 animatedImage->setRepetitionCount(0);
134 canvas->
translate(cropRect.left(), cropRect.top());
136 drawProc(animatedImage);
140 const auto duration = animatedImage->currentFrameDuration();
144 for (
int i = 0; i < fStep; i++) {
145 animatedImage->decodeNextFrame();
static int step(int x, SkScalar min, SkScalar max)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
sk_sp< SkData > GetResourceAsData(const char *resource)
constexpr SkColor SK_ColorTRANSPARENT
static bool SkEncodedOriginSwapsWidthHeight(SkEncodedOrigin origin)
static SkMatrix SkEncodedOriginToMatrix(SkEncodedOrigin origin, int w, int h)
#define SkScalarFloorToInt(x)
SK_API SkString static SkString SkStringPrintf()
static sk_sp< SkPicture > post_processor(const SkRect &bounds)
SkString getName() const override
AnimatedImageGM(const char *path, const char *name, int step, SkIRect cropRect)
SkISize getISize() override
void onDraw(SkCanvas *canvas) override
~AnimatedImageGM() override=default
static std::unique_ptr< SkAndroidCodec > MakeFromCodec(std::unique_ptr< SkCodec >)
static sk_sp< SkAnimatedImage > Make(std::unique_ptr< SkAndroidCodec >, const SkImageInfo &info, SkIRect cropRect, sk_sp< SkPicture > postProcess)
static constexpr int kFinished
void translate(SkScalar dx, SkScalar dy)
void drawPath(const SkPath &path, const SkPaint &paint)
void drawPicture(const SkPicture *picture)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
SkPathBuilder & setFillType(SkPathFillType ft)
SkPathBuilder & addRRect(const SkRRect &, SkPathDirection, unsigned startIndex)
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
static constexpr SkIRect MakeSize(const SkISize &size)
constexpr int32_t height() const
static SkRect Make(const SkISize &size)
void roundOut(SkIRect *dst) const