Use SkPaint.nothingToDraw instead of PaintUtils helper.
The PaintUtils helper is now shared between all pipelines and was
missing a quick reject test for drawLoopers which are used in
view.setShadowLayer and supported in the Skia pipelines.
Bug: 35809097
Test: added hwui unit test and verified in DocumentsUI app
Change-Id: I3c4a988f1c42b7f421f78ac3659af1daee910ea2
diff --git a/libs/hwui/tests/unit/SkiaCanvasTests.cpp b/libs/hwui/tests/unit/SkiaCanvasTests.cpp
index 0ac09ac..7fb75dc 100644
--- a/libs/hwui/tests/unit/SkiaCanvasTests.cpp
+++ b/libs/hwui/tests/unit/SkiaCanvasTests.cpp
@@ -18,6 +18,7 @@
#include <gtest/gtest.h>
#include <RecordingCanvas.h>
+#include <SkBlurDrawLooper.h>
#include <SkPicture.h>
#include <SkPictureRecorder.h>
@@ -59,3 +60,21 @@
EXPECT_EQ(directOp->unmappedBounds, pictureOp->unmappedBounds);
EXPECT_EQ(directOp->localMatrix, pictureOp->localMatrix);
}
+
+TEST(SkiaCanvas, drawShadowLayer) {
+ auto surface = SkSurface::MakeRasterN32Premul(10, 10);
+ SkiaCanvas canvas(surface->getCanvas());
+
+ // clear to white
+ canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrc);
+
+ SkPaint paint;
+ // it is transparent to ensure that we still draw the rect since it has a looper
+ paint.setColor(SK_ColorTRANSPARENT);
+ // this is how view's shadow layers are implemented
+ paint.setLooper(SkBlurDrawLooper::Make(0xF0000000, 6.0f, 0, 10));
+ canvas.drawRect(3, 3, 7, 7, paint);
+
+ ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorWHITE);
+ ASSERT_NE(TestUtils::getColor(surface, 5, 5), SK_ColorWHITE);
+}