Fix for partial filter subregion specification with deferred filters.

Filter primitive subregions are specified as x/y/width/height, while
skia crop rects are left/right/top/bottom.  If x is set but
width is not, we were only sending the left edge. We must also tell skia
the right edge, in order to preserve the rect's original width.
Similarly when y is specified but height is not, we must tell skia the
new bottom edge.

Also changed all this code to use FloatRect instead of SkRect, since
these relationships are easier to express.

Covered by layout test svg/batik/filters/filterRegions.svg, when run
with --enable-deferred-filters.

BUG=

Review URL: https://codereview.chromium.org/212803005

git-svn-id: svn://svn.chromium.org/blink/trunk@170116 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 479c4230
......@@ -544,24 +544,26 @@ PassRefPtr<SkImageFilter> FilterEffect::createImageFilter(SkiaImageFilterBuilder
SkImageFilter::CropRect FilterEffect::getCropRect(const FloatSize& cropOffset) const
{
SkRect rect = filter()->filterRegion();
FloatRect rect = filter()->filterRegion();
uint32_t flags = 0;
FloatRect boundaries = effectBoundaries();
boundaries.move(cropOffset);
if (hasX()) {
rect.fLeft = boundaries.x();
rect.setX(boundaries.x());
flags |= SkImageFilter::CropRect::kHasLeft_CropEdge;
flags |= SkImageFilter::CropRect::kHasRight_CropEdge;
}
if (hasY()) {
rect.fTop = boundaries.y();
rect.setY(boundaries.y());
flags |= SkImageFilter::CropRect::kHasTop_CropEdge;
flags |= SkImageFilter::CropRect::kHasBottom_CropEdge;
}
if (hasWidth()) {
rect.fRight = rect.fLeft + boundaries.width();
rect.setWidth(boundaries.width());
flags |= SkImageFilter::CropRect::kHasRight_CropEdge;
}
if (hasHeight()) {
rect.fBottom = rect.fTop + boundaries.height();
rect.setHeight(boundaries.height());
flags |= SkImageFilter::CropRect::kHasBottom_CropEdge;
}
rect = filter()->mapLocalRectToAbsoluteRect(rect);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment