Change hasAlpha to isKnownToBeOpaque and correct the return value for SVG images.
authorpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Feb 2013 21:31:00 +0000 (21:31 +0000)
committerpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Feb 2013 21:31:00 +0000 (21:31 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141637 268f45cc-cd09-0410-ab3c-d52691b4dbfc

46 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/box-shadow/image-box-shadow-expected.html
LayoutTests/fast/box-shadow/image-box-shadow.html
LayoutTests/fast/box-shadow/resources/green.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSCrossfadeValue.cpp
Source/WebCore/css/CSSCrossfadeValue.h
Source/WebCore/css/CSSGradientValue.cpp
Source/WebCore/css/CSSGradientValue.h
Source/WebCore/css/CSSImageGeneratorValue.cpp
Source/WebCore/css/CSSImageGeneratorValue.h
Source/WebCore/css/CSSImageValue.cpp
Source/WebCore/css/CSSImageValue.h
Source/WebCore/loader/cache/CachedImage.cpp
Source/WebCore/loader/cache/CachedImage.h
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/GeneratedImage.h
Source/WebCore/platform/graphics/Image.h
Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp
Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp
Source/WebCore/platform/graphics/cg/PDFDocumentImage.h
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
Source/WebCore/platform/graphics/qt/StillImageQt.cpp
Source/WebCore/platform/graphics/qt/StillImageQt.h
Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.cpp
Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.h
Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/style/FillLayer.cpp
Source/WebCore/rendering/style/StyleCachedImage.cpp
Source/WebCore/rendering/style/StyleCachedImage.h
Source/WebCore/rendering/style/StyleCachedImageSet.cpp
Source/WebCore/rendering/style/StyleCachedImageSet.h
Source/WebCore/rendering/style/StyleGeneratedImage.cpp
Source/WebCore/rendering/style/StyleGeneratedImage.h
Source/WebCore/rendering/style/StyleImage.h
Source/WebCore/rendering/style/StylePendingImage.h
Source/WebCore/svg/graphics/SVGImage.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/DragImageTest.cpp
Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp
Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebKit.vcproj/WebKitExports.def.in

index 369f0db..b9cfbab 100644 (file)
@@ -1,3 +1,20 @@
+2013-02-01  Philip Rogers  <pdr@google.com>
+
+        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.
+
+        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.
+
 2013-02-01  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, GTK TestExpectations update.
index d4302ed..2a90c08 100644 (file)
@@ -7,10 +7,11 @@ img {
 }
 div {
     display: inline-block;
-    background: rgb(0,256,0);
+    background: rgb(0,255,0);
     height: 50px;
 }
 </style>
 <div><img src="resources/green-alpha.png"></div>
 <div><img src="resources/green.png"></div>
 <div><img src="resources/green.jpg"></div>
+<div><img src="resources/green.svg"></div>
index 4139311..8e8114c 100644 (file)
@@ -1,11 +1,11 @@
 <!DOCTYPE html>
 <style>
 img {
-    background: rgb(0,256,0);
+    background: rgb(0,255,0);
     width: 50px;
     height: 25px;
     margin-bottom: 25px;
-    box-shadow: 0px 25px rgb(0,256,0); 
+    box-shadow: 0px 25px rgb(0,255,0); 
 }
 div {
     display: inline-block;
@@ -16,3 +16,4 @@ div {
 <div><img src="resources/green-alpha.png"></div>
 <div><img src="resources/green.png"></div>
 <div><img src="resources/green.jpg"></div>
+<div><img src="resources/green.svg"></div>
diff --git a/LayoutTests/fast/box-shadow/resources/green.svg b/LayoutTests/fast/box-shadow/resources/green.svg
new file mode 100644 (file)
index 0000000..c1461e9
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="50" height="25">
+  <rect x="0" y="0" width="100" height="100" fill="rgba(0,255,0,0.5)" />
+</svg>
index 1e06458..7bdd395 100644 (file)
@@ -1,3 +1,119 @@
+2013-02-01  Philip Rogers  <pdr@google.com>
+
+        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.
+
+        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):
+
 2013-02-01  Brady Eidson  <beidson@apple.com>
 
         Clean up WebArchive loading with the NetworkProcess
index 8ee0250..10c96a7 100644 (file)
@@ -52,17 +52,17 @@ static bool subimageIsPending(CSSValue* value)
     return false;
 }
 
-static bool subimageHasAlpha(CSSValue* value, const RenderObject* renderer)
+static bool subimageKnownToBeOpaque(CSSValue* value, const RenderObject* renderer)
 {
     if (value->isImageValue())
-        return static_cast<CSSImageValue*>(value)->hasAlpha(renderer);
+        return static_cast<CSSImageValue*>(value)->knownToBeOpaque(renderer);
 
     if (value->isImageGeneratorValue())
-        return static_cast<CSSImageGeneratorValue*>(value)->hasAlpha(renderer);
+        return static_cast<CSSImageGeneratorValue*>(value)->knownToBeOpaque(renderer);
 
     ASSERT_NOT_REACHED();
 
-    return true;
+    return false;
 }
 
 static CachedImage* cachedImageForCSSValue(CSSValue* value, CachedResourceLoader* cachedResourceLoader)
@@ -139,9 +139,9 @@ bool CSSCrossfadeValue::isPending() const
     return subimageIsPending(m_fromValue.get()) || subimageIsPending(m_toValue.get());
 }
 
-bool CSSCrossfadeValue::hasAlpha(const RenderObject* renderer) const
+bool CSSCrossfadeValue::knownToBeOpaque(const RenderObject* renderer) const
 {
-    return subimageHasAlpha(m_fromValue.get(), renderer) || subimageHasAlpha(m_toValue.get(), renderer);
+    return subimageKnownToBeOpaque(m_fromValue.get(), renderer) && subimageKnownToBeOpaque(m_toValue.get(), renderer);
 }
 
 void CSSCrossfadeValue::loadSubimages(CachedResourceLoader* cachedResourceLoader)
index 80d26d1..c074780 100644 (file)
@@ -58,7 +58,7 @@ public:
     IntSize fixedSize(const RenderObject*);
 
     bool isPending() const;
-    bool hasAlpha(const RenderObject*) const;
+    bool knownToBeOpaque(const RenderObject*) const;
 
     void loadSubimages(CachedResourceLoader*);
 
index 2fe9b8a..dcde178 100644 (file)
@@ -462,13 +462,13 @@ bool CSSGradientValue::isCacheable() const
     return true;
 }
 
-bool CSSGradientValue::hasAlpha(const RenderObject*) const
+bool CSSGradientValue::knownToBeOpaque(const RenderObject*) const
 {
     for (size_t i = 0; i < m_stops.size(); ++i) {
         if (m_stops[i].m_resolvedColor.hasAlpha())
-            return true;
+            return false;
     }
-    return false;
+    return true;
 }
 
 void CSSGradientValue::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
index 6f00535..7a19075 100644 (file)
@@ -81,7 +81,7 @@ public:
     IntSize fixedSize(const RenderObject*) const { return IntSize(); }
 
     bool isPending() const { return false; }
-    bool hasAlpha(const RenderObject*) const;
+    bool knownToBeOpaque(const RenderObject*) const;
 
     void loadSubimages(CachedResourceLoader*) { }
     PassRefPtr<CSSGradientValue> gradientWithStylesResolved(StyleResolver*);
index 999dbf1..1f3f9f5 100644 (file)
@@ -196,21 +196,21 @@ bool CSSImageGeneratorValue::isPending() const
     return false;
 }
 
-bool CSSImageGeneratorValue::hasAlpha(const RenderObject* renderer) const
+bool CSSImageGeneratorValue::knownToBeOpaque(const RenderObject* renderer) const
 {
     switch (classType()) {
     case CrossfadeClass:
-        return static_cast<const CSSCrossfadeValue*>(this)->hasAlpha(renderer);
+        return static_cast<const CSSCrossfadeValue*>(this)->knownToBeOpaque(renderer);
     case CanvasClass:
-        return true;
+        return false;
     case LinearGradientClass:
-        return static_cast<const CSSLinearGradientValue*>(this)->hasAlpha(renderer);
+        return static_cast<const CSSLinearGradientValue*>(this)->knownToBeOpaque(renderer);
     case RadialGradientClass:
-        return static_cast<const CSSRadialGradientValue*>(this)->hasAlpha(renderer);
+        return static_cast<const CSSRadialGradientValue*>(this)->knownToBeOpaque(renderer);
     default:
         ASSERT_NOT_REACHED();
     }
-    return true;
+    return false;
 }
 
 void CSSImageGeneratorValue::loadSubimages(CachedResourceLoader* cachedResourceLoader)
index f02292a..8b77579 100644 (file)
@@ -63,7 +63,7 @@ public:
     IntSize fixedSize(const RenderObject*);
 
     bool isPending() const;
-    bool hasAlpha(const RenderObject*) const;
+    bool knownToBeOpaque(const RenderObject*) const;
 
     void loadSubimages(CachedResourceLoader*);
 
index 6742798..8902efb 100644 (file)
@@ -113,9 +113,9 @@ void CSSImageValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectIn
     // No need to report m_image as it is counted as part of RenderArena.
 }
 
-bool CSSImageValue::hasAlpha(const RenderObject* renderer) const
+bool CSSImageValue::knownToBeOpaque(const RenderObject* renderer) const
 {
-    return m_image ? m_image->hasAlpha(renderer) : true;
+    return m_image ? m_image->knownToBeOpaque(renderer) : false;
 }
 
 } // namespace WebCore
index e219642..8e4a169 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
 
-    bool hasAlpha(const RenderObject*) const;
+    bool knownToBeOpaque(const RenderObject*) const;
 
     void setInitiator(const AtomicString& name) { m_initiatorName = name; }
 
index 0ee16e6..e0bc36a 100644 (file)
@@ -506,12 +506,12 @@ void CachedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 #endif
 }
 
-bool CachedImage::currentFrameHasAlpha(const RenderObject* renderer)
+bool CachedImage::currentFrameKnownToBeOpaque(const RenderObject* renderer)
 {
     Image* image = imageForRenderer(renderer);
     if (image->isBitmapImage())
         image->nativeImageForCurrentFrame(); // force decode
-    return image->currentFrameHasAlpha();
+    return image->currentFrameKnownToBeOpaque();
 }
 
 } // namespace WebCore
index 8ae2a49..5c08f18 100644 (file)
@@ -54,7 +54,7 @@ public:
     Image* image(); // Returns the nullImage() if the image is not available yet.
     Image* imageForRenderer(const RenderObject*); // Returns the nullImage() if the image is not available yet.
     bool hasImage() const { return m_image.get(); }
-    bool currentFrameHasAlpha(const RenderObject*); // Side effect: ensures decoded image is in cache, therefore should only be called when about to draw the image.
+    bool currentFrameKnownToBeOpaque(const RenderObject*); // Side effect: ensures decoded image is in cache, therefore should only be called when about to draw the image.
 
     std::pair<Image*, float> brokenImage(float deviceScaleFactor) const; // Returns an image and the image's resolution scale factor.
     bool willPaintBrokenImage() const; 
index 27e730d..c28197d 100644 (file)
@@ -336,9 +336,9 @@ bool BitmapImage::frameHasAlphaAtIndex(size_t index)
     return m_source.frameHasAlphaAtIndex(index);
 }
 
-bool BitmapImage::currentFrameHasAlpha()
+bool BitmapImage::currentFrameKnownToBeOpaque()
 {
-    return frameHasAlphaAtIndex(currentFrame());
+    return !frameHasAlphaAtIndex(currentFrame());
 }
 
 ImageOrientation BitmapImage::currentFrameOrientation()
index 4b11b52..664ee2a 100644 (file)
@@ -178,7 +178,7 @@ public:
 #endif
 
     virtual NativeImagePtr nativeImageForCurrentFrame();
-    virtual bool currentFrameHasAlpha();
+    virtual bool currentFrameKnownToBeOpaque() OVERRIDE;
 
     ImageOrientation currentFrameOrientation();
 
index 7e8bd3f..e134608 100644 (file)
@@ -57,6 +57,9 @@ protected:
     virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
                              const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect) = 0;
 
+    // FIXME: Implement this to be less conservative.
+    virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
+
     GeneratedImage() { }
 
     IntSize m_size;
index 41a3146..40eca93 100644 (file)
@@ -99,7 +99,7 @@ public:
 
     virtual bool isSVGImage() const { return false; }
     virtual bool isBitmapImage() const { return false; }
-    virtual bool currentFrameHasAlpha() { return false; }
+    virtual bool currentFrameKnownToBeOpaque() = 0;
 
     // Derived classes should override this if they can assure that 
     // the image contains only resources from its own security origin.
index cd2801e..2bd9773 100644 (file)
@@ -184,9 +184,7 @@ void LayerTiler::updateTextureContentsIfNeeded(double scale)
     HashSet<TileIndex> finishedJobs;
     if (!renderJobs.isEmpty()) {
         if (Image* image = m_layer->contents()) {
-            bool isOpaque = false;
-            if (image->isBitmapImage())
-                isOpaque = !static_cast<BitmapImage*>(image)->currentFrameHasAlpha();
+            bool isOpaque = image->currentFrameKnownToBeOpaque();
             if (NativeImagePtr nativeImage = image->nativeImageForCurrentFrame()) {
                 SkBitmap bitmap = SkBitmap(nativeImage->bitmap());
                 addTextureJob(TextureJob::setContents(bitmap, isOpaque));
@@ -237,9 +235,7 @@ void LayerTiler::updateTextureContentsIfNeeded(double scale)
         return;
 
     if (Image* image = m_layer->contents()) {
-        bool isOpaque = false;
-        if (image->isBitmapImage())
-            isOpaque = !static_cast<BitmapImage*>(image)->currentFrameHasAlpha();
+        bool isOpaque = image->currentFrameKnownToBeOpaque();
         // No point in tiling an image layer, the image is already stored as an SkBitmap
         NativeImagePtr nativeImage = m_layer->contents()->nativeImageForCurrentFrame();
         if (nativeImage) {
index ecf0cee..f6eb973 100644 (file)
@@ -97,7 +97,7 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
 {
     if (!m_image)
         return false;
-    bool hasAlpha = m_image->isBitmapImage() ? m_image->currentFrameHasAlpha() : true;
+    bool hasAlpha = !m_image->currentFrameKnownToBeOpaque();
     if ((ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAlpha)) && m_image->data()) {
         ImageSource decoder(ImageSource::AlphaNotPremultiplied,
                             ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied);
index 62f6554..689a031 100644 (file)
@@ -64,7 +64,10 @@ namespace WebCore {
 
         PDFDocumentImage();
         virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
-        
+
+        // FIXME: Implement this to be less conservative.
+        virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
+
         void setCurrentPage(int);
         int pageCount() const;
         void adjustCTM(GraphicsContext*) const;
index 9fe810c..f592c85 100644 (file)
@@ -496,7 +496,7 @@ void GraphicsLayerChromium::setContentsToImage(Image* image)
             childrenChanged = true;
         }
         m_imageLayer->setBitmap(nativeImage->bitmap());
-        m_imageLayer->layer()->setOpaque(image->isBitmapImage() && !image->currentFrameHasAlpha());
+        m_imageLayer->layer()->setOpaque(image->currentFrameKnownToBeOpaque());
         updateContentsRect();
     } else {
         if (m_imageLayer) {
index 38092bf..0f407c1 100644 (file)
@@ -52,9 +52,9 @@ StillImage::~StillImage()
         delete m_pixmap;
 }
 
-bool StillImage::currentFrameHasAlpha()
+bool StillImage::currentFrameKnownToBeOpaque()
 {
-    return m_pixmap->hasAlpha();
+    return !m_pixmap->hasAlpha();
 }
 
 IntSize StillImage::size() const
index f94c6a1..505b190 100644 (file)
@@ -44,7 +44,7 @@ namespace WebCore {
             return adoptRef(new StillImage(pixmap));
         }
 
-        virtual bool currentFrameHasAlpha();
+        virtual bool currentFrameKnownToBeOpaque();
 
         // FIXME: StillImages are underreporting decoded sizes and will be unable
         // to prune because these functions are not implemented yet.
index 28ead8f..fb66155 100644 (file)
@@ -9,9 +9,9 @@ bool BitmapImageSingleFrameSkia::isBitmapImage() const
     return true;
 }
 
-bool BitmapImageSingleFrameSkia::currentFrameHasAlpha()
+bool BitmapImageSingleFrameSkia::currentFrameKnownToBeOpaque()
 {
-    return !m_nativeImage.bitmap().isOpaque();
+    return m_nativeImage.bitmap().isOpaque();
 }
 
 IntSize BitmapImageSingleFrameSkia::size() const
index 51b7c27..56ebe3a 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     virtual bool isBitmapImage() const;
 
-    virtual bool currentFrameHasAlpha();
+    virtual bool currentFrameKnownToBeOpaque() OVERRIDE;
 
     virtual IntSize size() const;
 
index 3106df2..6ec5565 100644 (file)
@@ -74,7 +74,7 @@ void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* imag
     targetRect.move(-m_rect.x(), -m_rect.y());
     if (!m_texture) {
         m_texture = textureMapper->createTexture();
-        m_texture->reset(targetRect.size(), image->currentFrameHasAlpha() ? BitmapTexture::SupportsAlpha : 0);
+        m_texture->reset(targetRect.size(), image->currentFrameKnownToBeOpaque() ? 0 : BitmapTexture::SupportsAlpha);
     }
 
     m_texture->updateContents(image, targetRect, sourceOffset, updateContentsFlag);
@@ -225,7 +225,7 @@ void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatSiz
 
 void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
 {
-    createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), image->currentFrameHasAlpha());
+    createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), !image->currentFrameKnownToBeOpaque());
     for (size_t i = 0; i < m_tiles.size(); ++i)
         m_tiles[i].updateContents(textureMapper, image, dirtyRect, updateContentsFlag);
 }
index f692482..128babe 100644 (file)
@@ -101,7 +101,7 @@ void CoordinatedImageBacking::update()
         }
     }
 
-    m_surface = CoordinatedSurface::create(m_image->size(), m_image->currentFrameHasAlpha() ? CoordinatedSurface::SupportsAlpha : CoordinatedSurface::NoFlags);
+    m_surface = CoordinatedSurface::create(m_image->size(), !m_image->currentFrameKnownToBeOpaque() ? CoordinatedSurface::SupportsAlpha : CoordinatedSurface::NoFlags);
     if (!m_surface) {
         m_isDirty = false;
         return;
index fd4c34f..cab3e44 100644 (file)
@@ -499,12 +499,11 @@ bool RenderImage::backgroundIsObscured() const
     if ((backgroundClip == BorderFillBox || backgroundClip == PaddingFillBox) && style()->hasPadding())
         return false;
 
-    // Check for bitmap image with alpha.
+    // Check for image with alpha.
     Image* image = m_imageResource->image().get();
-    if (!image || !image->isBitmapImage() || image->currentFrameHasAlpha())
+    if (!image)
         return false;
-        
-    return true;
+    return image->currentFrameKnownToBeOpaque();
 }
 
 LayoutUnit RenderImage::minimumReplacedHeight() const
index 880bb34..035f48e 100644 (file)
@@ -335,7 +335,7 @@ bool FillLayer::hasOpaqueImage(const RenderObject* renderer) const
         return true;
 
     if (m_composite == CompositeSourceOver)
-        return !m_image->hasAlpha(renderer);
+        return m_image->knownToBeOpaque(renderer);
 
     return false;
 }
index 4269edd..6a71286 100644 (file)
@@ -106,9 +106,9 @@ PassRefPtr<Image> StyleCachedImage::image(RenderObject* renderer, const IntSize&
     return m_image->imageForRenderer(renderer);
 }
 
-bool StyleCachedImage::hasAlpha(const RenderObject* renderer) const
+bool StyleCachedImage::knownToBeOpaque(const RenderObject* renderer) const
 {
-    return m_image->currentFrameHasAlpha(renderer);
+    return m_image->currentFrameKnownToBeOpaque(renderer);
 }
 
 }
index 7fdfca0..b81b43a 100644 (file)
@@ -54,7 +54,7 @@ public:
     virtual void addClient(RenderObject*);
     virtual void removeClient(RenderObject*);
     virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const;
-    virtual bool hasAlpha(const RenderObject*) const OVERRIDE;
+    virtual bool knownToBeOpaque(const RenderObject*) const OVERRIDE;
     virtual CachedImage* cachedImage() const OVERRIDE { return m_image.get(); }
     
 private:
index c9f1382..f4f2f8b 100644 (file)
@@ -116,9 +116,9 @@ PassRefPtr<Image> StyleCachedImageSet::image(RenderObject* renderer, const IntSi
     return m_bestFitImage->imageForRenderer(renderer);
 }
 
-bool StyleCachedImageSet::hasAlpha(const RenderObject* renderer) const
+bool StyleCachedImageSet::knownToBeOpaque(const RenderObject* renderer) const
 {
-    return m_bestFitImage->currentFrameHasAlpha(renderer);
+    return m_bestFitImage->currentFrameKnownToBeOpaque(renderer);
 }
 
 } // namespace WebCore
index d113837..21b0e0c 100644 (file)
@@ -71,7 +71,7 @@ public:
     virtual void removeClient(RenderObject*);
     virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const;
     virtual float imageScaleFactor() const { return m_imageScaleFactor; }
-    virtual bool hasAlpha(const RenderObject*) const OVERRIDE;
+    virtual bool knownToBeOpaque(const RenderObject*) const OVERRIDE;
     virtual CachedImage* cachedImage() const OVERRIDE { return m_bestFitImage.get(); }
     
 private:
index 09781a6..c4c2f3b 100644 (file)
@@ -89,9 +89,9 @@ PassRefPtr<Image> StyleGeneratedImage::image(RenderObject* renderer, const IntSi
     return m_imageGeneratorValue->image(renderer, size);
 }
 
-bool StyleGeneratedImage::hasAlpha(const RenderObject* renderer) const
+bool StyleGeneratedImage::knownToBeOpaque(const RenderObject* renderer) const
 {
-    return m_imageGeneratorValue->hasAlpha(renderer);
+    return m_imageGeneratorValue->knownToBeOpaque(renderer);
 }
 
 }
index 7ab70f2..57f78dd 100644 (file)
@@ -51,7 +51,7 @@ public:
     virtual void addClient(RenderObject*);
     virtual void removeClient(RenderObject*);
     virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const;
-    virtual bool hasAlpha(const RenderObject*) const OVERRIDE;
+    virtual bool knownToBeOpaque(const RenderObject*) const OVERRIDE;
     
 private:
     StyleGeneratedImage(PassRefPtr<CSSImageGeneratorValue>);
index 7b1b668..70f3360 100644 (file)
@@ -65,7 +65,7 @@ public:
     virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const = 0;
     virtual WrappedImagePtr data() const = 0;
     virtual float imageScaleFactor() const { return 1; }
-    virtual bool hasAlpha(const RenderObject*) const = 0;
+    virtual bool knownToBeOpaque(const RenderObject*) const = 0;
     virtual CachedImage* cachedImage() const { return 0; }
 
     ALWAYS_INLINE bool isCachedImage() const { return m_isCachedImage; }
index 4cea0f9..b689ee7 100644 (file)
@@ -68,7 +68,7 @@ public:
         ASSERT_NOT_REACHED();
         return 0;
     }
-    virtual bool hasAlpha(const RenderObject*) const { return true; }
+    virtual bool knownToBeOpaque(const RenderObject*) const { return false; }
     
 private:
     StylePendingImage(CSSValue* value)
index b400f1f..ad202b7 100644 (file)
@@ -82,6 +82,9 @@ private:
 
     virtual NativeImagePtr frameAtIndex(size_t) { return 0; }
 
+    // FIXME: Implement this to be less conservative.
+    virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
+
     SVGImage(ImageObserver*);
     virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
 
index 9415880..ac89330 100644 (file)
@@ -1,3 +1,18 @@
+2013-02-01  Philip Rogers  <pdr@google.com>
+
+        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.
+
+        * tests/DragImageTest.cpp:
+        (WebCore::TestImage::currentFrameKnownToBeOpaque):
+        (TestImage):
+        * tests/ImageLayerChromiumTest.cpp:
+        (WebCore::TestImage::currentFrameKnownToBeOpaque):
+        * tests/PlatformContextSkiaTest.cpp:
+        (WebCore::TEST):
+
 2013-02-01  Nico Weber  <thakis@chromium.org>
 
         [chromium] Build webkit with enable_web_intents set to 0.
index 3a7d9dd..a9465e6 100644 (file)
@@ -82,6 +82,11 @@ public:
         return 0u;
     }
 
+    virtual bool currentFrameKnownToBeOpaque()
+    {
+        return false;
+    }
+
     virtual void draw(WebCore::GraphicsContext*, const WebCore::FloatRect&,
                       const WebCore::FloatRect&, WebCore::ColorSpace,
                       WebCore::CompositeOperator, WebCore::BlendMode)
index c87b7ac..b9c2810 100644 (file)
@@ -66,9 +66,9 @@ public:
         return true;
     }
 
-    virtual bool currentFrameHasAlpha()
+    virtual bool currentFrameKnownToBeOpaque()
     {
-        return !m_nativeImage->bitmap().isOpaque();
+        return m_nativeImage->bitmap().isOpaque();
     }
 
     virtual IntSize size() const
index dd320d3..a9c4360 100644 (file)
@@ -550,14 +550,14 @@ TEST(PlatformContextSkiaTest, trackOpaqueImageTest)
         for (int x = 0; x < drawBitmap.width(); ++x)
             *drawBitmap.getAddr32(x, y) = 0xFFFFFFFF;
     RefPtr<BitmapImageSingleFrameSkia> opaqueImage = BitmapImageSingleFrameSkia::create(drawBitmap, true);
-    EXPECT_FALSE(opaqueImage->currentFrameHasAlpha());
+    EXPECT_TRUE(opaqueImage->currentFrameKnownToBeOpaque());
 
     drawBitmap.setIsOpaque(false);
     for (int y = 0; y < drawBitmap.height(); ++y)
         for (int x = 0; x < drawBitmap.width(); ++x)
             *drawBitmap.getAddr32(x, y) = 0x00000000;
     RefPtr<BitmapImageSingleFrameSkia> alphaImage = BitmapImageSingleFrameSkia::create(drawBitmap, true);
-    EXPECT_TRUE(alphaImage->currentFrameHasAlpha());
+    EXPECT_FALSE(alphaImage->currentFrameKnownToBeOpaque());
 
     context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver);
     EXPECT_EQ_RECT(IntRect(10, 10, 90, 90), platformContext.opaqueRegion().asRect());
index 8e93ad0..b593bd1 100644 (file)
@@ -1,3 +1,12 @@
+2013-02-01  Philip Rogers  <pdr@google.com>
+
+        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.
+
+        * WebKit.vcproj/WebKitExports.def.in:
+
 2013-01-31  Aurimas Liutikas  <aurimas@chromium.org>
 
         Editor::m_compositionNode not updated on HTMLInputElement::setValue()
index ea3435f..55d61b3 100644 (file)
@@ -338,7 +338,7 @@ EXPORTS
         ??1BitmapImage@WebCore@@UAE@XZ
         ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
         ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
-        ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
+        ?currentFrameKnownToBeOpaque@BitmapImage@WebCore@@UAE_NXZ
         ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
 #if !ASSERT_DISABLED
         ?notSolidColor@BitmapImage@WebCore@@UAE_NXZ 
@@ -725,7 +725,7 @@ EXPORTS
         ??1BitmapImage@WebCore@@UAE@XZ
         ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
         ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
-        ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
+        ?currentFrameKnownToBeOpaque@BitmapImage@WebCore@@UAE_NXZ
         ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
 #if !ASSERT_DISABLED
         ?notSolidColor@BitmapImage@WebCore@@UAE_NXZ 
@@ -1111,7 +1111,7 @@ EXPORTS
         ??1BitmapImage@WebCore@@UAE@XZ
         ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
         ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
-        ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
+        ?currentFrameKnownToBeOpaque@BitmapImage@WebCore@@UAE_NXZ
         ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
 #if !ASSERT_DISABLED
         ?notSolidColor@BitmapImage@WebCore@@UAE_NXZ 
@@ -1503,7 +1503,7 @@ EXPORTS
         ??1BitmapImage@WebCore@@UAE@XZ
         ??0BitmapImage@WebCore@@IAE@PAVImageObserver@1@@Z
         ?isBitmapImage@BitmapImage@WebCore@@UBE_NXZ
-        ?currentFrameHasAlpha@BitmapImage@WebCore@@UAE_NXZ
+        ?currentFrameKnownToBeOpaque@BitmapImage@WebCore@@UAE_NXZ
         ?hasSingleSecurityOrigin@BitmapImage@WebCore@@UBE_NXZ
 #if !ASSERT_DISABLED
         ?notSolidColor@BitmapImage@WebCore@@UAE_NXZ