Adding occlusion detection to reduce overdraw in RenderBox background rendering
authorjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2012 18:43:51 +0000 (18:43 +0000)
committerjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2012 18:43:51 +0000 (18:43 +0000)
commitc560f8a0f319e51cc111a5f2838b22e8a08e8879
treef7188628a641a2a91f17c59f55dd45d3a1a22c77
parent9fd7de5d5af3cdeab6146ddec36e2aac2592e005
Adding occlusion detection to reduce overdraw in RenderBox background rendering
https://bugs.webkit.org/show_bug.cgi?id=102557

Reviewed by Stephen White.

Source/WebCore:

Adding hasAlpha method to all classes dervived from CSSImageValue and
StyleImage, in order to support occlusion testing.
This allows the FillLayer recursion to stop early when an opaque layer
is encountered while applying a CSS background style. This also allows
the elimination of background color application when the background is
completely covered by an image.  The optimization also skips the
clearing of the page's root element when the page background is
entirely covered by an image (e.g a tiled bitmap or a gradient)

Test: fast/backgrounds/background-opaque-images-over-color.html

* css/CSSCrossfadeValue.cpp:
(WebCore::subimageHasAlpha):
(WebCore):
(WebCore::CSSCrossfadeValue::isPending):
(WebCore::CSSCrossfadeValue::hasAlpha):
* css/CSSCrossfadeValue.h:
(CSSCrossfadeValue):
* css/CSSGradientValue.cpp:
(WebCore::CSSGradientValue::hasAlpha):
(WebCore):
* css/CSSGradientValue.h:
(CSSGradientValue):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::hasAlpha):
(WebCore):
* css/CSSImageGeneratorValue.h:
(CSSImageGeneratorValue):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::hasAlpha):
(WebCore):
* css/CSSImageValue.h:
(WebCore):
(CSSImageValue):
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::currentFrameHasAlpha):
Test whether a cached image has alpha, with side effect of ensuring
the image is in cache. (new method)
(WebCore):
* loader/cache/CachedImage.h:
(CachedImage):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintFillLayers):
Added layer recursion early exit when an opaque layer is encountered.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
Eliminated background color fill when the layer contains an opaque
image that covers the entire RenderBox.
* rendering/style/FillLayer.cpp:
(WebCore::FillLayer::hasOpaqueImage):
Returns true if the layer's image is known to be fully opaque.
(WebCore):
(WebCore::FillLayer::hasRepeatXY):
* rendering/style/FillLayer.h:
(FillLayer):
* rendering/style/StyleCachedImage.cpp:
(WebCore::StyleCachedImage::hasAlpha):
(WebCore):
* rendering/style/StyleCachedImage.h:
(StyleCachedImage):
* rendering/style/StyleCachedImageSet.cpp:
(WebCore::StyleCachedImageSet::hasAlpha):
(WebCore):
* rendering/style/StyleCachedImageSet.h:
(StyleCachedImageSet):
* rendering/style/StyleGeneratedImage.cpp:
(WebCore::StyleGeneratedImage::hasAlpha):
(WebCore):
* rendering/style/StyleGeneratedImage.h:
(StyleGeneratedImage):
* rendering/style/StyleImage.h:
(StyleImage):
* rendering/style/StylePendingImage.h:
(WebCore::StylePendingImage::hasAlpha):

LayoutTests:

New test exercises different CSS background style use cases that
are candidates for optimization by occlusion culling.

* fast/backgrounds/background-opaque-images-over-color-expected.txt: Added.
* fast/backgrounds/background-opaque-images-over-color.html: Added.
* platform/chromium/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135629 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/backgrounds/background-opaque-images-over-color-expected.txt [new file with mode: 0644]
LayoutTests/fast/backgrounds/background-opaque-images-over-color.html [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/mac/TestExpectations
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/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/style/FillLayer.cpp
Source/WebCore/rendering/style/FillLayer.h
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