- Revision
- 135212
- Author
- [email protected]
- Date
- 2012-11-19 16:38:01 -0800 (Mon, 19 Nov 2012)
Log Message
Coordinated Graphics: Remove tiles of a layer when they are off the viewport.
https://bugs.webkit.org/show_bug.cgi?id=102313
Patch by Huang Dongsung <[email protected]> on 2012-11-19
Reviewed by Noam Rosenthal.
Source/WebKit2:
Currently, we don't remove tiles of the layer with the special properties: a
transform animation and non affine transform. If a page has a lot of layers with
a transform animation, we will encounter OOM. So this patch removes the
privilege of the layer.
There are two changes.
1. computeTransformedVisibleRect() calculates a layer transform using the
current local transform which a transform animation applied.
2. tiledBackingStoreVisibleRect() calculates a visible
rect of all layers, even if the layer includes the property: a transform
animation or non affine transform.
Test: animations/animation-offscreen-to-onscreen.html
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::effectiveContentsScale):
(WebCore::CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect):
(WebCore::CoordinatedGraphicsLayer::hasPendingVisibleChanges):
(WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
(WebCore::CoordinatedGraphicsLayer::selfOrAncestorHasActiveTransformAnimation):
(WebCore):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayer):
LayoutTests:
This test checks that a compositing layer is rendered if the layer is
originally transformed off the viewport.
* animations/animation-offscreen-to-onscreen-expected.png: Added.
* animations/animation-offscreen-to-onscreen-expected.txt: Added.
* animations/animation-offscreen-to-onscreen.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (135211 => 135212)
--- trunk/LayoutTests/ChangeLog 2012-11-20 00:34:12 UTC (rev 135211)
+++ trunk/LayoutTests/ChangeLog 2012-11-20 00:38:01 UTC (rev 135212)
@@ -1,3 +1,17 @@
+2012-11-19 Huang Dongsung <[email protected]>
+
+ Coordinated Graphics: Remove tiles of a layer when they are off the viewport.
+ https://bugs.webkit.org/show_bug.cgi?id=102313
+
+ Reviewed by Noam Rosenthal.
+
+ This test checks that a compositing layer is rendered if the layer is
+ originally transformed off the viewport.
+
+ * animations/animation-offscreen-to-onscreen-expected.png: Added.
+ * animations/animation-offscreen-to-onscreen-expected.txt: Added.
+ * animations/animation-offscreen-to-onscreen.html: Added.
+
2012-11-19 Jian Li <[email protected]>
Unreviewed. Mark 2 tests as failed on chromium.
Added: trunk/LayoutTests/animations/animation-offscreen-to-onscreen-expected.png (0 => 135212)
--- trunk/LayoutTests/animations/animation-offscreen-to-onscreen-expected.png (rev 0)
+++ trunk/LayoutTests/animations/animation-offscreen-to-onscreen-expected.png 2012-11-20 00:38:01 UTC (rev 135212)
@@ -0,0 +1,5 @@
+\x89PNG
+
+
+IHDR X \x9Av\x82p sBIT|d\x88 pHYs \xC4 \xC4\x95+ )tEXtchecksum 5674fabca59e0959f93fc21add15e018\x82
+{ \x83IDATx\x9C\xED\xD91\xC2@A\xF9\xFF_^R\xE4ܽT\xBD`\xD2֜\x99\x99 @\xE0\xBD= \xF8 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 sm\xE0\xE6\x9C\xED|\x9B\xD9^ \xF0S< @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d\xAE\xED\xDC\xCCl/ \x80\xC7x@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\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80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8| \x8E\xEC\xAE\x81ư IEND\xAEB`\x82
\ No newline at end of file
Added: trunk/LayoutTests/animations/animation-offscreen-to-onscreen-expected.txt (0 => 135212)
--- trunk/LayoutTests/animations/animation-offscreen-to-onscreen-expected.txt (rev 0)
+++ trunk/LayoutTests/animations/animation-offscreen-to-onscreen-expected.txt 2012-11-20 00:38:01 UTC (rev 135212)
@@ -0,0 +1,2 @@
+PASS - "webkitTransform" property for "box" element at 0.5s saw something close to: 1,0,0,1,100,0
+
Added: trunk/LayoutTests/animations/animation-offscreen-to-onscreen.html (0 => 135212)
--- trunk/LayoutTests/animations/animation-offscreen-to-onscreen.html (rev 0)
+++ trunk/LayoutTests/animations/animation-offscreen-to-onscreen.html 2012-11-20 00:38:01 UTC (rev 135212)
@@ -0,0 +1,53 @@
+<html>
+<head>
+ <style type="text/css" media="screen">
+ body {
+ margin: 0;
+ }
+
+ #box {
+ position: absolute;
+ left: 0px;
+ top: 100px;
+ height: 100px;
+ width: 100px;
+ margin: 0;
+ background-color: red;
+ -webkit-transform: translate(-2000px, 0px);
+ -webkit-animation-duration: 1s;
+ -webkit-animation-direction: normal;
+ -webkit-animation-timing-function: linear;
+ -webkit-animation-name: "anim";
+ }
+ @-webkit-keyframes "anim" {
+ 0% { -webkit-transform: translate(100px, 0px); }
+ 100% { -webkit-transform: translate(100px, 0px); }
+ }
+ #result {
+ color: white; /* hide from pixel results */
+ }
+ </style>
+ <script src="" type="text/_javascript_"></script>
+ <script type="text/_javascript_" charset="utf-8">
+ if (window.testRunner) {
+ window.testRunner.dumpAsText(true);
+ }
+
+ const expectedValues = [
+ // [time, element-id, property, expected-value, tolerance]
+ ["anim", 0.5, "box", "webkitTransform", [1, 0, 0, 1, 100, 0], 0.002],
+ ];
+
+ const doPixelTest = true;
+ const disablePauseAnimationAPI = false;
+ runAnimationTest(expectedValues, null, null, disablePauseAnimationAPI, doPixelTest);
+ </script>
+</head>
+<body>
+
+<!-- This test checks that a compositing layer is rendered if the layer is originally transformed off the viewport. You should see red boxes. -->
+<div id="box"></div>
+<div id="result"></div>
+
+</body>
+</html>
Modified: trunk/Source/WebKit2/ChangeLog (135211 => 135212)
--- trunk/Source/WebKit2/ChangeLog 2012-11-20 00:34:12 UTC (rev 135211)
+++ trunk/Source/WebKit2/ChangeLog 2012-11-20 00:38:01 UTC (rev 135212)
@@ -1,5 +1,36 @@
2012-11-19 Huang Dongsung <[email protected]>
+ Coordinated Graphics: Remove tiles of a layer when they are off the viewport.
+ https://bugs.webkit.org/show_bug.cgi?id=102313
+
+ Reviewed by Noam Rosenthal.
+
+ Currently, we don't remove tiles of the layer with the special properties: a
+ transform animation and non affine transform. If a page has a lot of layers with
+ a transform animation, we will encounter OOM. So this patch removes the
+ privilege of the layer.
+
+ There are two changes.
+ 1. computeTransformedVisibleRect() calculates a layer transform using the
+ current local transform which a transform animation applied.
+ 2. tiledBackingStoreVisibleRect() calculates a visible
+ rect of all layers, even if the layer includes the property: a transform
+ animation or non affine transform.
+
+ Test: animations/animation-offscreen-to-onscreen.html
+
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
+ (WebCore::CoordinatedGraphicsLayer::effectiveContentsScale):
+ (WebCore::CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect):
+ (WebCore::CoordinatedGraphicsLayer::hasPendingVisibleChanges):
+ (WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
+ (WebCore::CoordinatedGraphicsLayer::selfOrAncestorHasActiveTransformAnimation):
+ (WebCore):
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
+ (CoordinatedGraphicsLayer):
+
+2012-11-19 Huang Dongsung <[email protected]>
+
Coordinated Graphics: Remove a texture if an direct composited image is off the viewport.
https://bugs.webkit.org/show_bug.cgi?id=102449
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp (135211 => 135212)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp 2012-11-20 00:34:12 UTC (rev 135211)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp 2012-11-20 00:38:01 UTC (rev 135212)
@@ -644,7 +644,7 @@
float CoordinatedGraphicsLayer::effectiveContentsScale()
{
- return shouldUseTiledBackingStore() ? m_contentsScale : 1;
+ return selfOrAncestorHaveNonAffineTransforms() ? 1 : m_contentsScale;
}
void CoordinatedGraphicsLayer::adjustContentsScale()
@@ -697,16 +697,8 @@
return IntRect(0, 0, size().width(), size().height());
}
-bool CoordinatedGraphicsLayer::shouldUseTiledBackingStore()
-{
- return !selfOrAncestorHaveNonAffineTransforms();
-}
-
IntRect CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect()
{
- if (!shouldUseTiledBackingStore())
- return tiledBackingStoreContentsRect();
-
// Non-invertible layers are not visible.
if (!m_layerTransform.combined().isInvertible())
return IntRect();
@@ -807,17 +799,21 @@
if (!m_shouldSyncLayerState && !m_shouldSyncChildren && !m_shouldSyncFilters && !m_shouldSyncImageBacking && !m_shouldSyncAnimations && !m_canvasNeedsDisplay)
return false;
- return selfOrAncestorHaveNonAffineTransforms() || !tiledBackingStoreVisibleRect().isEmpty();
-
+ return tiledBackingStoreVisibleRect().intersects(tiledBackingStoreContentsRect());
}
void CoordinatedGraphicsLayer::computeTransformedVisibleRect()
{
- if (!m_shouldUpdateVisibleRect)
+ // When we have a transform animation, we need to update visible rect every frame to adjust the visible rect of a backing store.
+ bool hasActiveTransformAnimation = selfOrAncestorHasActiveTransformAnimation();
+ if (!m_shouldUpdateVisibleRect && !hasActiveTransformAnimation)
return;
m_shouldUpdateVisibleRect = false;
- m_layerTransform.setLocalTransform(transform());
+ TransformationMatrix currentTransform = transform();
+ if (hasActiveTransformAnimation)
+ client()->getCurrentTransform(this, currentTransform);
+ m_layerTransform.setLocalTransform(currentTransform);
m_layerTransform.setPosition(position());
m_layerTransform.setAnchorPoint(anchorPoint());
m_layerTransform.setSize(size());
@@ -841,6 +837,17 @@
GraphicsLayer::setGraphicsLayerFactory(createCoordinatedGraphicsLayer);
}
+bool CoordinatedGraphicsLayer::selfOrAncestorHasActiveTransformAnimation() const
+{
+ if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform))
+ return true;
+
+ if (!parent())
+ return false;
+
+ return toCoordinatedGraphicsLayer(parent())->selfOrAncestorHasActiveTransformAnimation();
+}
+
bool CoordinatedGraphicsLayer::selfOrAncestorHaveNonAffineTransforms()
{
if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform))
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h (135211 => 135212)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h 2012-11-20 00:34:12 UTC (rev 135211)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h 2012-11-20 00:38:01 UTC (rev 135212)
@@ -196,8 +196,8 @@
void destroyCanvasIfNeeded();
void createCanvasIfNeeded();
+ bool selfOrAncestorHasActiveTransformAnimation() const;
bool selfOrAncestorHaveNonAffineTransforms();
- bool shouldUseTiledBackingStore();
void adjustContentsScale();
void setShouldUpdateVisibleRect();