[Impeller] Support applying color filters on the CPU for the RRect fast path. (flutter/engine#46281)
Resolves https://github.com/flutter/flutter/issues/133354. Fixes and speeds up blended rrect blurs. Before:  After: 
This commit is contained in:
@@ -2988,7 +2988,7 @@ TEST_P(AiksTest, CanRenderForegroundAdvancedBlendWithMaskBlur) {
|
||||
canvas.ClipRect(Rect::MakeXYWH(100, 150, 400, 400));
|
||||
canvas.DrawCircle({400, 400}, 200,
|
||||
{
|
||||
.color = Color::White(),
|
||||
.color = Color::Grey(),
|
||||
.color_filter = ColorFilter::MakeBlend(
|
||||
BlendMode::kColor, Color::Green()),
|
||||
.mask_blur_descriptor =
|
||||
|
||||
@@ -117,4 +117,10 @@ bool SolidRRectBlurContents::Render(const ContentContext& renderer,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SolidRRectBlurContents::ApplyColorFilter(
|
||||
const ColorFilterProc& color_filter_proc) {
|
||||
color_ = color_filter_proc(color_);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -43,6 +43,10 @@ class SolidRRectBlurContents final : public Contents {
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const override;
|
||||
|
||||
// |Contents|
|
||||
[[nodiscard]] bool ApplyColorFilter(
|
||||
const ColorFilterProc& color_filter_proc) override;
|
||||
|
||||
private:
|
||||
std::optional<Rect> rect_;
|
||||
Scalar corner_radius_;
|
||||
|
||||
Reference in New Issue
Block a user