OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
6 * Copyright (C) 2010 Igalia, S.L. | 6 * Copyright (C) 2010 Igalia, S.L. |
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
8 * Copyright (C) 2013 Google Inc. All rights reserved. | 8 * Copyright (C) 2013 Google Inc. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 31 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
32 #include "platform/text/TextStream.h" | 32 #include "platform/text/TextStream.h" |
33 | 33 |
34 #include "SkBlurImageFilter.h" | 34 #include "SkBlurImageFilter.h" |
35 | 35 |
36 static inline float gaussianKernelFactor() | 36 static inline float gaussianKernelFactor() |
37 { | 37 { |
38 return 3 / 4.f * sqrtf(twoPiFloat); | 38 return 3 / 4.f * sqrtf(twoPiFloat); |
39 } | 39 } |
40 | 40 |
41 static const int gMaxKernelSize = 1000; | |
42 | |
43 namespace blink { | 41 namespace blink { |
44 | 42 |
45 FEGaussianBlur::FEGaussianBlur(Filter* filter, float x, float y) | 43 FEGaussianBlur::FEGaussianBlur(Filter* filter, float x, float y) |
46 : FilterEffect(filter) | 44 : FilterEffect(filter) |
47 , m_stdX(x) | 45 , m_stdX(x) |
48 , m_stdY(y) | 46 , m_stdY(y) |
49 { | 47 { |
50 } | 48 } |
51 | 49 |
52 PassRefPtrWillBeRawPtr<FEGaussianBlur> FEGaussianBlur::create(Filter* filter, fl
oat x, float y) | 50 PassRefPtrWillBeRawPtr<FEGaussianBlur> FEGaussianBlur::create(Filter* filter, fl
oat x, float y) |
(...skipping 23 matching lines...) Expand all Loading... |
76 | 74 |
77 IntSize FEGaussianBlur::calculateUnscaledKernelSize(const FloatPoint& std) | 75 IntSize FEGaussianBlur::calculateUnscaledKernelSize(const FloatPoint& std) |
78 { | 76 { |
79 ASSERT(std.x() >= 0 && std.y() >= 0); | 77 ASSERT(std.x() >= 0 && std.y() >= 0); |
80 | 78 |
81 IntSize kernelSize; | 79 IntSize kernelSize; |
82 // Limit the kernel size to 1000. A bigger radius won't make a big differenc
e for the result image but | 80 // Limit the kernel size to 1000. A bigger radius won't make a big differenc
e for the result image but |
83 // inflates the absolute paint rect to much. This is compatible with Firefox
' behavior. | 81 // inflates the absolute paint rect to much. This is compatible with Firefox
' behavior. |
84 if (std.x()) { | 82 if (std.x()) { |
85 int size = std::max<unsigned>(2, static_cast<unsigned>(floorf(std.x() *
gaussianKernelFactor() + 0.5f))); | 83 int size = std::max<unsigned>(2, static_cast<unsigned>(floorf(std.x() *
gaussianKernelFactor() + 0.5f))); |
86 kernelSize.setWidth(std::min(size, gMaxKernelSize)); | 84 kernelSize.setWidth(size); |
87 } | 85 } |
88 | 86 |
89 if (std.y()) { | 87 if (std.y()) { |
90 int size = std::max<unsigned>(2, static_cast<unsigned>(floorf(std.y() *
gaussianKernelFactor() + 0.5f))); | 88 int size = std::max<unsigned>(2, static_cast<unsigned>(floorf(std.y() *
gaussianKernelFactor() + 0.5f))); |
91 kernelSize.setHeight(std::min(size, gMaxKernelSize)); | 89 kernelSize.setHeight(size); |
92 } | 90 } |
93 | 91 |
94 return kernelSize; | 92 return kernelSize; |
95 } | 93 } |
96 | 94 |
97 IntSize FEGaussianBlur::calculateKernelSize(Filter* filter, const FloatPoint& st
d) | 95 IntSize FEGaussianBlur::calculateKernelSize(Filter* filter, const FloatPoint& st
d) |
98 { | 96 { |
99 FloatPoint stdError(filter->applyHorizontalScale(std.x()), filter->applyVert
icalScale(std.y())); | 97 FloatPoint stdError(filter->applyHorizontalScale(std.x()), filter->applyVert
icalScale(std.y())); |
100 | 98 |
101 return calculateUnscaledKernelSize(stdError); | 99 return calculateUnscaledKernelSize(stdError); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 { | 143 { |
146 writeIndent(ts, indent); | 144 writeIndent(ts, indent); |
147 ts << "[feGaussianBlur"; | 145 ts << "[feGaussianBlur"; |
148 FilterEffect::externalRepresentation(ts); | 146 FilterEffect::externalRepresentation(ts); |
149 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\"]\n"; | 147 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\"]\n"; |
150 inputEffect(0)->externalRepresentation(ts, indent + 1); | 148 inputEffect(0)->externalRepresentation(ts, indent + 1); |
151 return ts; | 149 return ts; |
152 } | 150 } |
153 | 151 |
154 } // namespace blink | 152 } // namespace blink |
OLD | NEW |