File tree 3 files changed +26
-6
lines changed 3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -330,12 +330,7 @@ bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
330
330
Paint rrect_paint = paint;
331
331
332
332
// Absorb the color filter, if any.
333
- if (rrect_paint.HasColorFilter ()) {
334
- rrect_paint.color =
335
- rrect_paint.GetColorFilter ()->GetCPUColorFilterProc ()(paint.color );
336
- rrect_paint.color_filter = nullptr ;
337
- rrect_paint.invert_colors = false ;
338
- }
333
+ rrect_paint.AbsorbColorFilterIntoColor ();
339
334
340
335
// In some cases, we need to render the mask blur to a separate layer.
341
336
//
Original file line number Diff line number Diff line change @@ -199,4 +199,20 @@ bool Paint::HasColorFilter() const {
199
199
return !!color_filter || invert_colors;
200
200
}
201
201
202
+ void Paint::AbsorbColorFilterIntoColor () {
203
+ // This method should only ever be used when the caller knows that the color
204
+ // source is a solid color. This is not a valid way to apply the color filter
205
+ // for other color sources.
206
+ FML_DCHECK (color_source.GetType () == ColorSource::Type::kColor );
207
+
208
+ std::shared_ptr<ColorFilter> final_color_filter = GetColorFilter ();
209
+ if (!final_color_filter) {
210
+ return ; // Nothing to absorb.
211
+ }
212
+
213
+ color = GetColorFilter ()->GetCPUColorFilterProc ()(color);
214
+ color_filter = nullptr ;
215
+ invert_colors = false ;
216
+ }
217
+
202
218
} // namespace impeller
Original file line number Diff line number Diff line change @@ -104,6 +104,15 @@ struct Paint {
104
104
std::shared_ptr<Contents> input,
105
105
ColorFilterContents::AbsorbOpacity absorb_opacity =
106
106
ColorFilterContents::AbsorbOpacity::kNo ) const ;
107
+
108
+ // / @brief Absorbs the color filter (if any) into the Paint's color.
109
+ // / There are multiple paint attributes that can result in a
110
+ // / filter being applied.
111
+ // / This is only valid if the color source is set is a solid
112
+ // / color.
113
+ void AbsorbColorFilterIntoColor ();
114
+
115
+ friend class Canvas ;
107
116
};
108
117
109
118
} // namespace impeller
You can’t perform that action at this time.
0 commit comments