| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ASSERT(animation()->source() == this); | 122 ASSERT(animation()->source() == this); |
| 123 animation()->setCompositorPending(true); | 123 animation()->setCompositorPending(true); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 static AnimationStack& ensureAnimationStack(Element* element) | 127 static AnimationStack& ensureAnimationStack(Element* element) |
| 128 { | 128 { |
| 129 return element->ensureElementAnimations().defaultStack(); | 129 return element->ensureElementAnimations().defaultStack(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool KeyframeEffect::hasIncompatibleStyle() |
| 133 { |
| 134 if (!m_target->computedStyle()) |
| 135 return false; |
| 136 |
| 137 bool affectsTransform = animation()->affects(*m_target, CSSPropertyTransform
) |
| 138 || animation()->affects(*m_target, CSSPropertyScale) |
| 139 || animation()->affects(*m_target, CSSPropertyRotate) |
| 140 || animation()->affects(*m_target, CSSPropertyTranslate); |
| 141 |
| 142 if (animation()->hasActiveAnimationsOnCompositor()) { |
| 143 if (m_target->computedStyle()->hasMotionPath() && affectsTransform) |
| 144 return true; |
| 145 |
| 146 if ((m_target->computedStyle()->hasTransformOperations() |
| 147 || m_target->computedStyle()->rotate() |
| 148 || m_target->computedStyle()->scale() |
| 149 || m_target->computedStyle()->translate()) |
| 150 && affectsTransform) |
| 151 return true; |
| 152 } |
| 153 |
| 154 return false; |
| 155 } |
| 156 |
| 132 void KeyframeEffect::applyEffects() | 157 void KeyframeEffect::applyEffects() |
| 133 { | 158 { |
| 134 ASSERT(isInEffect()); | 159 ASSERT(isInEffect()); |
| 135 ASSERT(animation()); | 160 ASSERT(animation()); |
| 136 if (!m_target || !m_model) | 161 if (!m_target || !m_model) |
| 137 return; | 162 return; |
| 138 | 163 |
| 139 // Cancel composited animation of transform if a motion path, translate, | 164 // Cancel composited animation of transform, translate, rotate or scale |
| 140 // rotate or scale operation has been introduced on the element. | 165 // if a motion path has been introduced on the element. |
| 141 if (m_target->computedStyle() | 166 if (hasIncompatibleStyle()) |
| 142 && (m_target->computedStyle()->hasMotionPath() | |
| 143 || m_target->computedStyle()->translate() | |
| 144 || m_target->computedStyle()->rotate() | |
| 145 || m_target->computedStyle()->scale()) | |
| 146 && animation()->hasActiveAnimationsOnCompositor() | |
| 147 && animation()->affects(*m_target, CSSPropertyTransform)) { | |
| 148 animation()->cancelAnimationOnCompositor(); | 167 animation()->cancelAnimationOnCompositor(); |
| 149 } | |
| 150 | 168 |
| 151 double iteration = currentIteration(); | 169 double iteration = currentIteration(); |
| 152 ASSERT(iteration >= 0); | 170 ASSERT(iteration >= 0); |
| 153 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> inte
rpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullpt
r; | 171 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> inte
rpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullpt
r; |
| 154 // FIXME: Handle iteration values which overflow int. | 172 // FIXME: Handle iteration values which overflow int. |
| 155 m_model->sample(static_cast<int>(iteration), timeFraction(), iterationDurati
on(), interpolations); | 173 m_model->sample(static_cast<int>(iteration), timeFraction(), iterationDurati
on(), interpolations); |
| 156 if (m_sampledEffect) { | 174 if (m_sampledEffect) { |
| 157 m_sampledEffect->setInterpolations(interpolations.release()); | 175 m_sampledEffect->setInterpolations(interpolations.release()); |
| 158 } else if (interpolations && !interpolations->isEmpty()) { | 176 } else if (interpolations && !interpolations->isEmpty()) { |
| 159 OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create(
this, interpolations.release()); | 177 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; | 257 m_sampledEffect = nullptr; |
| 240 if (sampledEffect) | 258 if (sampledEffect) |
| 241 sampledEffect->clear(); | 259 sampledEffect->clear(); |
| 242 } | 260 } |
| 243 #endif | 261 #endif |
| 244 | 262 |
| 245 bool KeyframeEffect::isCandidateForAnimationOnCompositor(double animationPlaybac
kRate) const | 263 bool KeyframeEffect::isCandidateForAnimationOnCompositor(double animationPlaybac
kRate) const |
| 246 { | 264 { |
| 247 if (!model() | 265 if (!model() |
| 248 || !m_target | 266 || !m_target |
| 249 || (m_target->computedStyle() && (m_target->computedStyle()->hasMotionPa
th() || m_target->computedStyle()->translate() || m_target->computedStyle()->rot
ate() || m_target->computedStyle()->scale()))) | 267 || (m_target->computedStyle() && m_target->computedStyle()->hasMotionPat
h())) |
| 250 return false; | 268 return false; |
| 251 | 269 |
| 270 // Do not put transforms on compositor if more than one of them are defined |
| 271 // in computed style because they need to be explicitly ordered |
| 272 if (m_target->computedStyle()) { |
| 273 unsigned transformPropertysCount = 0; |
| 274 if (m_target->computedStyle()->hasTransformOperations()) |
| 275 transformPropertysCount++; |
| 276 if (m_target->computedStyle()->rotate()) |
| 277 transformPropertysCount++; |
| 278 if (m_target->computedStyle()->scale()) |
| 279 transformPropertysCount++; |
| 280 if (m_target->computedStyle()->translate()) |
| 281 transformPropertysCount++; |
| 282 if (transformPropertysCount > 1) |
| 283 return false; |
| 284 } |
| 285 |
| 252 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor
(specifiedTiming(), *m_target, animation(), *model(), animationPlaybackRate); | 286 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor
(specifiedTiming(), *m_target, animation(), *model(), animationPlaybackRate); |
| 253 } | 287 } |
| 254 | 288 |
| 255 bool KeyframeEffect::maybeStartAnimationOnCompositor(int group, double startTime
, double currentTime, double animationPlaybackRate) | 289 bool KeyframeEffect::maybeStartAnimationOnCompositor(int group, double startTime
, double currentTime, double animationPlaybackRate) |
| 256 { | 290 { |
| 257 ASSERT(!hasActiveAnimationsOnCompositor()); | 291 ASSERT(!hasActiveAnimationsOnCompositor()); |
| 258 if (!isCandidateForAnimationOnCompositor(animationPlaybackRate)) | 292 if (!isCandidateForAnimationOnCompositor(animationPlaybackRate)) |
| 259 return false; | 293 return false; |
| 260 if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_targ
et)) | 294 if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_targ
et)) |
| 261 return false; | 295 return false; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 370 |
| 337 DEFINE_TRACE(KeyframeEffect) | 371 DEFINE_TRACE(KeyframeEffect) |
| 338 { | 372 { |
| 339 visitor->trace(m_target); | 373 visitor->trace(m_target); |
| 340 visitor->trace(m_model); | 374 visitor->trace(m_model); |
| 341 visitor->trace(m_sampledEffect); | 375 visitor->trace(m_sampledEffect); |
| 342 AnimationEffect::trace(visitor); | 376 AnimationEffect::trace(visitor); |
| 343 } | 377 } |
| 344 | 378 |
| 345 } // namespace blink | 379 } // namespace blink |
| OLD | NEW |