Index: Source/core/rendering/svg/RenderSVGResourceFilter.cpp |
diff --git a/Source/core/rendering/svg/RenderSVGResourceFilter.cpp b/Source/core/rendering/svg/RenderSVGResourceFilter.cpp |
index 35472a5471bd3a18f47a78a656dfe156dad5e1f8..8804a56fd04cd936e0f72d46f370f72c6199fbf3 100644 |
--- a/Source/core/rendering/svg/RenderSVGResourceFilter.cpp |
+++ b/Source/core/rendering/svg/RenderSVGResourceFilter.cpp |
@@ -109,17 +109,17 @@ PassRefPtr<SVGFilterBuilder> RenderSVGResourceFilter::buildPrimitives(SVGFilter* |
bool RenderSVGResourceFilter::fitsInMaximumImageSize(const FloatSize& size, FloatSize& scale) |
{ |
- bool matchesFilterSize = true; |
- if (size.width() * scale.width() > kMaxFilterSize) { |
- scale.setWidth(kMaxFilterSize / size.width()); |
- matchesFilterSize = false; |
- } |
- if (size.height() * scale.height() > kMaxFilterSize) { |
- scale.setHeight(kMaxFilterSize / size.height()); |
- matchesFilterSize = false; |
- } |
+ FloatSize scaledSize(size); |
+ scaledSize.scale(scale.width(), scale.height()); |
+ float scaledArea = scaledSize.width() * scaledSize.height(); |
+ |
+ if (scaledArea <= FilterEffect::maxFilterArea()) |
+ return true; |
- return matchesFilterSize; |
+ // If area of scaled size is bigger than the upper limit, adjust the scale |
+ // to fit. |
+ scale.scale(sqrt(FilterEffect::maxFilterArea() / scaledArea)); |
+ return false; |
} |
static bool createImageBuffer(const Filter* filter, OwnPtr<ImageBuffer>& imageBuffer, bool accelerated) |