Changeset 157045 in webkit
- Timestamp:
- Oct 7, 2013 9:48:09 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r157043 r157045 1 2013-10-07 Tim Horton <timothy_horton@apple.com> 2 3 -webkit-cross-fade paints SVGs at full opacity during cross-fade 4 https://bugs.webkit.org/show_bug.cgi?id=122441 5 <rdar://problem/13973162> 6 7 Reviewed by Simon Fraser. 8 9 Add a test that ensures that -cross-fade with SVG images draws correctly. 10 11 * css3/images/cross-fade-svg-with-opacity-expected.html: Added. 12 * css3/images/cross-fade-svg-with-opacity.html: Added. 13 1 14 2013-10-07 Filip Pizlo <fpizlo@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r157044 r157045 1 2013-10-07 Tim Horton <timothy_horton@apple.com> 2 3 -webkit-cross-fade paints SVGs at full opacity during cross-fade 4 https://bugs.webkit.org/show_bug.cgi?id=122441 5 <rdar://problem/13973162> 6 7 Reviewed by Simon Fraser. 8 9 Test: css3/images/cross-fade-svg-with-opacity.html 10 11 * platform/graphics/CrossfadeGeneratedImage.cpp: 12 (WebCore::drawCrossfadeSubimage): 13 (WebCore::CrossfadeGeneratedImage::drawCrossfade): 14 Factor the image painting out into a function. 15 Conditionally use a transparency layer around painting if the image 16 we're drawing is an SVG (SVGImage is the only Image subclass that will 17 not respect the context's opacity). 18 1 19 2013-10-06 Anders Carlsson <andersca@apple.com> 2 20 -
trunk/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp
r155721 r157045 44 44 } 45 45 46 static void drawCrossfadeSubimage(GraphicsContext* context, Image* image, CompositeOperator operation, float opacity, IntSize targetSize) 47 { 48 IntSize imageSize = image->size(); 49 50 // SVGImage resets the opacity when painting, so we have to use transparency layers to accurately paint one at a given opacity. 51 bool useTransparencyLayer = image->isSVGImage(); 52 53 GraphicsContextStateSaver stateSaver(*context); 54 55 context->setCompositeOperation(operation); 56 57 if (useTransparencyLayer) 58 context->beginTransparencyLayer(opacity); 59 else 60 context->setAlpha(opacity); 61 62 if (targetSize != imageSize) 63 context->scale(FloatSize(static_cast<float>(targetSize.width()) / imageSize.width(), 64 static_cast<float>(targetSize.height()) / imageSize.height())); 65 context->drawImage(image, ColorSpaceDeviceRGB, IntPoint()); 66 67 if (useTransparencyLayer) 68 context->endTransparencyLayer(); 69 } 70 46 71 void CrossfadeGeneratedImage::drawCrossfade(GraphicsContext* context) 47 72 { 48 float inversePercentage = 1 - m_percentage;49 50 IntSize fromImageSize = m_fromImage->size();51 IntSize toImageSize = m_toImage->size();52 53 73 // Draw nothing if either of the images hasn't loaded yet. 54 74 if (m_fromImage == Image::nullImage() || m_toImage == Image::nullImage()) … … 59 79 context->clip(IntRect(IntPoint(), m_crossfadeSize)); 60 80 context->beginTransparencyLayer(1); 61 62 // Draw the image we're fading away from.63 context->save();64 if (m_crossfadeSize != fromImageSize)65 context->scale(FloatSize(static_cast<float>(m_crossfadeSize.width()) / fromImageSize.width(),66 static_cast<float>(m_crossfadeSize.height()) / fromImageSize.height()));67 context->setAlpha(inversePercentage);68 context->drawImage(m_fromImage, ColorSpaceDeviceRGB, IntPoint());69 context->restore();70 81 71 // Draw the image we're fading towards. 72 context->save(); 73 if (m_crossfadeSize != toImageSize) 74 context->scale(FloatSize(static_cast<float>(m_crossfadeSize.width()) / toImageSize.width(), 75 static_cast<float>(m_crossfadeSize.height()) / toImageSize.height())); 76 context->setAlpha(m_percentage); 77 context->drawImage(m_toImage, ColorSpaceDeviceRGB, IntPoint(), CompositePlusLighter); 78 context->restore(); 82 drawCrossfadeSubimage(context, m_fromImage, CompositeSourceOver, 1 - m_percentage, m_crossfadeSize); 83 drawCrossfadeSubimage(context, m_toImage, CompositePlusLighter, m_percentage, m_crossfadeSize); 79 84 80 85 context->endTransparencyLayer();
Note: See TracChangeset
for help on using the changeset viewer.