Changeset 156391 in webkit
- Timestamp:
- Sep 25, 2013 6:53:08 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r156389 r156391 1 2013-09-25 Andrei Parvu <parvu@adobe.com> 2 3 <https://webkit.org/b/120476> [CSS Masking] Implement luminance masking 4 5 Added tests to verify the implementation of luminance masking. 6 7 Reviewed by Dirk Schulze. 8 9 * css3/masking/mask-luminance-gradient-expected.html: Added. 10 * css3/masking/mask-luminance-gradient.html: Added. 11 * css3/masking/mask-luminance-png.html: Added. 12 * css3/masking/mask-luminance-svg-expected.html: Added. 13 * css3/masking/mask-luminance-svg.html: Added. 14 * css3/masking/resources/circle-alpha.svg: Added. 15 * css3/masking/resources/circle2.svg: Added. 16 * css3/masking/resources/dice.png: Added. 17 * platform/mac/css3/masking/mask-luminance-png-expected.txt: Added. 18 1 19 2013-09-25 Krzysztof Czech <k.czech@samsung.com> 2 20 -
trunk/Source/WebCore/ChangeLog
r156390 r156391 1 2013-09-25 Andrei Parvu <parvu@adobe.com> 2 3 <https://webkit.org/b/120476> [CSS Masking] Implement luminance masking 4 5 Added implementation for luminance masking. A luminance mask is applied by transforming its RGB values into 6 an alpha value, using luminance-to-alpha coefficients. Because this conversion is already implemented in 7 the ImageBuffer class, we used it in our implementation. 8 9 Reviewed by Dirk Schulze. 10 11 Tests: css3/masking/mask-luminance-gradient.html 12 css3/masking/mask-luminance-png.html 13 css3/masking/mask-luminance-svg.html 14 15 * platform/graphics/BitmapImage.cpp: Add a drawPattern method, in which an ImageBuffer is created and converted from alpha to luminance, if there is a luminance mask. 16 (WebCore::BitmapImage::BitmapImage): 17 (WebCore::BitmapImage::drawPattern): 18 * platform/graphics/BitmapImage.h: 19 * platform/graphics/GeneratorGeneratedImage.cpp: Convert the ImageBuffer to luminance, if necessary. 20 (WebCore::GeneratorGeneratedImage::drawPattern): 21 * platform/graphics/GraphicsContext.cpp: Add methods which set and check if a luminance mask is drawn. 22 (WebCore::GraphicsContext::setDrawLuminanceMask): 23 (WebCore::GraphicsContext::drawLuminanceMask): 24 * platform/graphics/GraphicsContext.h: Add property to ContextState for luminance drawing. 25 (WebCore::GraphicsContextState::GraphicsContextState): 26 * rendering/RenderBoxModelObject.cpp: Set the luminance property of the mask, if the layer has a mask source type of luminance. 27 (WebCore::RenderBoxModelObject::paintFillLayerExtended): 28 * svg/graphics/SVGImage.cpp: Convert the ImageBuffer to luminance, if necessary. 29 (WebCore::SVGImage::drawPatternForContainer): 30 * svg/graphics/SVGImageForContainer.cpp: Pass the luminance property to the SVG image. 31 (WebCore::SVGImageForContainer::drawPattern): 32 1 33 2013-09-25 Andreas Kling <akling@apple.com> 2 34 -
trunk/Source/WebCore/platform/graphics/BitmapImage.cpp
r155721 r156391 29 29 30 30 #include "FloatRect.h" 31 #include "ImageBuffer.h" 31 32 #include "ImageObserver.h" 32 33 #include "IntRect.h" … … 59 60 , m_hasUniformFrameSize(true) 60 61 , m_haveFrameCount(false) 62 , m_cachedImage(0) 61 63 { 62 64 } … … 493 495 } 494 496 497 void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& transform, 498 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode) 499 { 500 if (tileRect.isEmpty()) 501 return; 502 503 if (!ctxt->drawLuminanceMask()) { 504 Image::drawPattern(ctxt, tileRect, transform, phase, styleColorSpace, op, destRect, blendMode); 505 return; 506 } 507 if (!m_cachedImage) { 508 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(expandedIntSize(tileRect.size())); 509 ASSERT(buffer.get() > 0); 510 511 ImageObserver* observer = imageObserver(); 512 ASSERT(observer); 513 514 // Temporarily reset image observer, we don't want to receive any changeInRect() calls due to this relayout. 515 setImageObserver(0); 516 517 draw(buffer->context(), tileRect, tileRect, styleColorSpace, op, blendMode); 518 519 setImageObserver(observer); 520 buffer->convertToLuminanceMask(); 521 522 m_cachedImage = buffer->copyImage(DontCopyBackingStore, Unscaled); 523 m_cachedImage->setSpaceSize(spaceSize()); 524 525 setImageObserver(observer); 526 } 527 528 ctxt->setDrawLuminanceMask(false); 529 m_cachedImage->drawPattern(ctxt, tileRect, transform, phase, styleColorSpace, op, destRect, blendMode); 530 } 495 531 496 532 -
trunk/Source/WebCore/platform/graphics/BitmapImage.h
r156226 r156391 137 137 virtual unsigned decodedSize() const OVERRIDE; 138 138 139 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, 140 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal) OVERRIDE; 141 139 142 #if PLATFORM(MAC) 140 143 // Accessors for native image formats. … … 297 300 mutable bool m_hasUniformFrameSize : 1; 298 301 mutable bool m_haveFrameCount : 1; 302 303 RefPtr<Image> m_cachedImage; 299 304 }; 300 305 -
trunk/Source/WebCore/platform/graphics/GradientImage.cpp
r156226 r156391 73 73 m_cachedGeneratorHash = generatorHash; 74 74 m_cachedAdjustedSize = adjustedSize; 75 76 if (destContext->drawLuminanceMask()) 77 m_cachedImageBuffer->convertToLuminanceMask(); 75 78 } 76 79 77 80 m_cachedImageBuffer->setSpaceSize(spaceSize()); 81 destContext->setDrawLuminanceMask(false); 82 78 83 // Tile the image buffer into the context. 79 84 m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect); -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r154088 r156391 739 739 } 740 740 741 void GraphicsContext::setDrawLuminanceMask(bool drawLuminanceMask) 742 { 743 m_state.drawLuminanceMask = drawLuminanceMask; 744 } 745 746 bool GraphicsContext::drawLuminanceMask() const 747 { 748 return m_state.drawLuminanceMask; 749 } 750 741 751 #if !USE(CG) 742 752 // Implement this if you want to go ahead and push the drawing mode into your native context -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r154088 r156391 151 151 , shadowsUseLegacyRadius(false) 152 152 #endif 153 , drawLuminanceMask(false) 153 154 { 154 155 } … … 189 190 bool shadowsUseLegacyRadius : 1; 190 191 #endif 192 bool drawLuminanceMask : 1; 191 193 }; 192 194 … … 382 384 CompositeOperator compositeOperation() const; 383 385 BlendMode blendModeOperation() const; 386 387 void setDrawLuminanceMask(bool); 388 bool drawLuminanceMask() const; 384 389 385 390 void clip(const Path&, WindRule = RULE_EVENODD); -
trunk/Source/WebCore/platform/graphics/Image.cpp
r154875 r156391 121 121 122 122 // Check and see if a single draw of the image can cover the entire area we are supposed to tile. 123 if (oneTileRect.contains(destRect) ) {123 if (oneTileRect.contains(destRect) && !ctxt->drawLuminanceMask()) { 124 124 FloatRect visibleSrcRect; 125 125 visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width()); -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r156322 r156391 798 798 RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this; 799 799 RefPtr<Image> image = bgImage->image(clientForBackgroundImage, geometry.tileSize()); 800 context->setDrawLuminanceMask(bgLayer->maskSourceType() == MaskLuminance); 800 801 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image.get(), bgLayer, geometry.tileSize()); 801 802 if (image.get()) -
trunk/Source/WebCore/svg/graphics/SVGImage.cpp
r155217 r156391 202 202 return; 203 203 drawForContainer(buffer->context(), containerSize, zoom, imageBufferSize, zoomedContainerRect, ColorSpaceDeviceRGB, CompositeSourceOver, BlendModeNormal); 204 if (context->drawLuminanceMask()) 205 buffer->convertToLuminanceMask(); 206 204 207 RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore, Unscaled); 205 208 image->setSpaceSize(spaceSize()); … … 211 214 unscaledPatternTransform.scale(1 / imageBufferScale.width(), 1 / imageBufferScale.height()); 212 215 216 context->setDrawLuminanceMask(false); 213 217 image->drawPattern(context, scaledSrcRect, unscaledPatternTransform, phase, colorSpace, compositeOp, dstRect); 214 218 }
Note: See TracChangeset
for help on using the changeset viewer.