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 26 matching lines...) Expand all Loading... |
37 , m_shadowColor(shadowColor) | 37 , m_shadowColor(shadowColor) |
38 , m_shadowOpacity(shadowOpacity) | 38 , m_shadowOpacity(shadowOpacity) |
39 { | 39 { |
40 } | 40 } |
41 | 41 |
42 FEDropShadow* FEDropShadow::create(Filter* filter, float stdX, float stdY, float
dx, float dy, const Color& shadowColor, float shadowOpacity) | 42 FEDropShadow* FEDropShadow::create(Filter* filter, float stdX, float stdY, float
dx, float dy, const Color& shadowColor, float shadowOpacity) |
43 { | 43 { |
44 return new FEDropShadow(filter, stdX, stdY, dx, dy, shadowColor, shadowOpaci
ty); | 44 return new FEDropShadow(filter, stdX, stdY, dx, dy, shadowColor, shadowOpaci
ty); |
45 } | 45 } |
46 | 46 |
47 FloatRect FEDropShadow::mapRect(const FloatRect& rect, bool forward) const | 47 FloatRect FEDropShadow::mapEffect(const FloatRect& rect) const |
48 { | 48 { |
49 FloatRect result = rect; | |
50 const Filter* filter = this->getFilter(); | 49 const Filter* filter = this->getFilter(); |
51 ASSERT(filter); | 50 DCHECK(filter); |
52 | 51 |
53 FloatRect offsetRect = rect; | 52 FloatRect offsetRect = rect; |
54 if (forward) | 53 offsetRect.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalSca
le(m_dy)); |
55 offsetRect.move(filter->applyHorizontalScale(m_dx), filter->applyVertica
lScale(m_dy)); | |
56 else | |
57 offsetRect.move(-filter->applyHorizontalScale(m_dx), -filter->applyVerti
calScale(m_dy)); | |
58 result.unite(offsetRect); | |
59 | 54 |
60 IntSize kernelSize = FEGaussianBlur::calculateKernelSize(filter, FloatPoint(
m_stdX, m_stdY)); | 55 IntSize kernelSize = FEGaussianBlur::calculateKernelSize(filter, FloatPoint(
m_stdX, m_stdY)); |
61 | 56 |
62 // We take the half kernel size and multiply it with three, because we run b
ox blur three times. | 57 // We take the half kernel size and multiply it with three, because we run b
ox blur three times. |
| 58 FloatRect result = unionRect(rect, offsetRect); |
63 result.inflateX(3.0f * kernelSize.width() * 0.5f); | 59 result.inflateX(3.0f * kernelSize.width() * 0.5f); |
64 result.inflateY(3.0f * kernelSize.height() * 0.5f); | 60 result.inflateY(3.0f * kernelSize.height() * 0.5f); |
65 return result; | 61 return result; |
66 } | 62 } |
67 | 63 |
68 sk_sp<SkImageFilter> FEDropShadow::createImageFilter() | 64 sk_sp<SkImageFilter> FEDropShadow::createImageFilter() |
69 { | 65 { |
70 sk_sp<SkImageFilter> input(SkiaImageFilterBuilder::build(inputEffect(0), ope
ratingColorSpace())); | 66 sk_sp<SkImageFilter> input(SkiaImageFilterBuilder::build(inputEffect(0), ope
ratingColorSpace())); |
71 float dx = getFilter()->applyHorizontalScale(m_dx); | 67 float dx = getFilter()->applyHorizontalScale(m_dx); |
72 float dy = getFilter()->applyVerticalScale(m_dy); | 68 float dy = getFilter()->applyVerticalScale(m_dy); |
73 float stdX = getFilter()->applyHorizontalScale(m_stdX); | 69 float stdX = getFilter()->applyHorizontalScale(m_stdX); |
74 float stdY = getFilter()->applyVerticalScale(m_stdY); | 70 float stdY = getFilter()->applyVerticalScale(m_stdY); |
75 Color color = adaptColorToOperatingColorSpace(m_shadowColor.combineWithAlpha
(m_shadowOpacity)); | 71 Color color = adaptColorToOperatingColorSpace(m_shadowColor.combineWithAlpha
(m_shadowOpacity)); |
76 SkImageFilter::CropRect cropRect = getCropRect(); | 72 SkImageFilter::CropRect cropRect = getCropRect(); |
77 return SkDropShadowImageFilter::Make(SkFloatToScalar(dx), SkFloatToScalar(dy
), SkFloatToScalar(stdX), SkFloatToScalar(stdY), color.rgb(), SkDropShadowImageF
ilter::kDrawShadowAndForeground_ShadowMode, std::move(input), &cropRect); | 73 return SkDropShadowImageFilter::Make(SkFloatToScalar(dx), SkFloatToScalar(dy
), SkFloatToScalar(stdX), SkFloatToScalar(stdY), color.rgb(), SkDropShadowImageF
ilter::kDrawShadowAndForeground_ShadowMode, std::move(input), &cropRect); |
78 } | 74 } |
79 | 75 |
80 | |
81 TextStream& FEDropShadow::externalRepresentation(TextStream& ts, int indent) con
st | 76 TextStream& FEDropShadow::externalRepresentation(TextStream& ts, int indent) con
st |
82 { | 77 { |
83 writeIndent(ts, indent); | 78 writeIndent(ts, indent); |
84 ts << "[feDropShadow"; | 79 ts << "[feDropShadow"; |
85 FilterEffect::externalRepresentation(ts); | 80 FilterEffect::externalRepresentation(ts); |
86 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\" dx=\"" << m_dx <
< "\" dy=\"" << m_dy << "\" flood-color=\"" << m_shadowColor.nameForLayoutTreeAs
Text() <<"\" flood-opacity=\"" << m_shadowOpacity << "]\n"; | 81 ts << " stdDeviation=\"" << m_stdX << ", " << m_stdY << "\" dx=\"" << m_dx <
< "\" dy=\"" << m_dy << "\" flood-color=\"" << m_shadowColor.nameForLayoutTreeAs
Text() <<"\" flood-opacity=\"" << m_shadowOpacity << "]\n"; |
87 inputEffect(0)->externalRepresentation(ts, indent + 1); | 82 inputEffect(0)->externalRepresentation(ts, indent + 1); |
88 return ts; | 83 return ts; |
89 } | 84 } |
90 | 85 |
91 } // namespace blink | 86 } // namespace blink |
OLD | NEW |