Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: Source/core/animation/KeyframeEffect.cpp

Issue 1218943002: Compositor animations for Independent CSS Transform Properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
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() 143 || m_target->computedStyle()->rotate()
145 || m_target->computedStyle()->scale()) 144 || m_target->computedStyle()->scale()
145 || m_target->computedStyle()->translate())
146 && animation()->hasActiveAnimationsOnCompositor() 146 && animation()->hasActiveAnimationsOnCompositor()
147 && animation()->affects(*m_target, CSSPropertyTransform)) { 147 && (animation()->affects(*m_target, CSSPropertyScale)
148 || animation()->affects(*m_target, CSSPropertyRotate)
149 || animation()->affects(*m_target, CSSPropertyTransform)
150 || animation()->affects(*m_target, CSSPropertyTranslate))) {
148 animation()->cancelAnimationOnCompositor(); 151 animation()->cancelAnimationOnCompositor();
149 } 152 }
150 153
151 double iteration = currentIteration(); 154 double iteration = currentIteration();
152 ASSERT(iteration >= 0); 155 ASSERT(iteration >= 0);
153 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> inte rpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullpt r; 156 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> inte rpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullpt r;
154 // FIXME: Handle iteration values which overflow int. 157 // FIXME: Handle iteration values which overflow int.
155 m_model->sample(static_cast<int>(iteration), timeFraction(), iterationDurati on(), interpolations); 158 m_model->sample(static_cast<int>(iteration), timeFraction(), iterationDurati on(), interpolations);
156 if (m_sampledEffect) { 159 if (m_sampledEffect) {
157 m_sampledEffect->setInterpolations(interpolations.release()); 160 m_sampledEffect->setInterpolations(interpolations.release());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 m_sampledEffect = nullptr; 242 m_sampledEffect = nullptr;
240 if (sampledEffect) 243 if (sampledEffect)
241 sampledEffect->clear(); 244 sampledEffect->clear();
242 } 245 }
243 #endif 246 #endif
244 247
245 bool KeyframeEffect::isCandidateForAnimationOnCompositor(double animationPlaybac kRate) const 248 bool KeyframeEffect::isCandidateForAnimationOnCompositor(double animationPlaybac kRate) const
246 { 249 {
247 if (!model() 250 if (!model()
248 || !m_target 251 || !m_target
249 || (m_target->computedStyle() && (m_target->computedStyle()->hasMotionPa th() || m_target->computedStyle()->translate() || m_target->computedStyle()->rot ate() || m_target->computedStyle()->scale()))) 252 || (m_target->computedStyle() && m_target->computedStyle()->hasMotionPat h()))
250 return false; 253 return false;
251 254
255 // Do not put transforms on compositor if more than one of them are defined
256 // in computed style because they need to be explicitly ordered
257 if (m_target->computedStyle()) {
258 unsigned transformOperationsCount = 0;
259 if (m_target->computedStyle()->hasTransformOperations())
260 transformOperationsCount++;
261 if (m_target->computedStyle()->rotate())
262 transformOperationsCount++;
263 if (m_target->computedStyle()->scale())
264 transformOperationsCount++;
265 if (m_target->computedStyle()->translate())
266 transformOperationsCount++;
267 if (transformOperationsCount > 1)
268 return false;
269 }
270
252 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *m_target, animation(), *model(), animationPlaybackRate); 271 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *m_target, animation(), *model(), animationPlaybackRate);
253 } 272 }
254 273
255 bool KeyframeEffect::maybeStartAnimationOnCompositor(int group, double startTime , double currentTime, double animationPlaybackRate) 274 bool KeyframeEffect::maybeStartAnimationOnCompositor(int group, double startTime , double currentTime, double animationPlaybackRate)
256 { 275 {
257 ASSERT(!hasActiveAnimationsOnCompositor()); 276 ASSERT(!hasActiveAnimationsOnCompositor());
258 if (!isCandidateForAnimationOnCompositor(animationPlaybackRate)) 277 if (!isCandidateForAnimationOnCompositor(animationPlaybackRate))
259 return false; 278 return false;
260 if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_targ et)) 279 if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_targ et))
261 return false; 280 return false;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 355
337 DEFINE_TRACE(KeyframeEffect) 356 DEFINE_TRACE(KeyframeEffect)
338 { 357 {
339 visitor->trace(m_target); 358 visitor->trace(m_target);
340 visitor->trace(m_model); 359 visitor->trace(m_model);
341 visitor->trace(m_sampledEffect); 360 visitor->trace(m_sampledEffect);
342 AnimationEffect::trace(visitor); 361 AnimationEffect::trace(visitor);
343 } 362 }
344 363
345 } // namespace blink 364 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698