Changeset 155100 in webkit
- Timestamp:
- Sep 4, 2013 11:50:05 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r155099 r155100 1 2013-09-04 Dirk Schulze <krit@webkit.org> 2 3 Support interpolation between cross-fade() images 4 https://bugs.webkit.org/show_bug.cgi?id=119955 5 6 Reviewed by Darin Adler. 7 8 Test interpolation from one cross-fade function to another. Changed pixel test 9 to a ref test. 10 11 * animations/cross-fade-background-image.html: 12 * animations/cross-fade-background-image-expected.html: Added. 13 * platform/mac/animations/cross-fade-background-image-expected.png: Removed. 14 * platform/mac/animations/cross-fade-background-image-expected.txt: Removed. 15 1 16 2013-09-04 Zoltan Herczeg <zherczeg@webkit.org> 2 17 -
trunk/LayoutTests/animations/cross-fade-background-image.html
r154906 r155100 5 5 position: absolute; 6 6 left: 100px; 7 top: 100px;7 top: 200px; 8 8 height: 100px; 9 9 width: 100px; … … 14 14 position: absolute; 15 15 left: 100px; 16 top: 200px;16 top: 300px; 17 17 height: 100px; 18 18 width: 100px; … … 23 23 position: absolute; 24 24 left: 100px; 25 top: 400px; 26 height: 100px; 27 width: 100px; 28 background-color: red; 29 background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 50%); 30 } 31 #boxAnim1 { 32 position: absolute; 33 left: 200px; 34 top: 200px; 35 height: 100px; 36 width: 100px; 37 background-color: red; 38 -webkit-animation: animCross1 1s linear infinite; 39 } 40 #boxAnim2 { 41 position: absolute; 42 left: 200px; 25 43 top: 300px; 26 44 height: 100px; 27 45 width: 100px; 28 46 background-color: red; 29 background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 50%); 47 -webkit-animation: animCross2 1s linear infinite; 48 } 49 #boxAnim3 { 50 position: absolute; 51 left: 200px; 52 top: 400px; 53 height: 100px; 54 width: 100px; 55 background-color: red; 56 -webkit-animation: animCross3 1s linear infinite; 30 57 } 31 58 @-webkit-keyframes anim { … … 37 64 to { background: url(resources/green-100.png); } 38 65 } 66 @-webkit-keyframes animCross1 { 67 from { background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 20%); } 68 to { background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 0.8); } 69 } 70 @-webkit-keyframes animCross2 { 71 /* Image inputs are not identical - no animation.*/ 72 from { background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 20%); } 73 to { background-image: -webkit-cross-fade(url(resources/green-100.png), url(resources/blue-100.png), 50%); } 74 } 75 @-webkit-keyframes animCross3 { 76 /* Direct image inputs are not identical - no animation.*/ 77 from { background-image: -webkit-cross-fade(-webkit-filter(url(resources/blue-100.png), contrast(0.5)), url(resources/green-100.png), 20%); } 78 to { background-image: -webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 50%); } 79 } 39 80 </style> 40 81 <script src="resources/animation-test-helpers.js" type="text/javascript" charset="utf-8"></script> … … 45 86 ["anim", 2.5, ["box", "static:boxStatic"], "backgroundImage", "-webkit-cross-fade(url(blue-100.png), url(green-100.png), 50%)", 0.05], 46 87 ["animShorthand", 2.5, ["boxShorthand", "static:boxStatic"], "backgroundImage", "-webkit-cross-fade(url(blue-100.png), url(green-100.png), 50%)", 0.05], 88 ["animCross1", 2.5, "boxAnim1", "backgroundImage", "-webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 0.5)", 0.05], 89 ["animCross2", 2.5, "boxAnim2", "backgroundImage", "-webkit-cross-fade(url(resources/green-100.png), url(resources/blue-100.png), 50%)", 0], 90 ["animCross3", 2.5, "boxAnim3", "backgroundImage", "-webkit-cross-fade(url(resources/blue-100.png), url(resources/green-100.png), 50%)", 0], 47 91 ]; 48 92 … … 56 100 <div id="boxStatic"></div> 57 101 <div id="boxShorthand"></div> 102 <div id="boxAnim1"></div> 103 <div id="boxAnim2"></div> 104 <div id="boxAnim3"></div> 58 105 <div id="result"></div> 59 106 </body> -
trunk/Source/WebCore/ChangeLog
r155099 r155100 1 2013-09-04 Dirk Schulze <krit@webkit.org> 2 3 Support interpolation between cross-fade() images 4 https://bugs.webkit.org/show_bug.cgi?id=119955 5 6 Reviewed by Darin Adler. 7 8 With this patch, CSS can animate from one -webkit-cross-fade 9 function to another, when the input images are the same in the 10 same order. 11 12 * css/CSSCrossfadeValue.cpp: Added blend function. 13 (WebCore::blendFunc): 14 (WebCore::CSSCrossfadeValue::blend): 15 (WebCore::CSSCrossfadeValue::equals): 16 (WebCore::CSSCrossfadeValue::equalInputImages): 17 * css/CSSCrossfadeValue.h: Added save casting functions. 18 (WebCore::toCSSCrossfadeValue): 19 * css/CSSValue.h: 20 (WebCore::CSSValue::isCrossfadeValue): 21 * page/animation/CSSPropertyAnimation.cpp: Add another condition to 22 interpolate between two -webkit-cross-fade functions. 23 (WebCore::blendFunc): 24 1 25 2013-09-04 Zoltan Herczeg <zherczeg@webkit.org> 2 26 -
trunk/Source/WebCore/css/CSSCrossfadeValue.cpp
r155060 r155100 1 1 /* 2 2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 #include "CSSCrossfadeValue.h" 28 29 30 #include "AnimationUtilities.h" 29 31 #include "CSSImageValue.h" 30 32 #include "CachedResourceLoader.h" … … 37 39 38 40 namespace WebCore { 41 42 static inline double blendFunc(double from, double to, double progress) 43 { 44 return blend(from, to, progress); 45 } 39 46 40 47 static bool subimageKnownToBeOpaque(CSSValue* value, const RenderObject* renderer) … … 179 186 } 180 187 188 PassRefPtr<CSSCrossfadeValue> CSSCrossfadeValue::blend(const CSSCrossfadeValue& from, double progress) const 189 { 190 ASSERT(equalInputImages(from)); 191 RefPtr<StyleCachedImage> toStyledImage = StyleCachedImage::create(m_cachedToImage.get()); 192 RefPtr<StyleCachedImage> fromStyledImage = StyleCachedImage::create(m_cachedFromImage.get()); 193 194 RefPtr<CSSImageValue> fromImageValue = CSSImageValue::create(m_cachedFromImage->url(), fromStyledImage.get()); 195 RefPtr<CSSImageValue> toImageValue = CSSImageValue::create(m_cachedToImage->url(), toStyledImage.get()); 196 197 RefPtr<CSSCrossfadeValue> crossfadeValue = CSSCrossfadeValue::create(fromImageValue, toImageValue); 198 199 double fromPercentage = from.m_percentageValue->getDoubleValue(); 200 if (from.m_percentageValue->isPercentage()) 201 fromPercentage /= 100.0; 202 double toPercentage = m_percentageValue->getDoubleValue(); 203 if (m_percentageValue->isPercentage()) 204 toPercentage /= 100.0; 205 crossfadeValue->setPercentage(CSSPrimitiveValue::create(blendFunc(fromPercentage, toPercentage, progress), CSSPrimitiveValue::CSS_NUMBER)); 206 return crossfadeValue.release(); 207 } 208 181 209 bool CSSCrossfadeValue::equals(const CSSCrossfadeValue& other) const 182 210 { 211 return equalInputImages(other) 212 && compareCSSValuePtr(m_percentageValue, other.m_percentageValue); 213 } 214 215 216 bool CSSCrossfadeValue::equalInputImages(const CSSCrossfadeValue& other) const 217 { 183 218 return compareCSSValuePtr(m_fromValue, other.m_fromValue) 184 && compareCSSValuePtr(m_toValue, other.m_toValue) 185 && compareCSSValuePtr(m_percentageValue, other.m_percentageValue); 219 && compareCSSValuePtr(m_toValue, other.m_toValue); 186 220 } 187 221 -
trunk/Source/WebCore/css/CSSCrossfadeValue.h
r155060 r155100 66 66 bool hasFailedOrCanceledSubresources() const; 67 67 68 PassRefPtr<CSSCrossfadeValue> blend(const CSSCrossfadeValue&, double) const; 69 68 70 bool equals(const CSSCrossfadeValue&) const; 71 72 bool equalInputImages(const CSSCrossfadeValue&) const; 69 73 70 74 private: … … 107 111 }; 108 112 113 inline CSSCrossfadeValue* toCSSCrossfadeValue(CSSImageGeneratorValue* value) 114 { 115 ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isCrossfadeValue()); 116 return static_cast<CSSCrossfadeValue*>(value); 117 } 118 109 119 } // namespace WebCore 110 120 -
trunk/Source/WebCore/css/CSSValue.h
r154133 r155100 72 72 bool isAspectRatioValue() const { return m_classType == AspectRatioClass; } 73 73 bool isBorderImageSliceValue() const { return m_classType == BorderImageSliceClass; } 74 bool isCrossfadeValue() const { return m_classType == CrossfadeClass; } 74 75 bool isCursorImageValue() const { return m_classType == CursorImageClass; } 75 76 bool isFontFeatureValue() const { return m_classType == FontFeatureClass; } -
trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp
r154906 r155100 1 1 /* 2 2 * Copyright (C) 2007, 2008, 2009, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.3 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 317 317 // Animation of generated images just possible if input images are equal. 318 318 // Otherwise fall back to cross fade animation. 319 CSSFilterImageValue * fromFitler =toCSSFilterImageValue(fromGenerated);320 CSSFilterImageValue * toFitler =toCSSFilterImageValue(toGenerated);321 if (fromFitler ->equalInputImages(*toFitler))319 CSSFilterImageValue& fromFitler = *toCSSFilterImageValue(fromGenerated); 320 CSSFilterImageValue& toFitler = *toCSSFilterImageValue(toGenerated); 321 if (fromFitler.equalInputImages(toFitler)) 322 322 return filterBlend(anim, from, to, progress); 323 323 } 324 #else 325 UNUSED_PARAM(fromGenerated); 326 UNUSED_PARAM(toGenerated); 327 #endif 328 // FIXME: Add support for animation between two cross-fade() functions. 329 // https://bugs.webkit.org/show_bug.cgi?id=119955 324 #endif 325 326 if (fromGenerated->isCrossfadeValue() && toGenerated->isCrossfadeValue()) { 327 CSSCrossfadeValue& fromCrossfade = *toCSSCrossfadeValue(fromGenerated); 328 CSSCrossfadeValue& toCrossfade = *toCSSCrossfadeValue(toGenerated); 329 if (fromCrossfade.equalInputImages(toCrossfade)) 330 return StyleGeneratedImage::create(toCrossfade.blend(fromCrossfade, progress).get()); 331 } 330 332 331 333 // FIXME: Add support for animation between two *gradient() functions. 332 334 // https://bugs.webkit.org/show_bug.cgi?id=119956 333 }335 } 334 336 335 337 // FIXME: Add support cross fade between cached and generated images.
Note: See TracChangeset
for help on using the changeset viewer.