content: package com.google.android.material.internal;
  
  import android.graphics.Matrix;
  import android.graphics.Rect;
  import android.graphics.RectF;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.ViewParent;
  
  public class DescendantOffsetUtils {
      private static final ThreadLocal<Matrix> matrix = new ThreadLocal<>();
      private static final ThreadLocal<RectF> rectF = new ThreadLocal<>();
  
      public static void getDescendantRect(ViewGroup parent, View descendant, Rect out) {
          out.set(0, 0, descendant.getWidth(), descendant.getHeight());
          offsetDescendantRect(parent, descendant, out);
      }
  
      private static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) {
          ViewParent parent = view.getParent();
          if ((parent instanceof View) && parent != target) {
              View view2 = (View) parent;
              offsetDescendantMatrix(target, view2, m);
              m.preTranslate((float) (-view2.getScrollX()), (float) (-view2.getScrollY()));
          }
          m.preTranslate((float) view.getLeft(), (float) view.getTop());
          if (!view.getMatrix().isIdentity()) {
              m.preConcat(view.getMatrix());
          }
      }
  
      public static void offsetDescendantRect(ViewGroup parent, View descendant, Rect rect) {
          ThreadLocal<Matrix> threadLocal = matrix;
          Matrix matrix2 = threadLocal.get();
          if (matrix2 == null) {
              matrix2 = new Matrix();
              threadLocal.set(matrix2);
          } else {
              matrix2.reset();
          }
          offsetDescendantMatrix(parent, descendant, matrix2);
          ThreadLocal<RectF> threadLocal2 = rectF;
          RectF rectF2 = threadLocal2.get();
          if (rectF2 == null) {
              rectF2 = new RectF();
              threadLocal2.set(rectF2);
          }
          rectF2.set(rect);
          matrix2.mapRect(rectF2);
          rect.set((int) (rectF2.left + 0.5f), (int) (rectF2.top + 0.5f), (int) (rectF2.right + 0.5f), (int) (rectF2.bottom + 0.5f));
      }
  }
  