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)
commitf2ce7fdc22e09d110b78b89e26b4ab9c513a457d
tree1b7d461667208ef85afc8802b97aadc48f11f437
parentd945959d7784a3a4f3c7a1fbfc01f368c8a4a04a
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.

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