AnimationRoundHelper.smali
.class public Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;
.super Ljava/lang/Object;
.source "SourceFile"
# instance fields
.field private final mBitmapBounds:Landroid/graphics/RectF;
.field private mBound:Landroid/graphics/Rect;
.field private final mBoundsTransform:Landroid/graphics/Matrix;
.field private final mCornerRadii:[F
.field private final mDrawableBounds:Landroid/graphics/RectF;
.field private mImageHeight:I
.field private mImageWidth:I
.field private final mInverseParentTransform:Landroid/graphics/Matrix;
.field private mIsCircle:Z
.field private mIsPathDirty:Z
.field private mIsShaderTransformDirty:Z
.field private mLastBitmap:Ljava/lang/ref/WeakReference;
.field private final mPaint:Landroid/graphics/Paint;
.field private final mParentTransform:Landroid/graphics/Matrix;
.field private final mPath:Landroid/graphics/Path;
.field private final mPrevBoundsTransform:Landroid/graphics/Matrix;
.field private final mPrevParentTransform:Landroid/graphics/Matrix;
.field private final mPrevRootBounds:Landroid/graphics/RectF;
.field private final mRootBounds:Landroid/graphics/RectF;
.field private final mTransform:Landroid/graphics/Matrix;
.field private mTransformCallback:Lcom/facebook/drawee/drawable/TransformCallback;
# direct methods
.method public constructor <init>(Lcom/facebook/drawee/drawable/TransformCallback;Lcom/facebook/fresco/animation/drawable/AnimationRoundParams;Landroid/graphics/Rect;II)V
.registers 8
.line 55
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/16 v0, 0x8
new-array v0, v0, [F
.line 24
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mCornerRadii:[F
.line 26
new-instance v0, Landroid/graphics/RectF;
invoke-direct {v0}, Landroid/graphics/RectF;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
.line 27
new-instance v0, Landroid/graphics/RectF;
invoke-direct {v0}, Landroid/graphics/RectF;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevRootBounds:Landroid/graphics/RectF;
.line 28
new-instance v0, Landroid/graphics/RectF;
invoke-direct {v0}, Landroid/graphics/RectF;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBitmapBounds:Landroid/graphics/RectF;
.line 29
new-instance v0, Landroid/graphics/RectF;
invoke-direct {v0}, Landroid/graphics/RectF;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mDrawableBounds:Landroid/graphics/RectF;
.line 31
new-instance v0, Landroid/graphics/Matrix;
invoke-direct {v0}, Landroid/graphics/Matrix;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBoundsTransform:Landroid/graphics/Matrix;
.line 32
new-instance v0, Landroid/graphics/Matrix;
invoke-direct {v0}, Landroid/graphics/Matrix;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevBoundsTransform:Landroid/graphics/Matrix;
.line 34
new-instance v0, Landroid/graphics/Matrix;
invoke-direct {v0}, Landroid/graphics/Matrix;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mParentTransform:Landroid/graphics/Matrix;
.line 35
new-instance v0, Landroid/graphics/Matrix;
invoke-direct {v0}, Landroid/graphics/Matrix;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevParentTransform:Landroid/graphics/Matrix;
.line 36
new-instance v0, Landroid/graphics/Matrix;
invoke-direct {v0}, Landroid/graphics/Matrix;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mInverseParentTransform:Landroid/graphics/Matrix;
.line 38
new-instance v0, Landroid/graphics/Matrix;
invoke-direct {v0}, Landroid/graphics/Matrix;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mTransform:Landroid/graphics/Matrix;
.line 40
new-instance v0, Landroid/graphics/Path;
invoke-direct {v0}, Landroid/graphics/Path;-><init>()V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPath:Landroid/graphics/Path;
const/4 v0, 0x1
.line 41
iput-boolean v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsPathDirty:Z
.line 42
new-instance v1, Landroid/graphics/Paint;
invoke-direct {v1}, Landroid/graphics/Paint;-><init>()V
iput-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPaint:Landroid/graphics/Paint;
.line 43
iput-boolean v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsShaderTransformDirty:Z
.line 56
iput-object p1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mTransformCallback:Lcom/facebook/drawee/drawable/TransformCallback;
.line 57
iput-object p3, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBound:Landroid/graphics/Rect;
.line 58
iput p4, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mImageWidth:I
.line 59
iput p5, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mImageHeight:I
.line 60
invoke-interface {p2}, Lcom/facebook/fresco/animation/drawable/AnimationRoundParams;->getRoundAsCircle()Z
move-result p1
iput-boolean p1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsCircle:Z
.line 61
iget-object p1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mCornerRadii:[F
invoke-interface {p2}, Lcom/facebook/fresco/animation/drawable/AnimationRoundParams;->getRoundWidth()I
move-result p2
int-to-float p2, p2
invoke-static {p1, p2}, Ljava/util/Arrays;->fill([FF)V
return-void
.end method
.method private updatePaint(Landroid/graphics/Bitmap;)V
.registers 5
.line 113
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mLastBitmap:Ljava/lang/ref/WeakReference;
if-eqz v0, :cond_a
invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;
move-result-object v0
if-eq v0, p1, :cond_20
.line 114
:cond_a
new-instance v0, Ljava/lang/ref/WeakReference;
invoke-direct {v0, p1}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V
iput-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mLastBitmap:Ljava/lang/ref/WeakReference;
.line 115
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPaint:Landroid/graphics/Paint;
new-instance v1, Landroid/graphics/BitmapShader;
sget-object v2, Landroid/graphics/Shader$TileMode;->CLAMP:Landroid/graphics/Shader$TileMode;
invoke-direct {v1, p1, v2, v2}, Landroid/graphics/BitmapShader;-><init>(Landroid/graphics/Bitmap;Landroid/graphics/Shader$TileMode;Landroid/graphics/Shader$TileMode;)V
invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setShader(Landroid/graphics/Shader;)Landroid/graphics/Shader;
const/4 p1, 0x1
.line 116
iput-boolean p1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsShaderTransformDirty:Z
.line 118
:cond_20
iget-boolean p1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsShaderTransformDirty:Z
if-eqz p1, :cond_32
.line 119
iget-object p1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPaint:Landroid/graphics/Paint;
invoke-virtual {p1}, Landroid/graphics/Paint;->getShader()Landroid/graphics/Shader;
move-result-object p1
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mTransform:Landroid/graphics/Matrix;
invoke-virtual {p1, v0}, Landroid/graphics/Shader;->setLocalMatrix(Landroid/graphics/Matrix;)V
const/4 p1, 0x0
.line 120
iput-boolean p1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsShaderTransformDirty:Z
:cond_32
return-void
.end method
.method private updatePath()V
.registers 6
.line 96
iget-boolean v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsPathDirty:Z
if-eqz v0, :cond_49
.line 97
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPath:Landroid/graphics/Path;
invoke-virtual {v0}, Landroid/graphics/Path;->reset()V
.line 98
iget-boolean v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsCircle:Z
if-eqz v0, :cond_34
.line 99
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPath:Landroid/graphics/Path;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
.line 100
invoke-virtual {v1}, Landroid/graphics/RectF;->centerX()F
move-result v1
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
.line 101
invoke-virtual {v2}, Landroid/graphics/RectF;->centerY()F
move-result v2
iget-object v3, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
.line 102
invoke-virtual {v3}, Landroid/graphics/RectF;->width()F
move-result v3
iget-object v4, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
invoke-virtual {v4}, Landroid/graphics/RectF;->height()F
move-result v4
invoke-static {v3, v4}, Ljava/lang/Math;->min(FF)F
move-result v3
const/high16 v4, 0x40000000 # 2.0f
div-float/2addr v3, v4
sget-object v4, Landroid/graphics/Path$Direction;->CW:Landroid/graphics/Path$Direction;
.line 99
invoke-virtual {v0, v1, v2, v3, v4}, Landroid/graphics/Path;->addCircle(FFFLandroid/graphics/Path$Direction;)V
goto :goto_3f
.line 105
:cond_34
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPath:Landroid/graphics/Path;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mCornerRadii:[F
sget-object v3, Landroid/graphics/Path$Direction;->CW:Landroid/graphics/Path$Direction;
invoke-virtual {v0, v1, v2, v3}, Landroid/graphics/Path;->addRoundRect(Landroid/graphics/RectF;[FLandroid/graphics/Path$Direction;)V
.line 107
:goto_3f
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPath:Landroid/graphics/Path;
sget-object v1, Landroid/graphics/Path$FillType;->WINDING:Landroid/graphics/Path$FillType;
invoke-virtual {v0, v1}, Landroid/graphics/Path;->setFillType(Landroid/graphics/Path$FillType;)V
const/4 v0, 0x0
.line 108
iput-boolean v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsPathDirty:Z
:cond_49
return-void
.end method
.method private updateTransform()V
.registers 5
.line 65
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mTransformCallback:Lcom/facebook/drawee/drawable/TransformCallback;
if-eqz v0, :cond_11
.line 66
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mParentTransform:Landroid/graphics/Matrix;
invoke-interface {v0, v1}, Lcom/facebook/drawee/drawable/TransformCallback;->getTransform(Landroid/graphics/Matrix;)V
.line 67
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mTransformCallback:Lcom/facebook/drawee/drawable/TransformCallback;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
invoke-interface {v0, v1}, Lcom/facebook/drawee/drawable/TransformCallback;->getRootBounds(Landroid/graphics/RectF;)V
goto :goto_1d
.line 69
:cond_11
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mParentTransform:Landroid/graphics/Matrix;
invoke-virtual {v0}, Landroid/graphics/Matrix;->reset()V
.line 70
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBound:Landroid/graphics/Rect;
invoke-virtual {v0, v1}, Landroid/graphics/RectF;->set(Landroid/graphics/Rect;)V
.line 73
:goto_1d
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBitmapBounds:Landroid/graphics/RectF;
iget v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mImageWidth:I
int-to-float v1, v1
iget v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mImageHeight:I
int-to-float v2, v2
const/4 v3, 0x0
invoke-virtual {v0, v3, v3, v1, v2}, Landroid/graphics/RectF;->set(FFFF)V
.line 74
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mDrawableBounds:Landroid/graphics/RectF;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBound:Landroid/graphics/Rect;
invoke-virtual {v0, v1}, Landroid/graphics/RectF;->set(Landroid/graphics/Rect;)V
.line 75
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBoundsTransform:Landroid/graphics/Matrix;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBitmapBounds:Landroid/graphics/RectF;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mDrawableBounds:Landroid/graphics/RectF;
sget-object v3, Landroid/graphics/Matrix$ScaleToFit;->FILL:Landroid/graphics/Matrix$ScaleToFit;
invoke-virtual {v0, v1, v2, v3}, Landroid/graphics/Matrix;->setRectToRect(Landroid/graphics/RectF;Landroid/graphics/RectF;Landroid/graphics/Matrix$ScaleToFit;)Z
.line 77
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mParentTransform:Landroid/graphics/Matrix;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevParentTransform:Landroid/graphics/Matrix;
invoke-virtual {v0, v1}, Landroid/graphics/Matrix;->equals(Ljava/lang/Object;)Z
move-result v0
const/4 v1, 0x1
if-eqz v0, :cond_50
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBoundsTransform:Landroid/graphics/Matrix;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevBoundsTransform:Landroid/graphics/Matrix;
.line 78
invoke-virtual {v0, v2}, Landroid/graphics/Matrix;->equals(Ljava/lang/Object;)Z
move-result v0
if-nez v0, :cond_75
.line 79
:cond_50
iput-boolean v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsShaderTransformDirty:Z
.line 81
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mParentTransform:Landroid/graphics/Matrix;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mInverseParentTransform:Landroid/graphics/Matrix;
invoke-virtual {v0, v2}, Landroid/graphics/Matrix;->invert(Landroid/graphics/Matrix;)Z
.line 82
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mTransform:Landroid/graphics/Matrix;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mParentTransform:Landroid/graphics/Matrix;
invoke-virtual {v0, v2}, Landroid/graphics/Matrix;->set(Landroid/graphics/Matrix;)V
.line 83
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mTransform:Landroid/graphics/Matrix;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBoundsTransform:Landroid/graphics/Matrix;
invoke-virtual {v0, v2}, Landroid/graphics/Matrix;->preConcat(Landroid/graphics/Matrix;)Z
.line 85
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevParentTransform:Landroid/graphics/Matrix;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mParentTransform:Landroid/graphics/Matrix;
invoke-virtual {v0, v2}, Landroid/graphics/Matrix;->set(Landroid/graphics/Matrix;)V
.line 86
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevBoundsTransform:Landroid/graphics/Matrix;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mBoundsTransform:Landroid/graphics/Matrix;
invoke-virtual {v0, v2}, Landroid/graphics/Matrix;->set(Landroid/graphics/Matrix;)V
.line 89
:cond_75
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
iget-object v2, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevRootBounds:Landroid/graphics/RectF;
invoke-virtual {v0, v2}, Landroid/graphics/RectF;->equals(Ljava/lang/Object;)Z
move-result v0
if-nez v0, :cond_88
.line 90
iput-boolean v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mIsPathDirty:Z
.line 91
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPrevRootBounds:Landroid/graphics/RectF;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mRootBounds:Landroid/graphics/RectF;
invoke-virtual {v0, v1}, Landroid/graphics/RectF;->set(Landroid/graphics/RectF;)V
:cond_88
return-void
.end method
# virtual methods
.method public drawBitmap(Landroid/graphics/Canvas;Landroid/graphics/Bitmap;)V
.registers 5
.line 125
invoke-direct {p0}, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->updateTransform()V
.line 126
invoke-direct {p0}, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->updatePath()V
.line 127
invoke-direct {p0, p2}, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->updatePaint(Landroid/graphics/Bitmap;)V
.line 128
invoke-virtual {p1}, Landroid/graphics/Canvas;->save()I
move-result p2
.line 129
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mInverseParentTransform:Landroid/graphics/Matrix;
invoke-virtual {p1, v0}, Landroid/graphics/Canvas;->concat(Landroid/graphics/Matrix;)V
.line 130
iget-object v0, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPath:Landroid/graphics/Path;
iget-object v1, p0, Lcom/facebook/fresco/animation/drawable/AnimationRoundHelper;->mPaint:Landroid/graphics/Paint;
invoke-virtual {p1, v0, v1}, Landroid/graphics/Canvas;->drawPath(Landroid/graphics/Path;Landroid/graphics/Paint;)V
.line 131
invoke-virtual {p1, p2}, Landroid/graphics/Canvas;->restoreToCount(I)V
return-void
.end method