OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 float stdX, | 47 float stdX, |
48 float stdY, | 48 float stdY, |
49 float dx, | 49 float dx, |
50 float dy, | 50 float dy, |
51 const Color& shadowColor, | 51 const Color& shadowColor, |
52 float shadowOpacity) { | 52 float shadowOpacity) { |
53 return new FEDropShadow(filter, stdX, stdY, dx, dy, shadowColor, | 53 return new FEDropShadow(filter, stdX, stdY, dx, dy, shadowColor, |
54 shadowOpacity); | 54 shadowOpacity); |
55 } | 55 } |
56 | 56 |
| 57 FloatRect FEDropShadow::mapEffect(const FloatSize& stdDeviation, |
| 58 const FloatPoint& offset, |
| 59 const FloatRect& rect) { |
| 60 FloatRect offsetRect = rect; |
| 61 offsetRect.moveBy(offset); |
| 62 FloatRect blurredRect = FEGaussianBlur::mapEffect(stdDeviation, offsetRect); |
| 63 return unionRect(blurredRect, rect); |
| 64 } |
| 65 |
57 FloatRect FEDropShadow::mapEffect(const FloatRect& rect) const { | 66 FloatRect FEDropShadow::mapEffect(const FloatRect& rect) const { |
58 const Filter* filter = this->getFilter(); | 67 const Filter* filter = this->getFilter(); |
59 DCHECK(filter); | 68 DCHECK(filter); |
60 | 69 FloatPoint offset(filter->applyHorizontalScale(m_dx), |
61 FloatRect offsetRect = rect; | 70 filter->applyVerticalScale(m_dy)); |
62 offsetRect.move(filter->applyHorizontalScale(m_dx), | 71 FloatSize stdError(filter->applyHorizontalScale(m_stdX), |
63 filter->applyVerticalScale(m_dy)); | 72 filter->applyVerticalScale(m_stdY)); |
64 | 73 return mapEffect(stdError, offset, rect); |
65 IntSize kernelSize = | |
66 FEGaussianBlur::calculateKernelSize(filter, FloatPoint(m_stdX, m_stdY)); | |
67 | |
68 // We take the half kernel size and multiply it by three, because we run box | |
69 // blur three times. | |
70 FloatRect result = unionRect(rect, offsetRect); | |
71 result.inflateX(3.0f * kernelSize.width() * 0.5f); | |
72 result.inflateY(3.0f * kernelSize.height() * 0.5f); | |
73 return result; | |
74 } | 74 } |
75 | 75 |
76 sk_sp<SkImageFilter> FEDropShadow::createImageFilter() { | 76 sk_sp<SkImageFilter> FEDropShadow::createImageFilter() { |
77 sk_sp<SkImageFilter> input( | 77 sk_sp<SkImageFilter> input( |
78 SkiaImageFilterBuilder::build(inputEffect(0), operatingColorSpace())); | 78 SkiaImageFilterBuilder::build(inputEffect(0), operatingColorSpace())); |
79 float dx = getFilter()->applyHorizontalScale(m_dx); | 79 float dx = getFilter()->applyHorizontalScale(m_dx); |
80 float dy = getFilter()->applyVerticalScale(m_dy); | 80 float dy = getFilter()->applyVerticalScale(m_dy); |
81 float stdX = getFilter()->applyHorizontalScale(m_stdX); | 81 float stdX = getFilter()->applyHorizontalScale(m_stdX); |
82 float stdY = getFilter()->applyVerticalScale(m_stdY); | 82 float stdY = getFilter()->applyVerticalScale(m_stdY); |
83 Color color = adaptColorToOperatingColorSpace( | 83 Color color = adaptColorToOperatingColorSpace( |
(...skipping 13 matching lines...) Expand all Loading... |
97 FilterEffect::externalRepresentation(ts); | 97 FilterEffect::externalRepresentation(ts); |
98 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\" dx=\"" << m_dx | 98 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\" dx=\"" << m_dx |
99 << "\" dy=\"" << m_dy << "\" flood-color=\"" | 99 << "\" dy=\"" << m_dy << "\" flood-color=\"" |
100 << m_shadowColor.nameForLayoutTreeAsText() << "\" flood-opacity=\"" | 100 << m_shadowColor.nameForLayoutTreeAsText() << "\" flood-opacity=\"" |
101 << m_shadowOpacity << "]\n"; | 101 << m_shadowOpacity << "]\n"; |
102 inputEffect(0)->externalRepresentation(ts, indent + 1); | 102 inputEffect(0)->externalRepresentation(ts, indent + 1); |
103 return ts; | 103 return ts; |
104 } | 104 } |
105 | 105 |
106 } // namespace blink | 106 } // namespace blink |
OLD | NEW |