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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 return kernelSize; | 70 return kernelSize; |
71 } | 71 } |
72 | 72 |
73 IntSize FEGaussianBlur::calculateKernelSize(const Filter* filter, const FloatPoi
nt& std) | 73 IntSize FEGaussianBlur::calculateKernelSize(const Filter* filter, const FloatPoi
nt& std) |
74 { | 74 { |
75 FloatPoint stdError(filter->applyHorizontalScale(std.x()), filter->applyVert
icalScale(std.y())); | 75 FloatPoint stdError(filter->applyHorizontalScale(std.x()), filter->applyVert
icalScale(std.y())); |
76 return calculateUnscaledKernelSize(stdError); | 76 return calculateUnscaledKernelSize(stdError); |
77 } | 77 } |
78 | 78 |
79 FloatRect FEGaussianBlur::mapRect(const FloatRect& rect, bool) const | 79 FloatRect FEGaussianBlur::mapEffect(const FloatRect& rect) const |
80 { | 80 { |
81 FloatRect result = rect; | |
82 IntSize kernelSize = calculateKernelSize(getFilter(), FloatPoint(m_stdX, m_s
tdY)); | 81 IntSize kernelSize = calculateKernelSize(getFilter(), FloatPoint(m_stdX, m_s
tdY)); |
83 | 82 |
84 // We take the half kernel size and multiply it with three, because we run b
ox blur three times. | 83 // We take the half kernel size and multiply it with three, because we run b
ox blur three times. |
| 84 FloatRect result = rect; |
85 result.inflateX(3.0f * kernelSize.width() * 0.5f); | 85 result.inflateX(3.0f * kernelSize.width() * 0.5f); |
86 result.inflateY(3.0f * kernelSize.height() * 0.5f); | 86 result.inflateY(3.0f * kernelSize.height() * 0.5f); |
87 return result; | 87 return result; |
88 } | 88 } |
89 | 89 |
90 FloatRect FEGaussianBlur::determineAbsolutePaintRect(const FloatRect& originalRe
questedRect) const | |
91 { | |
92 FloatRect requestedRect = originalRequestedRect; | |
93 if (clipsToBounds()) | |
94 requestedRect.intersect(absoluteBounds()); | |
95 | |
96 FilterEffect* input = inputEffect(0); | |
97 FloatRect inputRect = input->determineAbsolutePaintRect(mapRect(requestedRec
t, false)); | |
98 FloatRect outputRect = mapRect(inputRect, true); | |
99 outputRect.intersect(requestedRect); | |
100 | |
101 // Blur needs space for both input and output pixels in the paint area. | |
102 // Input is also clipped to subregion. | |
103 if (clipsToBounds()) | |
104 inputRect.intersect(absoluteBounds()); | |
105 return outputRect; | |
106 } | |
107 | |
108 sk_sp<SkImageFilter> FEGaussianBlur::createImageFilter() | 90 sk_sp<SkImageFilter> FEGaussianBlur::createImageFilter() |
109 { | 91 { |
110 sk_sp<SkImageFilter> input(SkiaImageFilterBuilder::build(inputEffect(0), ope
ratingColorSpace())); | 92 sk_sp<SkImageFilter> input(SkiaImageFilterBuilder::build(inputEffect(0), ope
ratingColorSpace())); |
111 float stdX = getFilter()->applyHorizontalScale(m_stdX); | 93 float stdX = getFilter()->applyHorizontalScale(m_stdX); |
112 float stdY = getFilter()->applyVerticalScale(m_stdY); | 94 float stdY = getFilter()->applyVerticalScale(m_stdY); |
113 SkImageFilter::CropRect rect = getCropRect(); | 95 SkImageFilter::CropRect rect = getCropRect(); |
114 return SkBlurImageFilter::Make(SkFloatToScalar(stdX), SkFloatToScalar(stdY),
std::move(input), &rect); | 96 return SkBlurImageFilter::Make(SkFloatToScalar(stdX), SkFloatToScalar(stdY),
std::move(input), &rect); |
115 } | 97 } |
116 | 98 |
117 TextStream& FEGaussianBlur::externalRepresentation(TextStream& ts, int indent) c
onst | 99 TextStream& FEGaussianBlur::externalRepresentation(TextStream& ts, int indent) c
onst |
118 { | 100 { |
119 writeIndent(ts, indent); | 101 writeIndent(ts, indent); |
120 ts << "[feGaussianBlur"; | 102 ts << "[feGaussianBlur"; |
121 FilterEffect::externalRepresentation(ts); | 103 FilterEffect::externalRepresentation(ts); |
122 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\"]\n"; | 104 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\"]\n"; |
123 inputEffect(0)->externalRepresentation(ts, indent + 1); | 105 inputEffect(0)->externalRepresentation(ts, indent + 1); |
124 return ts; | 106 return ts; |
125 } | 107 } |
126 | 108 |
127 } // namespace blink | 109 } // namespace blink |
OLD | NEW |