Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 } | 130 } |
| 131 | 131 |
| 132 void KeyframeEffect::applyEffects() | 132 void KeyframeEffect::applyEffects() |
| 133 { | 133 { |
| 134 ASSERT(isInEffect()); | 134 ASSERT(isInEffect()); |
| 135 ASSERT(animation()); | 135 ASSERT(animation()); |
| 136 if (!m_target || !m_model) | 136 if (!m_target || !m_model) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 // Cancel composited animation of transform if a motion path, translate, | 139 // Cancel composited animation of transform if a motion path, translate, |
| 140 // rotate or scale operation has been introduced on the element. | 140 // rotate or scale operation has been introduced on the element. |
|
dstockwell
2015/07/03 01:58:41
comment needs update
soonm
2015/07/03 06:34:29
Done.
| |
| 141 if (m_target->computedStyle() | 141 if (m_target->computedStyle() |
| 142 && (m_target->computedStyle()->hasMotionPath() | 142 && m_target->computedStyle()->hasMotionPath() |
| 143 || m_target->computedStyle()->translate() | |
| 144 || m_target->computedStyle()->rotate() | |
| 145 || m_target->computedStyle()->scale()) | |
| 146 && animation()->hasActiveAnimationsOnCompositor() | 143 && animation()->hasActiveAnimationsOnCompositor() |
| 147 && animation()->affects(*m_target, CSSPropertyTransform)) { | 144 && (animation()->affects(*m_target, CSSPropertyScale) |
| 145 || animation()->affects(*m_target, CSSPropertyRotate) | |
| 146 || animation()->affects(*m_target, CSSPropertyTransform) | |
| 147 || animation()->affects(*m_target, CSSPropertyTranslate))) | |
| 148 animation()->cancelAnimationOnCompositor(); | 148 animation()->cancelAnimationOnCompositor(); |
| 149 } | |
| 150 | 149 |
| 151 double iteration = currentIteration(); | 150 double iteration = currentIteration(); |
| 152 ASSERT(iteration >= 0); | 151 ASSERT(iteration >= 0); |
| 153 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> inte rpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullpt r; | 152 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> inte rpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullpt r; |
| 154 // FIXME: Handle iteration values which overflow int. | 153 // FIXME: Handle iteration values which overflow int. |
| 155 m_model->sample(static_cast<int>(iteration), timeFraction(), iterationDurati on(), interpolations); | 154 m_model->sample(static_cast<int>(iteration), timeFraction(), iterationDurati on(), interpolations); |
| 156 if (m_sampledEffect) { | 155 if (m_sampledEffect) { |
| 157 m_sampledEffect->setInterpolations(interpolations.release()); | 156 m_sampledEffect->setInterpolations(interpolations.release()); |
| 158 } else if (interpolations && !interpolations->isEmpty()) { | 157 } else if (interpolations && !interpolations->isEmpty()) { |
| 159 OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create( this, interpolations.release()); | 158 OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create( this, interpolations.release()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 m_sampledEffect = nullptr; | 238 m_sampledEffect = nullptr; |
| 240 if (sampledEffect) | 239 if (sampledEffect) |
| 241 sampledEffect->clear(); | 240 sampledEffect->clear(); |
| 242 } | 241 } |
| 243 #endif | 242 #endif |
| 244 | 243 |
| 245 bool KeyframeEffect::isCandidateForAnimationOnCompositor(double animationPlaybac kRate) const | 244 bool KeyframeEffect::isCandidateForAnimationOnCompositor(double animationPlaybac kRate) const |
| 246 { | 245 { |
| 247 if (!model() | 246 if (!model() |
| 248 || !m_target | 247 || !m_target |
| 249 || (m_target->computedStyle() && (m_target->computedStyle()->hasMotionPa th() || m_target->computedStyle()->translate() || m_target->computedStyle()->rot ate() || m_target->computedStyle()->scale()))) | 248 || (m_target->computedStyle() && m_target->computedStyle()->hasMotionPat h())) |
| 250 return false; | 249 return false; |
| 251 | 250 |
| 251 // Do not put transforms on compositor if more than one of them are defined | |
|
dstockwell
2015/07/03 01:58:40
I'm not sure the above is correct now (in applyEff
soonm
2015/07/03 06:34:29
Add tests to check for cancellations happening whe
| |
| 252 // in computed style because they need to be explicitly ordered | |
| 253 if (m_target->computedStyle()) { | |
| 254 unsigned transformOperationsCount = 0; | |
| 255 if (m_target->computedStyle()->hasTransformOperations()) | |
| 256 transformOperationsCount++; | |
| 257 if (m_target->computedStyle()->rotate()) | |
| 258 transformOperationsCount++; | |
| 259 if (m_target->computedStyle()->scale()) | |
| 260 transformOperationsCount++; | |
| 261 if (m_target->computedStyle()->translate()) | |
| 262 transformOperationsCount++; | |
| 263 if (transformOperationsCount > 1) | |
| 264 return false; | |
| 265 } | |
| 266 | |
| 252 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *m_target, animation(), *model(), animationPlaybackRate); | 267 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *m_target, animation(), *model(), animationPlaybackRate); |
| 253 } | 268 } |
| 254 | 269 |
| 255 bool KeyframeEffect::maybeStartAnimationOnCompositor(int group, double startTime , double currentTime, double animationPlaybackRate) | 270 bool KeyframeEffect::maybeStartAnimationOnCompositor(int group, double startTime , double currentTime, double animationPlaybackRate) |
| 256 { | 271 { |
| 257 ASSERT(!hasActiveAnimationsOnCompositor()); | 272 ASSERT(!hasActiveAnimationsOnCompositor()); |
| 258 if (!isCandidateForAnimationOnCompositor(animationPlaybackRate)) | 273 if (!isCandidateForAnimationOnCompositor(animationPlaybackRate)) |
| 259 return false; | 274 return false; |
| 260 if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_targ et)) | 275 if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_targ et)) |
| 261 return false; | 276 return false; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 | 351 |
| 337 DEFINE_TRACE(KeyframeEffect) | 352 DEFINE_TRACE(KeyframeEffect) |
| 338 { | 353 { |
| 339 visitor->trace(m_target); | 354 visitor->trace(m_target); |
| 340 visitor->trace(m_model); | 355 visitor->trace(m_model); |
| 341 visitor->trace(m_sampledEffect); | 356 visitor->trace(m_sampledEffect); |
| 342 AnimationEffect::trace(visitor); | 357 AnimationEffect::trace(visitor); |
| 343 } | 358 } |
| 344 | 359 |
| 345 } // namespace blink | 360 } // namespace blink |
| OLD | NEW |