Changeset 141637 in webkit


Ignore:
Timestamp:
Feb 1, 2013 1:31:00 PM (11 years ago)
Author:
pdr@google.com
Message:

Change hasAlpha to isKnownToBeOpaque and correct the return value for SVG images.
https://bugs.webkit.org/show_bug.cgi?id=106966

Reviewed by Stephen White.

Source/WebCore:

Previously, Image::currentFrameHasAlpha's default implementation returned false so SVG
images always returned false for currentFrameHasAlpha. Additionally, currentFrameHasAlpha
was treated as returning whether the frame had alpha when it would actually conservatively
return true.

This patch renames hasAlpha and currentFrameHasAlpha to isKnownToBeOpaque and
currentFrameIsKnownToBeOpaque, respectively. This rename better describes the actual
functionality. This patch also makes Image::isKnownToBeOpaque a pure virtual function and
correctly implements it for SVG images.

All users of isKnownToBeOpaque access SVG images using CachedImage::imageForRenderer which
currently returns a cached bitmap image. Therefore, this patch will not affect existing
functionality. A regression test has been added that will catch if this changes in the
future (e.g., WK106159 which proposes not returning cached bitmaps). The now unnecessary
isBitmapImage() calls have been removed in this patch.

image-box-shadow.html has been modified to test SVG images.

  • css/CSSCrossfadeValue.cpp:

(WebCore::subimageKnownToBeOpaque):
(WebCore::CSSCrossfadeValue::knownToBeOpaque):

Mostly straightforward rename but note the logic has been slightly altered: AND -> OR.

  • css/CSSCrossfadeValue.h:

(CSSCrossfadeValue):

  • css/CSSGradientValue.cpp:

(WebCore::CSSGradientValue::knownToBeOpaque):

  • css/CSSGradientValue.h:

(CSSGradientValue):

  • css/CSSImageGeneratorValue.cpp:

(WebCore::CSSImageGeneratorValue::knownToBeOpaque):

  • css/CSSImageGeneratorValue.h:

(CSSImageGeneratorValue):

  • css/CSSImageValue.cpp:

(WebCore::CSSImageValue::knownToBeOpaque):

  • css/CSSImageValue.h:

(CSSImageValue):

  • loader/cache/CachedImage.cpp:

(WebCore::CachedImage::currentFrameKnownToBeOpaque):

  • loader/cache/CachedImage.h:

(CachedImage):

  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::currentFrameKnownToBeOpaque):

  • platform/graphics/BitmapImage.h:

(BitmapImage):

  • platform/graphics/GeneratedImage.h:

(GeneratedImage):

  • platform/graphics/Image.h:

Note: now a pure virtual function!

(Image):

  • platform/graphics/blackberry/LayerTiler.cpp:

(WebCore::LayerTiler::updateTextureContentsIfNeeded):

Removed unnecessary isBitmapImage() checks.

  • platform/graphics/cg/GraphicsContext3DCG.cpp:

(WebCore::GraphicsContext3D::ImageExtractor::extractImage):

Removed unnecessary isBitmapImage() checks.

  • platform/graphics/cg/PDFDocumentImage.h:

(PDFDocumentImage):

  • platform/graphics/chromium/GraphicsLayerChromium.cpp:

Removed unnecessary isBitmapImage() checks.

(WebCore::GraphicsLayerChromium::setContentsToImage):

  • platform/graphics/qt/StillImageQt.cpp:

(WebCore::StillImage::currentFrameKnownToBeOpaque):

  • platform/graphics/qt/StillImageQt.h:

(StillImage):

  • platform/graphics/skia/BitmapImageSingleFrameSkia.cpp:

(WebCore::BitmapImageSingleFrameSkia::currentFrameKnownToBeOpaque):

  • platform/graphics/skia/BitmapImageSingleFrameSkia.h:

(BitmapImageSingleFrameSkia):

  • platform/graphics/texmap/TextureMapperBackingStore.cpp:

(WebCore::TextureMapperTile::updateContents):
(WebCore::TextureMapperTiledBackingStore::updateContents):

  • platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:

(WebCore::CoordinatedImageBacking::update):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::backgroundIsObscured):

Removed unnecessary isBitmapImage() checks and slightly reworked the logic.

  • rendering/style/FillLayer.cpp:

(WebCore::FillLayer::hasOpaqueImage):

  • rendering/style/StyleCachedImage.cpp:

(WebCore::StyleCachedImage::knownToBeOpaque):

  • rendering/style/StyleCachedImage.h:

(StyleCachedImage):

  • rendering/style/StyleCachedImageSet.cpp:

(WebCore::StyleCachedImageSet::knownToBeOpaque):

  • rendering/style/StyleCachedImageSet.h:

(StyleCachedImageSet):

  • rendering/style/StyleGeneratedImage.cpp:

(WebCore::StyleGeneratedImage::knownToBeOpaque):

  • rendering/style/StyleGeneratedImage.h:

(StyleGeneratedImage):

  • rendering/style/StyleImage.h:

(StyleImage):

  • rendering/style/StylePendingImage.h:

(WebCore::StylePendingImage::knownToBeOpaque):

  • svg/graphics/SVGImage.h:

(SVGImage):

Source/WebKit/chromium:

  • tests/DragImageTest.cpp:

(WebCore::TestImage::currentFrameKnownToBeOpaque):
(TestImage):

  • tests/ImageLayerChromiumTest.cpp:

(WebCore::TestImage::currentFrameKnownToBeOpaque):

  • tests/PlatformContextSkiaTest.cpp:

(WebCore::TEST):

Source/WebKit/win:

  • WebKit.vcproj/WebKitExports.def.in:

LayoutTests:

An SVG image has been added to this test to check for regressions.

  • fast/box-shadow/image-box-shadow-expected.html:
  • fast/box-shadow/image-box-shadow.html:

Add an SVG image and correct a small mistake in the test that used values of 256
instead of 255.

  • fast/box-shadow/resources/green.svg: Added.
Location:
trunk
Files:
1 added
45 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141636 r141637  
     12013-02-01  Philip Rogers  <pdr@google.com>
     2
     3        Change hasAlpha to isKnownToBeOpaque and correct the return value for SVG images.
     4        https://bugs.webkit.org/show_bug.cgi?id=106966
     5
     6        Reviewed by Stephen White.
     7
     8        An SVG image has been added to this test to check for regressions.
     9
     10        * fast/box-shadow/image-box-shadow-expected.html:
     11        * fast/box-shadow/image-box-shadow.html:
     12
     13            Add an SVG image and correct a small mistake in the test that used values of 256
     14            instead of 255.
     15
     16        * fast/box-shadow/resources/green.svg: Added.
     17
    1182013-02-01  Philippe Normand  <pnormand@igalia.com>
    219
  • trunk/LayoutTests/fast/box-shadow/image-box-shadow-expected.html

    r121314 r141637  
    88div {
    99    display: inline-block;
    10     background: rgb(0,256,0);
     10    background: rgb(0,255,0);
    1111    height: 50px;
    1212}
     
    1515<div><img src="resources/green.png"></div>
    1616<div><img src="resources/green.jpg"></div>
     17<div><img src="resources/green.svg"></div>
  • trunk/LayoutTests/fast/box-shadow/image-box-shadow.html

    r121314 r141637  
    22<style>
    33img {
    4     background: rgb(0,256,0);
     4    background: rgb(0,255,0);
    55    width: 50px;
    66    height: 25px;
    77    margin-bottom: 25px;
    8     box-shadow: 0px 25px rgb(0,256,0);
     8    box-shadow: 0px 25px rgb(0,255,0);
    99}
    1010div {
     
    1717<div><img src="resources/green.png"></div>
    1818<div><img src="resources/green.jpg"></div>
     19<div><img src="resources/green.svg"></div>
  • trunk/Source/WebCore/ChangeLog

    r141635 r141637  
     12013-02-01  Philip Rogers  <pdr@google.com>
     2
     3        Change hasAlpha to isKnownToBeOpaque and correct the return value for SVG images.
     4        https://bugs.webkit.org/show_bug.cgi?id=106966
     5
     6        Reviewed by Stephen White.
     7
     8        Previously, Image::currentFrameHasAlpha's default implementation returned false so SVG
     9        images always returned false for currentFrameHasAlpha. Additionally, currentFrameHasAlpha
     10        was treated as returning whether the frame had alpha when it would actually conservatively
     11        return true.
     12
     13        This patch renames hasAlpha and currentFrameHasAlpha to isKnownToBeOpaque and
     14        currentFrameIsKnownToBeOpaque, respectively. This rename better describes the actual
     15        functionality. This patch also makes Image::isKnownToBeOpaque a pure virtual function and
     16        correctly implements it for SVG images.
     17
     18        All users of isKnownToBeOpaque access SVG images using CachedImage::imageForRenderer which
     19        currently returns a cached bitmap image. Therefore, this patch will not affect existing
     20        functionality. A regression test has been added that will catch if this changes in the
     21        future (e.g., WK106159 which proposes not returning cached bitmaps). The now unnecessary
     22        isBitmapImage() calls have been removed in this patch.
     23
     24        image-box-shadow.html has been modified to test SVG images.
     25
     26        * css/CSSCrossfadeValue.cpp:
     27        (WebCore::subimageKnownToBeOpaque):
     28        (WebCore::CSSCrossfadeValue::knownToBeOpaque):
     29
     30            Mostly straightforward rename but note the logic has been slightly altered: AND -> OR.
     31
     32        * css/CSSCrossfadeValue.h:
     33        (CSSCrossfadeValue):
     34        * css/CSSGradientValue.cpp:
     35        (WebCore::CSSGradientValue::knownToBeOpaque):
     36        * css/CSSGradientValue.h:
     37        (CSSGradientValue):
     38        * css/CSSImageGeneratorValue.cpp:
     39        (WebCore::CSSImageGeneratorValue::knownToBeOpaque):
     40        * css/CSSImageGeneratorValue.h:
     41        (CSSImageGeneratorValue):
     42        * css/CSSImageValue.cpp:
     43        (WebCore::CSSImageValue::knownToBeOpaque):
     44        * css/CSSImageValue.h:
     45        (CSSImageValue):
     46        * loader/cache/CachedImage.cpp:
     47        (WebCore::CachedImage::currentFrameKnownToBeOpaque):
     48        * loader/cache/CachedImage.h:
     49        (CachedImage):
     50        * platform/graphics/BitmapImage.cpp:
     51        (WebCore::BitmapImage::currentFrameKnownToBeOpaque):
     52        * platform/graphics/BitmapImage.h:
     53        (BitmapImage):
     54        * platform/graphics/GeneratedImage.h:
     55        (GeneratedImage):
     56        * platform/graphics/Image.h:
     57
     58            Note: now a pure virtual function!
     59
     60        (Image):
     61        * platform/graphics/blackberry/LayerTiler.cpp:
     62        (WebCore::LayerTiler::updateTextureContentsIfNeeded):
     63
     64            Removed unnecessary isBitmapImage() checks.
     65
     66        * platform/graphics/cg/GraphicsContext3DCG.cpp:
     67        (WebCore::GraphicsContext3D::ImageExtractor::extractImage):
     68
     69            Removed unnecessary isBitmapImage() checks.
     70
     71        * platform/graphics/cg/PDFDocumentImage.h:
     72        (PDFDocumentImage):
     73        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
     74
     75            Removed unnecessary isBitmapImage() checks.
     76
     77        (WebCore::GraphicsLayerChromium::setContentsToImage):
     78        * platform/graphics/qt/StillImageQt.cpp:
     79        (WebCore::StillImage::currentFrameKnownToBeOpaque):
     80        * platform/graphics/qt/StillImageQt.h:
     81        (StillImage):
     82        * platform/graphics/skia/BitmapImageSingleFrameSkia.cpp:
     83        (WebCore::BitmapImageSingleFrameSkia::currentFrameKnownToBeOpaque):
     84        * platform/graphics/skia/BitmapImageSingleFrameSkia.h:
     85        (BitmapImageSingleFrameSkia):
     86        * platform/graphics/texmap/TextureMapperBackingStore.cpp:
     87        (WebCore::TextureMapperTile::updateContents):
     88        (WebCore::TextureMapperTiledBackingStore::updateContents):
     89        * platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp:
     90        (WebCore::CoordinatedImageBacking::update):
     91        * rendering/RenderImage.cpp:
     92        (WebCore::RenderImage::backgroundIsObscured):
     93
     94            Removed unnecessary isBitmapImage() checks and slightly reworked the logic.
     95
     96        * rendering/style/FillLayer.cpp:
     97        (WebCore::FillLayer::hasOpaqueImage):
     98        * rendering/style/StyleCachedImage.cpp:
     99        (WebCore::StyleCachedImage::knownToBeOpaque):
     100        * rendering/style/StyleCachedImage.h:
     101        (StyleCachedImage):
     102        * rendering/style/StyleCachedImageSet.cpp:
     103        (WebCore::StyleCachedImageSet::knownToBeOpaque):
     104        * rendering/style/StyleCachedImageSet.h:
     105        (StyleCachedImageSet):
     106        * rendering/style/StyleGeneratedImage.cpp:
     107        (WebCore::StyleGeneratedImage::knownToBeOpaque):
     108        * rendering/style/StyleGeneratedImage.h:
     109        (StyleGeneratedImage):
     110        * rendering/style/StyleImage.h:
     111        (StyleImage):
     112        * rendering/style/StylePendingImage.h:
     113        (WebCore::StylePendingImage::knownToBeOpaque):
     114        * svg/graphics/SVGImage.h:
     115        (SVGImage):
     116
    11172013-02-01  Brady Eidson  <beidson@apple.com>
    2118
  • trunk/Source/WebCore/css/CSSCrossfadeValue.cpp

    r141570 r141637  
    5353}
    5454
    55 static bool subimageHasAlpha(CSSValue* value, const RenderObject* renderer)
     55static bool subimageKnownToBeOpaque(CSSValue* value, const RenderObject* renderer)
    5656{
    5757    if (value->isImageValue())
    58         return static_cast<CSSImageValue*>(value)->hasAlpha(renderer);
     58        return static_cast<CSSImageValue*>(value)->knownToBeOpaque(renderer);
    5959
    6060    if (value->isImageGeneratorValue())
    61         return static_cast<CSSImageGeneratorValue*>(value)->hasAlpha(renderer);
     61        return static_cast<CSSImageGeneratorValue*>(value)->knownToBeOpaque(renderer);
    6262
    6363    ASSERT_NOT_REACHED();
    6464
    65     return true;
     65    return false;
    6666}
    6767
     
    140140}
    141141
    142 bool CSSCrossfadeValue::hasAlpha(const RenderObject* renderer) const
    143 {
    144     return subimageHasAlpha(m_fromValue.get(), renderer) || subimageHasAlpha(m_toValue.get(), renderer);
     142bool CSSCrossfadeValue::knownToBeOpaque(const RenderObject* renderer) const
     143{
     144    return subimageKnownToBeOpaque(m_fromValue.get(), renderer) && subimageKnownToBeOpaque(m_toValue.get(), renderer);
    145145}
    146146
  • trunk/Source/WebCore/css/CSSCrossfadeValue.h

    r135629 r141637  
    5959
    6060    bool isPending() const;
    61     bool hasAlpha(const RenderObject*) const;
     61    bool knownToBeOpaque(const RenderObject*) const;
    6262
    6363    void loadSubimages(CachedResourceLoader*);
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r141570 r141637  
    463463}
    464464
    465 bool CSSGradientValue::hasAlpha(const RenderObject*) const
     465bool CSSGradientValue::knownToBeOpaque(const RenderObject*) const
    466466{
    467467    for (size_t i = 0; i < m_stops.size(); ++i) {
    468468        if (m_stops[i].m_resolvedColor.hasAlpha())
    469             return true;
    470     }
    471     return false;
     469            return false;
     470    }
     471    return true;
    472472}
    473473
  • trunk/Source/WebCore/css/CSSGradientValue.h

    r139836 r141637  
    8282
    8383    bool isPending() const { return false; }
    84     bool hasAlpha(const RenderObject*) const;
     84    bool knownToBeOpaque(const RenderObject*) const;
    8585
    8686    void loadSubimages(CachedResourceLoader*) { }
  • trunk/Source/WebCore/css/CSSImageGeneratorValue.cpp

    r141570 r141637  
    197197}
    198198
    199 bool CSSImageGeneratorValue::hasAlpha(const RenderObject* renderer) const
    200 {
    201     switch (classType()) {
    202     case CrossfadeClass:
    203         return static_cast<const CSSCrossfadeValue*>(this)->hasAlpha(renderer);
    204     case CanvasClass:
    205         return true;
    206     case LinearGradientClass:
    207         return static_cast<const CSSLinearGradientValue*>(this)->hasAlpha(renderer);
    208     case RadialGradientClass:
    209         return static_cast<const CSSRadialGradientValue*>(this)->hasAlpha(renderer);
    210     default:
    211         ASSERT_NOT_REACHED();
    212     }
    213     return true;
     199bool CSSImageGeneratorValue::knownToBeOpaque(const RenderObject* renderer) const
     200{
     201    switch (classType()) {
     202    case CrossfadeClass:
     203        return static_cast<const CSSCrossfadeValue*>(this)->knownToBeOpaque(renderer);
     204    case CanvasClass:
     205        return false;
     206    case LinearGradientClass:
     207        return static_cast<const CSSLinearGradientValue*>(this)->knownToBeOpaque(renderer);
     208    case RadialGradientClass:
     209        return static_cast<const CSSRadialGradientValue*>(this)->knownToBeOpaque(renderer);
     210    default:
     211        ASSERT_NOT_REACHED();
     212    }
     213    return false;
    214214}
    215215
  • trunk/Source/WebCore/css/CSSImageGeneratorValue.h

    r135629 r141637  
    6464
    6565    bool isPending() const;
    66     bool hasAlpha(const RenderObject*) const;
     66    bool knownToBeOpaque(const RenderObject*) const;
    6767
    6868    void loadSubimages(CachedResourceLoader*);
  • trunk/Source/WebCore/css/CSSImageValue.cpp

    r141570 r141637  
    114114}
    115115
    116 bool CSSImageValue::hasAlpha(const RenderObject* renderer) const
     116bool CSSImageValue::knownToBeOpaque(const RenderObject* renderer) const
    117117{
    118     return m_image ? m_image->hasAlpha(renderer) : true;
     118    return m_image ? m_image->knownToBeOpaque(renderer) : false;
    119119}
    120120
  • trunk/Source/WebCore/css/CSSImageValue.h

    r136919 r141637  
    5353    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    5454
    55     bool hasAlpha(const RenderObject*) const;
     55    bool knownToBeOpaque(const RenderObject*) const;
    5656
    5757    void setInitiator(const AtomicString& name) { m_initiatorName = name; }
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r141570 r141637  
    507507}
    508508
    509 bool CachedImage::currentFrameHasAlpha(const RenderObject* renderer)
     509bool CachedImage::currentFrameKnownToBeOpaque(const RenderObject* renderer)
    510510{
    511511    Image* image = imageForRenderer(renderer);
    512512    if (image->isBitmapImage())
    513513        image->nativeImageForCurrentFrame(); // force decode
    514     return image->currentFrameHasAlpha();
     514    return image->currentFrameKnownToBeOpaque();
    515515}
    516516
  • trunk/Source/WebCore/loader/cache/CachedImage.h

    r140722 r141637  
    5555    Image* imageForRenderer(const RenderObject*); // Returns the nullImage() if the image is not available yet.
    5656    bool hasImage() const { return m_image.get(); }
    57     bool currentFrameHasAlpha(const RenderObject*); // Side effect: ensures decoded image is in cache, therefore should only be called when about to draw the image.
     57    bool currentFrameKnownToBeOpaque(const RenderObject*); // Side effect: ensures decoded image is in cache, therefore should only be called when about to draw the image.
    5858
    5959    std::pair<Image*, float> brokenImage(float deviceScaleFactor) const; // Returns an image and the image's resolution scale factor.
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r141570 r141637  
    337337}
    338338
    339 bool BitmapImage::currentFrameHasAlpha()
    340 {
    341     return frameHasAlphaAtIndex(currentFrame());
     339bool BitmapImage::currentFrameKnownToBeOpaque()
     340{
     341    return !frameHasAlphaAtIndex(currentFrame());
    342342}
    343343
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r137011 r141637  
    179179
    180180    virtual NativeImagePtr nativeImageForCurrentFrame();
    181     virtual bool currentFrameHasAlpha();
     181    virtual bool currentFrameKnownToBeOpaque() OVERRIDE;
    182182
    183183    ImageOrientation currentFrameOrientation();
  • trunk/Source/WebCore/platform/graphics/GeneratedImage.h

    r137011 r141637  
    5858                             const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect) = 0;
    5959
     60    // FIXME: Implement this to be less conservative.
     61    virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
     62
    6063    GeneratedImage() { }
    6164
  • trunk/Source/WebCore/platform/graphics/Image.h

    r138326 r141637  
    100100    virtual bool isSVGImage() const { return false; }
    101101    virtual bool isBitmapImage() const { return false; }
    102     virtual bool currentFrameHasAlpha() { return false; }
     102    virtual bool currentFrameKnownToBeOpaque() = 0;
    103103
    104104    // Derived classes should override this if they can assure that
  • trunk/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp

    r130612 r141637  
    185185    if (!renderJobs.isEmpty()) {
    186186        if (Image* image = m_layer->contents()) {
    187             bool isOpaque = false;
    188             if (image->isBitmapImage())
    189                 isOpaque = !static_cast<BitmapImage*>(image)->currentFrameHasAlpha();
     187            bool isOpaque = image->currentFrameKnownToBeOpaque();
    190188            if (NativeImagePtr nativeImage = image->nativeImageForCurrentFrame()) {
    191189                SkBitmap bitmap = SkBitmap(nativeImage->bitmap());
     
    238236
    239237    if (Image* image = m_layer->contents()) {
    240         bool isOpaque = false;
    241         if (image->isBitmapImage())
    242             isOpaque = !static_cast<BitmapImage*>(image)->currentFrameHasAlpha();
     238        bool isOpaque = image->currentFrameKnownToBeOpaque();
    243239        // No point in tiling an image layer, the image is already stored as an SkBitmap
    244240        NativeImagePtr nativeImage = m_layer->contents()->nativeImageForCurrentFrame();
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp

    r141288 r141637  
    9898    if (!m_image)
    9999        return false;
    100     bool hasAlpha = m_image->isBitmapImage() ? m_image->currentFrameHasAlpha() : true;
     100    bool hasAlpha = !m_image->currentFrameKnownToBeOpaque();
    101101    if ((ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAlpha)) && m_image->data()) {
    102102        ImageSource decoder(ImageSource::AlphaNotPremultiplied,
  • trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h

    r137011 r141637  
    6565        PDFDocumentImage();
    6666        virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
    67        
     67
     68        // FIXME: Implement this to be less conservative.
     69        virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
     70
    6871        void setCurrentPage(int);
    6972        int pageCount() const;
  • trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp

    r141570 r141637  
    497497        }
    498498        m_imageLayer->setBitmap(nativeImage->bitmap());
    499         m_imageLayer->layer()->setOpaque(image->isBitmapImage() && !image->currentFrameHasAlpha());
     499        m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque());
    500500        updateContentsRect();
    501501    } else {
  • trunk/Source/WebCore/platform/graphics/qt/StillImageQt.cpp

    r137011 r141637  
    5353}
    5454
    55 bool StillImage::currentFrameHasAlpha()
     55bool StillImage::currentFrameKnownToBeOpaque()
    5656{
    57     return m_pixmap->hasAlpha();
     57    return !m_pixmap->hasAlpha();
    5858}
    5959
  • trunk/Source/WebCore/platform/graphics/qt/StillImageQt.h

    r137011 r141637  
    4545        }
    4646
    47         virtual bool currentFrameHasAlpha();
     47        virtual bool currentFrameKnownToBeOpaque();
    4848
    4949        // FIXME: StillImages are underreporting decoded sizes and will be unable
  • trunk/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.cpp

    r111572 r141637  
    1010}
    1111
    12 bool BitmapImageSingleFrameSkia::currentFrameHasAlpha()
     12bool BitmapImageSingleFrameSkia::currentFrameKnownToBeOpaque()
    1313{
    14     return !m_nativeImage.bitmap().isOpaque();
     14    return m_nativeImage.bitmap().isOpaque();
    1515}
    1616
  • trunk/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.h

    r137011 r141637  
    5454    virtual bool isBitmapImage() const;
    5555
    56     virtual bool currentFrameHasAlpha();
     56    virtual bool currentFrameKnownToBeOpaque() OVERRIDE;
    5757
    5858    virtual IntSize size() const;
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp

    r140821 r141637  
    7575    if (!m_texture) {
    7676        m_texture = textureMapper->createTexture();
    77         m_texture->reset(targetRect.size(), image->currentFrameHasAlpha() ? BitmapTexture::SupportsAlpha : 0);
     77        m_texture->reset(targetRect.size(), image->currentFrameKnownToBeOpaque() ? 0 : BitmapTexture::SupportsAlpha);
    7878    }
    7979
     
    226226void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
    227227{
    228     createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), image->currentFrameHasAlpha());
     228    createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), !image->currentFrameKnownToBeOpaque());
    229229    for (size_t i = 0; i < m_tiles.size(); ++i)
    230230        m_tiles[i].updateContents(textureMapper, image, dirtyRect, updateContentsFlag);
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp

    r141543 r141637  
    102102    }
    103103
    104     m_surface = CoordinatedSurface::create(m_image->size(), m_image->currentFrameHasAlpha() ? CoordinatedSurface::SupportsAlpha : CoordinatedSurface::NoFlags);
     104    m_surface = CoordinatedSurface::create(m_image->size(), !m_image->currentFrameKnownToBeOpaque() ? CoordinatedSurface::SupportsAlpha : CoordinatedSurface::NoFlags);
    105105    if (!m_surface) {
    106106        m_isDirty = false;
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r140244 r141637  
    500500        return false;
    501501
    502     // Check for bitmap image with alpha.
     502    // Check for image with alpha.
    503503    Image* image = m_imageResource->image().get();
    504     if (!image || !image->isBitmapImage() || image->currentFrameHasAlpha())
    505         return false;
    506        
    507     return true;
     504    if (!image)
     505        return false;
     506    return image->currentFrameKnownToBeOpaque();
    508507}
    509508
  • trunk/Source/WebCore/rendering/style/FillLayer.cpp

    r137166 r141637  
    336336
    337337    if (m_composite == CompositeSourceOver)
    338         return !m_image->hasAlpha(renderer);
     338        return m_image->knownToBeOpaque(renderer);
    339339
    340340    return false;
  • trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp

    r135629 r141637  
    107107}
    108108
    109 bool StyleCachedImage::hasAlpha(const RenderObject* renderer) const
     109bool StyleCachedImage::knownToBeOpaque(const RenderObject* renderer) const
    110110{
    111     return m_image->currentFrameHasAlpha(renderer);
     111    return m_image->currentFrameKnownToBeOpaque(renderer);
    112112}
    113113
  • trunk/Source/WebCore/rendering/style/StyleCachedImage.h

    r136919 r141637  
    5555    virtual void removeClient(RenderObject*);
    5656    virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const;
    57     virtual bool hasAlpha(const RenderObject*) const OVERRIDE;
     57    virtual bool knownToBeOpaque(const RenderObject*) const OVERRIDE;
    5858    virtual CachedImage* cachedImage() const OVERRIDE { return m_image.get(); }
    5959   
  • trunk/Source/WebCore/rendering/style/StyleCachedImageSet.cpp

    r135629 r141637  
    117117}
    118118
    119 bool StyleCachedImageSet::hasAlpha(const RenderObject* renderer) const
     119bool StyleCachedImageSet::knownToBeOpaque(const RenderObject* renderer) const
    120120{
    121     return m_bestFitImage->currentFrameHasAlpha(renderer);
     121    return m_bestFitImage->currentFrameKnownToBeOpaque(renderer);
    122122}
    123123
  • trunk/Source/WebCore/rendering/style/StyleCachedImageSet.h

    r136919 r141637  
    7272    virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const;
    7373    virtual float imageScaleFactor() const { return m_imageScaleFactor; }
    74     virtual bool hasAlpha(const RenderObject*) const OVERRIDE;
     74    virtual bool knownToBeOpaque(const RenderObject*) const OVERRIDE;
    7575    virtual CachedImage* cachedImage() const OVERRIDE { return m_bestFitImage.get(); }
    7676   
  • trunk/Source/WebCore/rendering/style/StyleGeneratedImage.cpp

    r135629 r141637  
    9090}
    9191
    92 bool StyleGeneratedImage::hasAlpha(const RenderObject* renderer) const
     92bool StyleGeneratedImage::knownToBeOpaque(const RenderObject* renderer) const
    9393{
    94     return m_imageGeneratorValue->hasAlpha(renderer);
     94    return m_imageGeneratorValue->knownToBeOpaque(renderer);
    9595}
    9696
  • trunk/Source/WebCore/rendering/style/StyleGeneratedImage.h

    r135629 r141637  
    5252    virtual void removeClient(RenderObject*);
    5353    virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const;
    54     virtual bool hasAlpha(const RenderObject*) const OVERRIDE;
     54    virtual bool knownToBeOpaque(const RenderObject*) const OVERRIDE;
    5555   
    5656private:
  • trunk/Source/WebCore/rendering/style/StyleImage.h

    r136919 r141637  
    6666    virtual WrappedImagePtr data() const = 0;
    6767    virtual float imageScaleFactor() const { return 1; }
    68     virtual bool hasAlpha(const RenderObject*) const = 0;
     68    virtual bool knownToBeOpaque(const RenderObject*) const = 0;
    6969    virtual CachedImage* cachedImage() const { return 0; }
    7070
  • trunk/Source/WebCore/rendering/style/StylePendingImage.h

    r136919 r141637  
    6969        return 0;
    7070    }
    71     virtual bool hasAlpha(const RenderObject*) const { return true; }
     71    virtual bool knownToBeOpaque(const RenderObject*) const { return false; }
    7272   
    7373private:
  • trunk/Source/WebCore/svg/graphics/SVGImage.h

    r141303 r141637  
    8383    virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
    8484
     85    // FIXME: Implement this to be less conservative.
     86    virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
     87
    8588    SVGImage(ImageObserver*);
    8689    virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
  • trunk/Source/WebKit/chromium/ChangeLog

    r141614 r141637  
     12013-02-01  Philip Rogers  <pdr@google.com>
     2
     3        Change hasAlpha to isKnownToBeOpaque and correct the return value for SVG images.
     4        https://bugs.webkit.org/show_bug.cgi?id=106966
     5
     6        Reviewed by Stephen White.
     7
     8        * tests/DragImageTest.cpp:
     9        (WebCore::TestImage::currentFrameKnownToBeOpaque):
     10        (TestImage):
     11        * tests/ImageLayerChromiumTest.cpp:
     12        (WebCore::TestImage::currentFrameKnownToBeOpaque):
     13        * tests/PlatformContextSkiaTest.cpp:
     14        (WebCore::TEST):
     15
    1162013-02-01  Nico Weber  <thakis@chromium.org>
    217
  • trunk/Source/WebKit/chromium/tests/DragImageTest.cpp

    r137011 r141637  
    8383    }
    8484
     85    virtual bool currentFrameKnownToBeOpaque()
     86    {
     87        return false;
     88    }
     89
    8590    virtual void draw(WebCore::GraphicsContext*, const WebCore::FloatRect&,
    8691                      const WebCore::FloatRect&, WebCore::ColorSpace,
  • trunk/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp

    r139829 r141637  
    6767    }
    6868
    69     virtual bool currentFrameHasAlpha()
     69    virtual bool currentFrameKnownToBeOpaque()
    7070    {
    71         return !m_nativeImage->bitmap().isOpaque();
     71        return m_nativeImage->bitmap().isOpaque();
    7272    }
    7373
  • trunk/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp

    r139745 r141637  
    551551            *drawBitmap.getAddr32(x, y) = 0xFFFFFFFF;
    552552    RefPtr<BitmapImageSingleFrameSkia> opaqueImage = BitmapImageSingleFrameSkia::create(drawBitmap, true);
    553     EXPECT_FALSE(opaqueImage->currentFrameHasAlpha());
     553    EXPECT_TRUE(opaqueImage->currentFrameKnownToBeOpaque());
    554554
    555555    drawBitmap.setIsOpaque(false);
     
    558558            *drawBitmap.getAddr32(x, y) = 0x00000000;
    559559    RefPtr<BitmapImageSingleFrameSkia> alphaImage = BitmapImageSingleFrameSkia::create(drawBitmap, true);
    560     EXPECT_TRUE(alphaImage->currentFrameHasAlpha());
     560    EXPECT_FALSE(alphaImage->currentFrameKnownToBeOpaque());
    561561
    562562    context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
  • trunk/Source/WebKit/win/ChangeLog

    r141545 r141637  
     12013-02-01  Philip Rogers  <pdr@google.com>
     2
     3        Change hasAlpha to isKnownToBeOpaque and correct the return value for SVG images.
     4        https://bugs.webkit.org/show_bug.cgi?id=106966
     5
     6        Reviewed by Stephen White.
     7
     8        * WebKit.vcproj/WebKitExports.def.in:
     9
    1102013-01-31  Aurimas Liutikas  <aurimas@chromium.org>
    211
  • trunk/Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in

    r141196 r141637  
    339339        ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
    340340        ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
    341         ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
     341        ?currentFrameKnownToBeOpaque@BitmapImage@WebCore@@UAE_NXZ
    342342        ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
    343343#if !ASSERT_DISABLED
     
    726726        ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
    727727        ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
    728         ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
     728        ?currentFrameKnownToBeOpaque@BitmapImage@WebCore@@UAE_NXZ
    729729        ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
    730730#if !ASSERT_DISABLED
     
    11121112        ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
    11131113        ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
    1114         ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
     1114        ?currentFrameKnownToBeOpaque@BitmapImage@WebCore@@UAE_NXZ
    11151115        ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
    11161116#if !ASSERT_DISABLED
     
    15041504        ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
    15051505        ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
    1506         ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
     1506        ?currentFrameKnownToBeOpaque@BitmapImage@WebCore@@UAE_NXZ
    15071507        ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
    15081508#if !ASSERT_DISABLED
Note: See TracChangeset for help on using the changeset viewer.