Changeset 155240 in webkit
- Timestamp:
- Sep 6, 2013 10:28:23 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r155238 r155240 1 2013-09-06 Dirk Schulze <krit@webkit.org> 2 3 Interpolate between CSS filter() and cached images 4 https://bugs.webkit.org/show_bug.cgi?id=120602 5 6 Reviewed by Simon Fraser. 7 8 Add aditional test for interpolation from url to a -webkit-filter function 9 and the other way around. Added an additional test to make sure that different 10 input images don't make start and end interpolate. 11 12 * fast/filter-image/filter-image-animation.html: 13 1 14 2013-09-06 Ryosuke Niwa <rniwa@webkit.org> 2 15 -
trunk/LayoutTests/fast/filter-image/filter-image-animation-expected.txt
r155179 r155240 1 1 2 2 PASS - "backgroundImage" property for "brightness" element at 1s saw something close to: -webkit-filter(url(image.svg), brightness(0.5)) 3 3 PASS - "backgroundImage" property for "blur" element at 1s saw something close to: -webkit-filter(url(image.svg), blur(5px)) … … 8 8 PASS - "backgroundImage" property for "multiple1" element at 1s saw something close to: -webkit-filter(url(image.svg), sepia(0.5) blur(1.5px) hue-rotate(22.5deg)) 9 9 PASS - "backgroundImage" property for "multiple2" element at 1s saw something close to: -webkit-filter(url(image.svg), contrast(0.5) blur(1.5px) hue-rotate(22.5deg)) 10 PASS - "backgroundImage" property for "urlfilter" element at 1s saw something close to: -webkit-filter(url(image.svg), sepia(0.25)) 11 PASS - "backgroundImage" property for "filterurl" element at 1s saw something close to: -webkit-filter(url(image.svg), sepia(0.25)) 12 PASS - "backgroundImage" property for "filterdiffurl" element at 1s saw something close to: -webkit-filter(url(blue.svg), sepia(0.5)) 10 13 PASS - "backgroundImage" property for "generated1" element at 1s saw something close to: -webkit-filter(-webkit-filter(url(image.svg), blur(3px)), sepia(0)) 11 14 PASS - "backgroundImage" property for "generated2" element at 1s saw something close to: -webkit-filter(-webkit-cross-fade(url(image.svg), url(image.svg), 50%), sepia(0)) 12 PASS - "backgroundImage" property for "urlfilter" element at 1s saw something close to: -webkit-filter(url(image.svg), sepia(0.5))13 15 -
trunk/LayoutTests/fast/filter-image/filter-image-animation.html
r155179 r155240 44 44 } 45 45 46 #urlfilter { 47 -webkit-animation: url-to-filter-anim 2s linear; 48 } 49 50 #filterurl { 51 -webkit-animation: filter-to-url-anim 2s linear; 52 } 53 54 #filterdiffurl { 55 -webkit-animation: filter-diff-url-anim 2s linear; 56 } 57 46 58 #generated1 { 47 59 -webkit-animation: generated-anim1 2s linear; … … 51 63 -webkit-animation: generated-anim2 2s linear; 52 64 } 53 54 #urlfilter {55 -webkit-animation: url-to-filter-anim 2s linear;56 }57 58 65 59 66 @-webkit-keyframes brightness-anim { … … 97 104 } 98 105 106 @-webkit-keyframes url-to-filter-anim { 107 from { background-image: url(resources/image.svg); } 108 to { background-image: -webkit-filter(url(resources/image.svg), sepia(0.5)); } 109 } 110 111 @-webkit-keyframes filter-to-url-anim { 112 from { background-image: -webkit-filter(url(resources/image.svg), sepia(0.5)); } 113 to { background-image: url(resources/image.svg); } 114 } 115 116 @-webkit-keyframes filter-diff-url-anim { 117 from { background-image: url(resources/image.svg); } 118 to { background-image: -webkit-filter(url(resources/blue.svg), sepia(0.5)); } 119 } 120 99 121 @-webkit-keyframes generated-anim1 { 100 122 from { background-image: -webkit-filter(-webkit-filter(url(resources/image.svg), blur(3px)), sepia(1)); } … … 105 127 from { background-image: -webkit-filter(-webkit-cross-fade(url(resources/image.svg), url(resources/image.svg), 50%), sepia(1)); } 106 128 to { background-image: -webkit-filter(-webkit-cross-fade(url(resources/image.svg), url(resources/image.svg), 50%), sepia(0)); } 107 }108 109 @-webkit-keyframes url-to-filter-anim {110 from { background-image: url(resources/image.svg); }111 to { background-image: -webkit-filter(url(resources/image.svg), sepia(0.5)); }112 129 } 113 130 </style> … … 124 141 ["multiple-anim1", 1, "multiple1", "backgroundImage", "-webkit-filter(url(image.svg), sepia(0.5) blur(1.5px) hue-rotate(22.5deg))", 0.05], 125 142 ["multiple-anim2", 1, "multiple2", "backgroundImage", "-webkit-filter(url(image.svg), contrast(0.5) blur(1.5px) hue-rotate(22.5deg))", 0.05], 143 ["url-to-filter-anim", 1, "urlfilter", "backgroundImage", " -webkit-filter(url(image.svg), sepia(0.25))", 0.05], 144 ["filter-to-url-anim", 1, "filterurl", "backgroundImage", " -webkit-filter(url(image.svg), sepia(0.25))", 0.05], 145 ["filter-diff-url-anim", 1, "filterdiffurl", "backgroundImage", " -webkit-filter(url(blue.svg), sepia(0.5))", 0], 126 146 // FIXME: We need to support generated images as input to other generated images for animations first. 127 147 ["generated-anim1", 1, "generated1", "backgroundImage", "-webkit-filter(-webkit-filter(url(image.svg), blur(3px)), sepia(0))", 0], 128 148 ["generated-anim2", 1, "generated2", "backgroundImage", "-webkit-filter(-webkit-cross-fade(url(image.svg), url(image.svg), 50%), sepia(0))", 0], 129 ["url-to-filter-anim", 1, "urlfilter", "backgroundImage", " -webkit-filter(url(image.svg), sepia(0.5))", 0],130 149 ]; 131 150 … … 143 162 <div class="box" id="multiple1"></div> 144 163 <div class="box" id="multiple2"></div> 164 <div class="box" id="urlfilter"></div> 165 <div class="box" id="filterurl"></div> 166 <div class="box" id="filterdiffurl"></div> 145 167 <div class="box" id="generated1"></div> 146 168 <div class="box" id="generated2"></div> 147 <div class="box" id="urlfilter"></div>148 169 149 170 <div id="result"> -
trunk/Source/WebCore/ChangeLog
r155234 r155240 1 2013-09-06 Dirk Schulze <krit@webkit.org> 2 3 Interpolate between CSS filter() and cached images 4 https://bugs.webkit.org/show_bug.cgi?id=120602 5 6 Reviewed by Simon Fraser. 7 8 Interpolate from a filter() image function to a url() image reference and 9 the other way around, if the input image on the filter function is the same 10 as the referenced image on url(). 11 12 * page/animation/CSSPropertyAnimation.cpp: Replaced old 13 filterBlend function with blendFilter function which is more generic 14 and can be reused in multiple places. 15 (WebCore::blendFilterOperations): 16 (WebCore::blendFunc): 17 (WebCore::blendFilter): 18 1 19 2013-09-06 Ryosuke Niwa <rniwa@webkit.org> 2 20 -
trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp
r155105 r155240 178 178 } 179 179 180 static inline void blendFilterOperations(const AnimationBase* anim, FilterOperations& result, const FilterOperations& from, const FilterOperations& to, double progress) 181 { 180 static inline FilterOperations blendFilterOperations(const AnimationBase* anim, const FilterOperations& from, const FilterOperations& to, double progress) 181 { 182 FilterOperations result; 182 183 size_t fromSize = from.operations().size(); 183 184 size_t toSize = to.operations().size(); … … 197 198 } 198 199 } 200 return result; 199 201 } 200 202 … … 205 207 // If we have a filter function list, use that to do a per-function animation. 206 208 if (anim->filterFunctionListsMatch()) 207 blendFilterOperations(anim, result, from, to, progress);209 result = blendFilterOperations(anim, from, to, progress); 208 210 else { 209 211 // If the filter function lists don't match, we could try to cross-fade, but don't yet have a way to represent that in CSS. … … 215 217 } 216 218 217 static inline PassRefPtr<StyleImage> filterBlend(const AnimationBase* anim, StyleImage* from, StyleImage* to, double progress) 218 { 219 CSSFilterImageValue* fromValue = static_cast<CSSFilterImageValue*>(from->data()); 220 CSSFilterImageValue* toValue = static_cast<CSSFilterImageValue*>(to->data()); 221 222 FilterOperations filterOperationsResult; 223 blendFilterOperations(anim, filterOperationsResult, fromValue->filterOperations(), toValue->filterOperations(), progress); 224 if (!toValue->cachedImage()) 225 return to; 226 227 RefPtr<StyleCachedImage> styledImage = StyleCachedImage::create(toValue->cachedImage()); 228 229 RefPtr<CSSImageValue> imageValue = CSSImageValue::create(toValue->cachedImage()->url(), styledImage.get()); 230 RefPtr<CSSValue> filterValue = ComputedStyleExtractor::valueForFilter(anim->renderer(), anim->renderer()->style(), 231 filterOperationsResult, DoNotAdjustPixelValues); 219 static inline PassRefPtr<StyleImage> blendFilter(const AnimationBase* anim, CachedImage* image, const FilterOperations& from, const FilterOperations& to, double progress) 220 { 221 ASSERT(image); 222 FilterOperations filterResult = blendFilterOperations(anim, from, to, progress); 223 224 RefPtr<StyleCachedImage> styledImage = StyleCachedImage::create(image); 225 RefPtr<CSSImageValue> imageValue = CSSImageValue::create(image->url(), styledImage.get()); 226 RefPtr<CSSValue> filterValue = ComputedStyleExtractor::valueForFilter(anim->renderer(), anim->renderer()->style(), filterResult, DoNotAdjustPixelValues); 232 227 RefPtr<CSSFilterImageValue> result = CSSFilterImageValue::create(imageValue, filterValue); 233 result->setFilterOperations(filter OperationsResult);228 result->setFilterOperations(filterResult); 234 229 235 230 return StyleGeneratedImage::create(result.get()); … … 320 315 // Animation of generated images just possible if input images are equal. 321 316 // Otherwise fall back to cross fade animation. 322 CSSFilterImageValue& fromFi tler = *toCSSFilterImageValue(fromGenerated);323 CSSFilterImageValue& toFi tler = *toCSSFilterImageValue(toGenerated);324 if (fromFi tler.equalInputImages(toFitler))325 return filterBlend(anim, from, to, progress);317 CSSFilterImageValue& fromFilter = *toCSSFilterImageValue(fromGenerated); 318 CSSFilterImageValue& toFilter = *toCSSFilterImageValue(toGenerated); 319 if (fromFilter.equalInputImages(toFilter) && fromFilter.cachedImage()) 320 return blendFilter(anim, fromFilter.cachedImage(), fromFilter.filterOperations(), toFilter.filterOperations(), progress); 326 321 } 327 322 #endif … … 336 331 // FIXME: Add support for animation between two *gradient() functions. 337 332 // https://bugs.webkit.org/show_bug.cgi?id=119956 333 #if ENABLE(CSS_FILTERS) 334 } else if (from->isGeneratedImage() && to->isCachedImage()) { 335 CSSImageGeneratorValue* fromGenerated = toStyleGeneratedImage(from)->imageValue(); 336 if (fromGenerated->isFilterImageValue()) { 337 CSSFilterImageValue& fromFilter = *toCSSFilterImageValue(fromGenerated); 338 if (fromFilter.cachedImage() && static_cast<StyleCachedImage*>(to)->cachedImage() == fromFilter.cachedImage()) 339 return blendFilter(anim, fromFilter.cachedImage(), fromFilter.filterOperations(), FilterOperations(), progress); 340 } 341 // FIXME: Add interpolation between cross-fade and image source. 342 } else if (from->isCachedImage() && to->isGeneratedImage()) { 343 CSSImageGeneratorValue* toGenerated = toStyleGeneratedImage(to)->imageValue(); 344 if (toGenerated->isFilterImageValue()) { 345 CSSFilterImageValue& toFilter = *toCSSFilterImageValue(toGenerated); 346 if (toFilter.cachedImage() && static_cast<StyleCachedImage*>(from)->cachedImage() == toFilter.cachedImage()) 347 return blendFilter(anim, toFilter.cachedImage(), FilterOperations(), toFilter.filterOperations(), progress); 348 } 349 #endif 350 // FIXME: Add interpolation between image source and cross-fade. 338 351 } 339 352
Note: See TracChangeset
for help on using the changeset viewer.