Fix backdrop effect for prerotation

When doing prerotation the matrix math didn't work out due
to makeImageSnapshot() being rotated already, but then drawn
again into a rotating matrix. Fix this by having BackdropFilterDrawable
do everything in post-rotation space.

Bug: 353827335
Test: SilkFX view blur behind demo
Flag: EXEMPT bugfix
Change-Id: I7b41d95e7e5f15434f9c6481534c74ee998a83ef
diff --git a/libs/hwui/pipeline/skia/BackdropFilterDrawable.cpp b/libs/hwui/pipeline/skia/BackdropFilterDrawable.cpp
index e81cbfb..b6d30b0 100644
--- a/libs/hwui/pipeline/skia/BackdropFilterDrawable.cpp
+++ b/libs/hwui/pipeline/skia/BackdropFilterDrawable.cpp
@@ -86,9 +86,17 @@
         backdropImage = SkImages::MakeWithFilter(backdropImage, backdropFilter, imageSubset,
                                                  imageSubset, &mOutSubset, &mOutOffset);
     }
-    canvas->drawImageRect(backdropImage, SkRect::Make(mOutSubset), mDstBounds,
+
+    // backdropImage & mOutSubset are in post-pre-rotation space, whereas mDstBounds is in
+    // prerotation space. So map dst bounds to post-pre-rotation space & draw there
+    SkRect dst;
+    canvas->getTotalMatrix().mapRect(&dst, mDstBounds);
+    canvas->save();
+    canvas->resetMatrix();
+    canvas->drawImageRect(backdropImage, SkRect::Make(mOutSubset), dst,
                           SkSamplingOptions(SkFilterMode::kLinear), &mPaint,
-                          SkCanvas::kStrict_SrcRectConstraint);
+                          SkCanvas::kFast_SrcRectConstraint);
+    canvas->restore();
 }
 
 }  // namespace skiapipeline
diff --git a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
index ca54087..4b29100 100644
--- a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
+++ b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp
@@ -1280,7 +1280,7 @@
     canvas->drawDrawable(&backdropDrawable);
     // the drawable is still visible, ok to draw.
     EXPECT_EQ(2, canvas->mDrawCounter);
-    EXPECT_EQ(SkRect::MakeLTRB(0, 0, CANVAS_WIDTH - 30, CANVAS_HEIGHT - 30), canvas->mDstBounds);
+    EXPECT_EQ(SkRect::MakeLTRB(30, 30, CANVAS_WIDTH, CANVAS_HEIGHT), canvas->mDstBounds);
 
     canvas->translate(CANVAS_WIDTH, CANVAS_HEIGHT);
     canvas->drawDrawable(&drawable);