@@ -19,6 +19,7 @@ void DisplayListCanvasDispatcher::restore() {
1919}
2020void DisplayListCanvasDispatcher::saveLayer (const SkRect* bounds,
2121 bool restore_with_paint) {
22+ TRACE_EVENT0 (" flutter" , " Canvas::saveLayer" );
2223 canvas_->saveLayer (bounds, restore_with_paint ? &paint () : nullptr );
2324}
2425
@@ -76,7 +77,14 @@ void DisplayListCanvasDispatcher::clipPath(const SkPath& path,
7677}
7778
7879void DisplayListCanvasDispatcher::drawPaint () {
79- canvas_->drawPaint (paint ());
80+ const SkPaint& sk_paint = paint ();
81+ SkImageFilter* filter = sk_paint.getImageFilter ();
82+ if (filter && !filter->asColorFilter (nullptr )) {
83+ // drawPaint does an implicit saveLayer if an SkImageFilter is
84+ // present that cannot be replaced by an SkColorFilter.
85+ TRACE_EVENT0 (" flutter" , " Canvas::saveLayer" );
86+ }
87+ canvas_->drawPaint (sk_paint);
8088}
8189void DisplayListCanvasDispatcher::drawColor (SkColor color, SkBlendMode mode) {
8290 canvas_->drawColor (color, mode);
@@ -170,8 +178,13 @@ void DisplayListCanvasDispatcher::drawAtlas(const sk_sp<SkImage> atlas,
170178void DisplayListCanvasDispatcher::drawPicture (const sk_sp<SkPicture> picture,
171179 const SkMatrix* matrix,
172180 bool render_with_attributes) {
173- canvas_->drawPicture (picture, matrix,
174- render_with_attributes ? &paint () : nullptr );
181+ if (render_with_attributes) {
182+ // drawPicture does an implicit saveLayer if an SkPaint is supplied.
183+ TRACE_EVENT0 (" flutter" , " Canvas::saveLayer" );
184+ canvas_->drawPicture (picture, matrix, &paint ());
185+ } else {
186+ canvas_->drawPicture (picture, matrix, nullptr );
187+ }
175188}
176189void DisplayListCanvasDispatcher::drawDisplayList (
177190 const sk_sp<DisplayList> display_list) {
0 commit comments