Skip to content

Commit

Permalink
Bug 1370564 - Add suppport for blur filter. r=kats
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: EYoYbbIs3wH

--HG--
extra : rebase_source : afb1030fbd3592fa5a373d0657d345ec45d70d11
  • Loading branch information
mephisto41 committed Oct 20, 2017
1 parent d2222ba commit 392d544
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions layout/painting/nsDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9581,6 +9581,13 @@ nsDisplayFilter::PaintAsLayer(nsDisplayListBuilder* aBuilder,
nsDisplayFilterGeometry::UpdateDrawResult(this, imgParams.result);
}

static float
ClampStdDeviation(float aStdDeviation)
{
// Cap software blur radius for performance reasons.
return std::min(std::max(0.0f, aStdDeviation), 100.0f);
}

bool
nsDisplayFilter::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
Expand Down Expand Up @@ -9611,6 +9618,18 @@ nsDisplayFilter::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuild
wrFilters.AppendElement(filterOp);
break;
}
case NS_STYLE_FILTER_BLUR: {
float appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
mozilla::wr::WrFilterOp filterOp = {
wr::ToWrFilterOpType(filter.GetType()),
ClampStdDeviation(
NSAppUnitsToFloatPixels(
filter.GetFilterParameter().GetCoordValue(),
appUnitsPerDevPixel)),
};
wrFilters.AppendElement(filterOp);
break;
}
default:
return false;
}
Expand Down

0 comments on commit 392d544

Please sign in to comment.