| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "platform/graphics/filters/FilterOperation.h" | 28 #include "platform/graphics/filters/FilterOperation.h" |
| 29 | 29 |
| 30 #include "platform/animation/AnimationUtilities.h" | 30 #include "platform/animation/AnimationUtilities.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 PassRefPtr<FilterOperation> FilterOperation::blend(const FilterOperation* from,
const FilterOperation* to, double progress) | 34 PassRefPtrWillBeRawPtr<FilterOperation> FilterOperation::blend(const FilterOpera
tion* from, const FilterOperation* to, double progress) |
| 35 { | 35 { |
| 36 ASSERT(from || to); | 36 ASSERT(from || to); |
| 37 if (to) | 37 if (to) |
| 38 return to->blend(from, progress); | 38 return to->blend(from, progress); |
| 39 return from->blend(0, 1 - progress); | 39 return from->blend(0, 1 - progress); |
| 40 } | 40 } |
| 41 | 41 |
| 42 PassRefPtr<FilterOperation> BasicColorMatrixFilterOperation::blend(const FilterO
peration* from, double progress) const | 42 void ReferenceFilterOperation::trace(Visitor* visitor) |
| 43 { |
| 44 visitor->trace(m_filter); |
| 45 FilterOperation::trace(visitor); |
| 46 } |
| 47 |
| 48 PassRefPtrWillBeRawPtr<FilterOperation> BasicColorMatrixFilterOperation::blend(c
onst FilterOperation* from, double progress) const |
| 43 { | 49 { |
| 44 double fromAmount; | 50 double fromAmount; |
| 45 if (from) { | 51 if (from) { |
| 46 ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this)); | 52 ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this)); |
| 47 fromAmount = toBasicColorMatrixFilterOperation(from)->amount(); | 53 fromAmount = toBasicColorMatrixFilterOperation(from)->amount(); |
| 48 } else { | 54 } else { |
| 49 switch (m_type) { | 55 switch (m_type) { |
| 50 case GRAYSCALE: | 56 case GRAYSCALE: |
| 51 case SEPIA: | 57 case SEPIA: |
| 52 case HUE_ROTATE: | 58 case HUE_ROTATE: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 break; | 77 break; |
| 72 case SATURATE: | 78 case SATURATE: |
| 73 result = clampTo<double>(result, 0); | 79 result = clampTo<double>(result, 0); |
| 74 break; | 80 break; |
| 75 default: | 81 default: |
| 76 ASSERT_NOT_REACHED(); | 82 ASSERT_NOT_REACHED(); |
| 77 } | 83 } |
| 78 return BasicColorMatrixFilterOperation::create(result, m_type); | 84 return BasicColorMatrixFilterOperation::create(result, m_type); |
| 79 } | 85 } |
| 80 | 86 |
| 81 PassRefPtr<FilterOperation> BasicComponentTransferFilterOperation::blend(const F
ilterOperation* from, double progress) const | 87 PassRefPtrWillBeRawPtr<FilterOperation> BasicComponentTransferFilterOperation::b
lend(const FilterOperation* from, double progress) const |
| 82 { | 88 { |
| 83 double fromAmount; | 89 double fromAmount; |
| 84 if (from) { | 90 if (from) { |
| 85 ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this)); | 91 ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this)); |
| 86 fromAmount = toBasicComponentTransferFilterOperation(from)->amount(); | 92 fromAmount = toBasicComponentTransferFilterOperation(from)->amount(); |
| 87 } else { | 93 } else { |
| 88 switch (m_type) { | 94 switch (m_type) { |
| 89 case OPACITY: | 95 case OPACITY: |
| 90 case CONTRAST: | 96 case CONTRAST: |
| 91 case BRIGHTNESS: | 97 case BRIGHTNESS: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 109 case INVERT: | 115 case INVERT: |
| 110 case OPACITY: | 116 case OPACITY: |
| 111 result = clampTo<double>(result, 0, 1); | 117 result = clampTo<double>(result, 0, 1); |
| 112 break; | 118 break; |
| 113 default: | 119 default: |
| 114 ASSERT_NOT_REACHED(); | 120 ASSERT_NOT_REACHED(); |
| 115 } | 121 } |
| 116 return BasicComponentTransferFilterOperation::create(result, m_type); | 122 return BasicComponentTransferFilterOperation::create(result, m_type); |
| 117 } | 123 } |
| 118 | 124 |
| 119 PassRefPtr<FilterOperation> BlurFilterOperation::blend(const FilterOperation* fr
om, double progress) const | 125 PassRefPtrWillBeRawPtr<FilterOperation> BlurFilterOperation::blend(const FilterO
peration* from, double progress) const |
| 120 { | 126 { |
| 121 LengthType lengthType = m_stdDeviation.type(); | 127 LengthType lengthType = m_stdDeviation.type(); |
| 122 if (!from) | 128 if (!from) |
| 123 return BlurFilterOperation::create(m_stdDeviation.blend(Length(lengthTyp
e), progress, ValueRangeNonNegative)); | 129 return BlurFilterOperation::create(m_stdDeviation.blend(Length(lengthTyp
e), progress, ValueRangeNonNegative)); |
| 124 | 130 |
| 125 const BlurFilterOperation* fromOp = toBlurFilterOperation(from); | 131 const BlurFilterOperation* fromOp = toBlurFilterOperation(from); |
| 126 return BlurFilterOperation::create(m_stdDeviation.blend(fromOp->m_stdDeviati
on, progress, ValueRangeNonNegative)); | 132 return BlurFilterOperation::create(m_stdDeviation.blend(fromOp->m_stdDeviati
on, progress, ValueRangeNonNegative)); |
| 127 } | 133 } |
| 128 | 134 |
| 129 PassRefPtr<FilterOperation> DropShadowFilterOperation::blend(const FilterOperati
on* from, double progress) const | 135 PassRefPtrWillBeRawPtr<FilterOperation> DropShadowFilterOperation::blend(const F
ilterOperation* from, double progress) const |
| 130 { | 136 { |
| 131 if (!from) { | 137 if (!from) { |
| 132 return DropShadowFilterOperation::create( | 138 return DropShadowFilterOperation::create( |
| 133 blink::blend(IntPoint(), m_location, progress), | 139 blink::blend(IntPoint(), m_location, progress), |
| 134 blink::blend(0, m_stdDeviation, progress), | 140 blink::blend(0, m_stdDeviation, progress), |
| 135 blink::blend(Color(Color::transparent), m_color, progress)); | 141 blink::blend(Color(Color::transparent), m_color, progress)); |
| 136 } | 142 } |
| 137 | 143 |
| 138 const DropShadowFilterOperation* fromOp = toDropShadowFilterOperation(from); | 144 const DropShadowFilterOperation* fromOp = toDropShadowFilterOperation(from); |
| 139 return DropShadowFilterOperation::create( | 145 return DropShadowFilterOperation::create( |
| 140 blink::blend(fromOp->location(), m_location, progress), | 146 blink::blend(fromOp->location(), m_location, progress), |
| 141 blink::blend(fromOp->stdDeviation(), m_stdDeviation, progress), | 147 blink::blend(fromOp->stdDeviation(), m_stdDeviation, progress), |
| 142 blink::blend(fromOp->color(), m_color, progress)); | 148 blink::blend(fromOp->color(), m_color, progress)); |
| 143 } | 149 } |
| 144 | 150 |
| 145 } // namespace blink | 151 } // namespace blink |
| 146 | 152 |
| OLD | NEW |