OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010, 2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010, 2011. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 #include "core/svg/SVGPathBlender.h" | 21 #include "core/svg/SVGPathBlender.h" |
22 | 22 |
23 #include "core/svg/SVGPathSeg.h" | 23 #include "core/svg/SVGPathSeg.h" |
24 #include "core/svg/SVGPathSource.h" | 24 #include "core/svg/SVGPathSource.h" |
25 #include "platform/animation/AnimationUtilities.h" | 25 #include "platform/animation/AnimationUtilities.h" |
26 #include "wtf/TemporaryChange.h" | 26 #include "wtf/TemporaryChange.h" |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
29 | 29 |
30 SVGPathBlender::SVGPathBlender() | 30 SVGPathBlender::SVGPathBlender(SVGPathSource* fromSource, SVGPathSource* toSourc
e, SVGPathConsumer* consumer) |
31 : m_fromSource(nullptr) | 31 : m_fromSource(fromSource) |
32 , m_toSource(nullptr) | 32 , m_toSource(toSource) |
33 , m_consumer(nullptr) | 33 , m_consumer(consumer) |
34 , m_progress(0) | 34 , m_progress(0) |
35 , m_addTypesCount(0) | 35 , m_addTypesCount(0) |
36 , m_isInFirstHalfOfAnimation(false) | 36 , m_isInFirstHalfOfAnimation(false) |
37 { | 37 { |
| 38 ASSERT(m_fromSource); |
| 39 ASSERT(m_toSource); |
| 40 ASSERT(m_consumer); |
38 } | 41 } |
39 | 42 |
40 void SVGPathBlender::trace(Visitor* visitor) | 43 void SVGPathBlender::trace(Visitor* visitor) |
41 { | 44 { |
42 visitor->trace(m_fromSource); | 45 visitor->trace(m_fromSource); |
43 visitor->trace(m_toSource); | 46 visitor->trace(m_toSource); |
44 visitor->trace(m_consumer); | 47 visitor->trace(m_consumer); |
45 } | 48 } |
46 | 49 |
47 // Helper functions | 50 // Helper functions |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 299 |
297 unsigned short from = fromType; | 300 unsigned short from = fromType; |
298 unsigned short to = toType; | 301 unsigned short to = toType; |
299 if (fromMode == toMode) | 302 if (fromMode == toMode) |
300 return from == to; | 303 return from == to; |
301 if (fromMode == AbsoluteCoordinates) | 304 if (fromMode == AbsoluteCoordinates) |
302 return from == to - 1; | 305 return from == to - 1; |
303 return to == from - 1; | 306 return to == from - 1; |
304 } | 307 } |
305 | 308 |
306 bool SVGPathBlender::addAnimatedPath(SVGPathSource* fromSource, SVGPathSource* t
oSource, SVGPathConsumer* consumer, unsigned repeatCount) | 309 bool SVGPathBlender::addAnimatedPath(unsigned repeatCount) |
307 { | 310 { |
308 TemporaryChange<unsigned> change(m_addTypesCount, repeatCount); | 311 TemporaryChange<unsigned> change(m_addTypesCount, repeatCount); |
309 return blendAnimatedPath(0, fromSource, toSource, consumer); | 312 return blendAnimatedPath(0); |
310 } | 313 } |
311 | 314 |
312 bool SVGPathBlender::blendAnimatedPath(float progress, SVGPathSource* fromSource
, SVGPathSource* toSource, SVGPathConsumer* consumer) | 315 bool SVGPathBlender::blendAnimatedPath(float progress) |
313 { | 316 { |
314 ASSERT(fromSource); | |
315 ASSERT(toSource); | |
316 ASSERT(consumer); | |
317 m_fromSource = fromSource; | |
318 m_toSource = toSource; | |
319 m_consumer = consumer; | |
320 m_isInFirstHalfOfAnimation = progress < 0.5f; | 317 m_isInFirstHalfOfAnimation = progress < 0.5f; |
321 m_progress = progress; | 318 m_progress = progress; |
322 | 319 |
323 bool fromSourceHadData = m_fromSource->hasMoreData(); | 320 bool fromSourceHadData = m_fromSource->hasMoreData(); |
324 while (m_toSource->hasMoreData()) { | 321 while (m_toSource->hasMoreData()) { |
325 SVGPathSegType fromCommand; | 322 SVGPathSegType fromCommand; |
326 SVGPathSegType toCommand; | 323 SVGPathSegType toCommand; |
327 if ((fromSourceHadData && !m_fromSource->parseSVGSegmentType(fromCommand
)) || !m_toSource->parseSVGSegmentType(toCommand)) | 324 if ((fromSourceHadData && !m_fromSource->parseSVGSegmentType(fromCommand
)) || !m_toSource->parseSVGSegmentType(toCommand)) |
328 return false; | 325 return false; |
329 | 326 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 continue; | 389 continue; |
393 if (m_fromSource->hasMoreData() != m_toSource->hasMoreData()) | 390 if (m_fromSource->hasMoreData() != m_toSource->hasMoreData()) |
394 return false; | 391 return false; |
395 if (!m_fromSource->hasMoreData() || !m_toSource->hasMoreData()) | 392 if (!m_fromSource->hasMoreData() || !m_toSource->hasMoreData()) |
396 return true; | 393 return true; |
397 } | 394 } |
398 | 395 |
399 return true; | 396 return true; |
400 } | 397 } |
401 | 398 |
402 void SVGPathBlender::cleanup() | |
403 { | |
404 ASSERT(m_toSource); | |
405 ASSERT(m_fromSource); | |
406 ASSERT(m_consumer); | |
407 | |
408 m_consumer->cleanup(); | |
409 m_toSource = nullptr; | |
410 m_fromSource = nullptr; | |
411 m_consumer = nullptr; | |
412 m_fromCurrentPoint = FloatPoint(); | |
413 m_toCurrentPoint = FloatPoint(); | |
414 } | 399 } |
415 | |
416 } | |
OLD | NEW |