OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "core/style/FilterOperation.h" | 26 #include "core/style/FilterOperation.h" |
27 | 27 |
| 28 #include "core/svg/SVGElementProxy.h" |
28 #include "platform/LengthFunctions.h" | 29 #include "platform/LengthFunctions.h" |
29 #include "platform/animation/AnimationUtilities.h" | 30 #include "platform/animation/AnimationUtilities.h" |
30 #include "platform/graphics/filters/FEDropShadow.h" | 31 #include "platform/graphics/filters/FEDropShadow.h" |
31 #include "platform/graphics/filters/FEGaussianBlur.h" | 32 #include "platform/graphics/filters/FEGaussianBlur.h" |
32 #include "platform/graphics/filters/Filter.h" | 33 #include "platform/graphics/filters/Filter.h" |
33 #include "platform/graphics/filters/FilterEffect.h" | 34 #include "platform/graphics/filters/FilterEffect.h" |
34 | 35 |
35 namespace blink { | 36 namespace blink { |
36 | 37 |
37 FilterOperation* FilterOperation::blend(const FilterOperation* from, | 38 FilterOperation* FilterOperation::blend(const FilterOperation* from, |
38 const FilterOperation* to, | 39 const FilterOperation* to, |
39 double progress) { | 40 double progress) { |
40 DCHECK(from || to); | 41 DCHECK(from || to); |
41 if (to) | 42 if (to) |
42 return to->blend(from, progress); | 43 return to->blend(from, progress); |
43 return from->blend(0, 1 - progress); | 44 return from->blend(0, 1 - progress); |
44 } | 45 } |
45 | 46 |
46 DEFINE_TRACE(ReferenceFilterOperation) { | 47 DEFINE_TRACE(ReferenceFilterOperation) { |
| 48 visitor->trace(m_elementProxy); |
47 visitor->trace(m_filter); | 49 visitor->trace(m_filter); |
48 FilterOperation::trace(visitor); | 50 FilterOperation::trace(visitor); |
49 } | 51 } |
50 | 52 |
51 FloatRect ReferenceFilterOperation::mapRect(const FloatRect& rect) const { | 53 FloatRect ReferenceFilterOperation::mapRect(const FloatRect& rect) const { |
52 const auto* lastEffect = m_filter ? m_filter->lastEffect() : nullptr; | 54 const auto* lastEffect = m_filter ? m_filter->lastEffect() : nullptr; |
53 if (!lastEffect) | 55 if (!lastEffect) |
54 return rect; | 56 return rect; |
55 return lastEffect->mapRect(rect); | 57 return lastEffect->mapRect(rect); |
56 } | 58 } |
57 | 59 |
| 60 ReferenceFilterOperation::ReferenceFilterOperation( |
| 61 const String& url, |
| 62 SVGElementProxy& elementProxy) |
| 63 : FilterOperation(REFERENCE), m_url(url), m_elementProxy(&elementProxy) {} |
| 64 |
| 65 void ReferenceFilterOperation::addClient(SVGResourceClient* client) { |
| 66 m_elementProxy->addClient(client); |
| 67 } |
| 68 |
| 69 void ReferenceFilterOperation::removeClient(SVGResourceClient* client) { |
| 70 m_elementProxy->removeClient(client); |
| 71 } |
| 72 |
| 73 bool ReferenceFilterOperation::operator==(const FilterOperation& o) const { |
| 74 if (!isSameType(o)) |
| 75 return false; |
| 76 const ReferenceFilterOperation& other = toReferenceFilterOperation(o); |
| 77 return m_url == other.m_url && m_elementProxy == other.m_elementProxy; |
| 78 } |
| 79 |
58 FilterOperation* BasicColorMatrixFilterOperation::blend( | 80 FilterOperation* BasicColorMatrixFilterOperation::blend( |
59 const FilterOperation* from, | 81 const FilterOperation* from, |
60 double progress) const { | 82 double progress) const { |
61 double fromAmount; | 83 double fromAmount; |
62 if (from) { | 84 if (from) { |
63 SECURITY_DCHECK(from->isSameType(*this)); | 85 SECURITY_DCHECK(from->isSameType(*this)); |
64 fromAmount = toBasicColorMatrixFilterOperation(from)->amount(); | 86 fromAmount = toBasicColorMatrixFilterOperation(from)->amount(); |
65 } else { | 87 } else { |
66 switch (m_type) { | 88 switch (m_type) { |
67 case GRAYSCALE: | 89 case GRAYSCALE: |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 206 } |
185 | 207 |
186 bool BoxReflectFilterOperation::operator==(const FilterOperation& o) const { | 208 bool BoxReflectFilterOperation::operator==(const FilterOperation& o) const { |
187 if (!isSameType(o)) | 209 if (!isSameType(o)) |
188 return false; | 210 return false; |
189 const auto& other = static_cast<const BoxReflectFilterOperation&>(o); | 211 const auto& other = static_cast<const BoxReflectFilterOperation&>(o); |
190 return m_reflection == other.m_reflection; | 212 return m_reflection == other.m_reflection; |
191 } | 213 } |
192 | 214 |
193 } // namespace blink | 215 } // namespace blink |
OLD | NEW |