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 |
(...skipping 11 matching lines...) Expand all Loading... |
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 "platform/graphics/filters/FilterOperation.h" | 26 #include "platform/graphics/filters/FilterOperation.h" |
27 | 27 |
28 #include "platform/animation/AnimationUtilities.h" | 28 #include "platform/animation/AnimationUtilities.h" |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 | 31 |
32 RawPtr<FilterOperation> FilterOperation::blend(const FilterOperation* from, cons
t FilterOperation* to, double progress) | 32 FilterOperation* FilterOperation::blend(const FilterOperation* from, const Filte
rOperation* to, double progress) |
33 { | 33 { |
34 ASSERT(from || to); | 34 ASSERT(from || to); |
35 if (to) | 35 if (to) |
36 return to->blend(from, progress); | 36 return to->blend(from, progress); |
37 return from->blend(0, 1 - progress); | 37 return from->blend(0, 1 - progress); |
38 } | 38 } |
39 | 39 |
40 DEFINE_TRACE(ReferenceFilterOperation) | 40 DEFINE_TRACE(ReferenceFilterOperation) |
41 { | 41 { |
42 visitor->trace(m_filter); | 42 visitor->trace(m_filter); |
43 FilterOperation::trace(visitor); | 43 FilterOperation::trace(visitor); |
44 } | 44 } |
45 | 45 |
46 RawPtr<FilterOperation> BasicColorMatrixFilterOperation::blend(const FilterOpera
tion* from, double progress) const | 46 FilterOperation* BasicColorMatrixFilterOperation::blend(const FilterOperation* f
rom, double progress) const |
47 { | 47 { |
48 double fromAmount; | 48 double fromAmount; |
49 if (from) { | 49 if (from) { |
50 ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this)); | 50 ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this)); |
51 fromAmount = toBasicColorMatrixFilterOperation(from)->amount(); | 51 fromAmount = toBasicColorMatrixFilterOperation(from)->amount(); |
52 } else { | 52 } else { |
53 switch (m_type) { | 53 switch (m_type) { |
54 case GRAYSCALE: | 54 case GRAYSCALE: |
55 case SEPIA: | 55 case SEPIA: |
56 case HUE_ROTATE: | 56 case HUE_ROTATE: |
(...skipping 18 matching lines...) Expand all Loading... |
75 break; | 75 break; |
76 case SATURATE: | 76 case SATURATE: |
77 result = clampTo<double>(result, 0); | 77 result = clampTo<double>(result, 0); |
78 break; | 78 break; |
79 default: | 79 default: |
80 ASSERT_NOT_REACHED(); | 80 ASSERT_NOT_REACHED(); |
81 } | 81 } |
82 return BasicColorMatrixFilterOperation::create(result, m_type); | 82 return BasicColorMatrixFilterOperation::create(result, m_type); |
83 } | 83 } |
84 | 84 |
85 RawPtr<FilterOperation> BasicComponentTransferFilterOperation::blend(const Filte
rOperation* from, double progress) const | 85 FilterOperation* BasicComponentTransferFilterOperation::blend(const FilterOperat
ion* from, double progress) const |
86 { | 86 { |
87 double fromAmount; | 87 double fromAmount; |
88 if (from) { | 88 if (from) { |
89 ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this)); | 89 ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this)); |
90 fromAmount = toBasicComponentTransferFilterOperation(from)->amount(); | 90 fromAmount = toBasicComponentTransferFilterOperation(from)->amount(); |
91 } else { | 91 } else { |
92 switch (m_type) { | 92 switch (m_type) { |
93 case OPACITY: | 93 case OPACITY: |
94 case CONTRAST: | 94 case CONTRAST: |
95 case BRIGHTNESS: | 95 case BRIGHTNESS: |
(...skipping 17 matching lines...) Expand all Loading... |
113 case INVERT: | 113 case INVERT: |
114 case OPACITY: | 114 case OPACITY: |
115 result = clampTo<double>(result, 0, 1); | 115 result = clampTo<double>(result, 0, 1); |
116 break; | 116 break; |
117 default: | 117 default: |
118 ASSERT_NOT_REACHED(); | 118 ASSERT_NOT_REACHED(); |
119 } | 119 } |
120 return BasicComponentTransferFilterOperation::create(result, m_type); | 120 return BasicComponentTransferFilterOperation::create(result, m_type); |
121 } | 121 } |
122 | 122 |
123 RawPtr<FilterOperation> BlurFilterOperation::blend(const FilterOperation* from,
double progress) const | 123 FilterOperation* BlurFilterOperation::blend(const FilterOperation* from, double
progress) const |
124 { | 124 { |
125 LengthType lengthType = m_stdDeviation.type(); | 125 LengthType lengthType = m_stdDeviation.type(); |
126 if (!from) | 126 if (!from) |
127 return BlurFilterOperation::create(m_stdDeviation.blend(Length(lengthTyp
e), progress, ValueRangeNonNegative)); | 127 return BlurFilterOperation::create(m_stdDeviation.blend(Length(lengthTyp
e), progress, ValueRangeNonNegative)); |
128 | 128 |
129 const BlurFilterOperation* fromOp = toBlurFilterOperation(from); | 129 const BlurFilterOperation* fromOp = toBlurFilterOperation(from); |
130 return BlurFilterOperation::create(m_stdDeviation.blend(fromOp->m_stdDeviati
on, progress, ValueRangeNonNegative)); | 130 return BlurFilterOperation::create(m_stdDeviation.blend(fromOp->m_stdDeviati
on, progress, ValueRangeNonNegative)); |
131 } | 131 } |
132 | 132 |
133 RawPtr<FilterOperation> DropShadowFilterOperation::blend(const FilterOperation*
from, double progress) const | 133 FilterOperation* DropShadowFilterOperation::blend(const FilterOperation* from, d
ouble progress) const |
134 { | 134 { |
135 if (!from) { | 135 if (!from) { |
136 return DropShadowFilterOperation::create( | 136 return DropShadowFilterOperation::create( |
137 blink::blend(IntPoint(), m_location, progress), | 137 blink::blend(IntPoint(), m_location, progress), |
138 blink::blend(0, m_stdDeviation, progress), | 138 blink::blend(0, m_stdDeviation, progress), |
139 blink::blend(Color(Color::transparent), m_color, progress)); | 139 blink::blend(Color(Color::transparent), m_color, progress)); |
140 } | 140 } |
141 | 141 |
142 const DropShadowFilterOperation* fromOp = toDropShadowFilterOperation(from); | 142 const DropShadowFilterOperation* fromOp = toDropShadowFilterOperation(from); |
143 return DropShadowFilterOperation::create( | 143 return DropShadowFilterOperation::create( |
144 blink::blend(fromOp->location(), m_location, progress), | 144 blink::blend(fromOp->location(), m_location, progress), |
145 blink::blend(fromOp->stdDeviation(), m_stdDeviation, progress), | 145 blink::blend(fromOp->stdDeviation(), m_stdDeviation, progress), |
146 blink::blend(fromOp->getColor(), m_color, progress)); | 146 blink::blend(fromOp->getColor(), m_color, progress)); |
147 } | 147 } |
148 | 148 |
149 RawPtr<FilterOperation> BoxReflectFilterOperation::blend(const FilterOperation*
from, double progress) const | 149 FilterOperation* BoxReflectFilterOperation::blend(const FilterOperation* from, d
ouble progress) const |
150 { | 150 { |
151 ASSERT_NOT_REACHED(); | 151 ASSERT_NOT_REACHED(); |
152 return nullptr; | 152 return nullptr; |
153 } | 153 } |
154 | 154 |
155 bool BoxReflectFilterOperation::operator==(const FilterOperation& o) const | 155 bool BoxReflectFilterOperation::operator==(const FilterOperation& o) const |
156 { | 156 { |
157 if (!isSameType(o)) | 157 if (!isSameType(o)) |
158 return false; | 158 return false; |
159 const auto& other = static_cast<const BoxReflectFilterOperation&>(o); | 159 const auto& other = static_cast<const BoxReflectFilterOperation&>(o); |
160 return m_direction == other.m_direction && m_offset == other.m_offset; | 160 return m_direction == other.m_direction && m_offset == other.m_offset; |
161 } | 161 } |
162 | 162 |
163 } // namespace blink | 163 } // namespace blink |
164 | 164 |
OLD | NEW |