haikuwebkit/LayoutTests/compositing/contents-scale/simple-scale.html

36 lines
810 B
HTML
Raw Permalink Normal View History

Hardware accelerated CSS transitions appear pixelated when scaled up using transform https://bugs.webkit.org/show_bug.cgi?id=27684 <rdar://problem/6134606> Source/WebCore: Reviewed by Dean Jackson. Take transforms and animations into account when computing the contentsScale for a layer, so that scaled-up layers remain sharp most of the time. In its recursiveCommitChanges() tree walk, GraphicsLayerCA now tracks a root-relative transform, and extracts from that transform the X and Y scales which it uses to scale the backing store. If the layer has transform animations on it, we keep around a transformation matrix for the animation endpoints (or keyframes), pick up the state that has the larger impact on the root-relative scale, and use that as the layer's transform, and the transform when recursing over descendants. Tests: compositing/contents-scale/animating.html compositing/contents-scale/scaled-ancestor.html compositing/contents-scale/simple-scale.html compositing/contents-scale/z-translate.html * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::maxScaleFromTransform): Decompose the transform if necesssary to extract the X and Y scale components. (WebCore::GraphicsLayerCA::GraphicsLayerCA): Initialize m_rootRelativeScaleFactor. (WebCore::GraphicsLayerCA::flushCompositingState): Supply a TransformationMatrix for the root of the recursion. (WebCore::GraphicsLayerCA::layerTransform): This code was factored out of computeVisibleRect(), and optionally takes a custom transform. (WebCore::GraphicsLayerCA::computeVisibleRect): Use the layerTransform() function. (WebCore::GraphicsLayerCA::updateRootRelativeScale): Given a transform from the root, find the max scale factor by multiplying the various animation endpoint matrices and picking the one with the biggest impact on scale. Use this to set m_rootRelativeScaleFactor, and set the flag to say that we need to update contentsScale. (WebCore::GraphicsLayerCA::recursiveCommitChanges): (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): After updating animations, call updateRootRelativeScale() to update m_rootRelativeScaleFactor. (WebCore::GraphicsLayerCA::updateAnimations): We have a side table of animation name to TransformationMatrix, so figure out which entries can be removed from that side table, and remove them. (WebCore::GraphicsLayerCA::setAnimationOnLayer): (WebCore::GraphicsLayerCA::appendToUncommittedAnimations): Store the matrices for animation endpoints/keyframes in the m_animationTransforms side table. We don't store them directly in LayerPropertyAnimation because we just want the final matrix for a transform list, and using a side table makes ownership easier to manage. (WebCore::GraphicsLayerCA::getTransformFromAnimationsWithMaxScaleImpact): goes through the matrices for the running animation endpoints/keyframes, and multiplies each with the transform up to this layer to find the matrix with the larger impact on scale. (WebCore::GraphicsLayerCA::setTransformAnimationEndpoints): Returns a vector of TransformationMatrix for the from and to states. (WebCore::GraphicsLayerCA::setTransformAnimationKeyframes): Returns a vector of TransformationMatrix for the keyframes. (WebCore::GraphicsLayerCA::updateContentsScale): Include m_rootRelativeScaleFactor in the scale factor computation. (WebCore::GraphicsLayerCA::dumpAdditionalProperties): If we're dumping visible rects, also dump the contentsScale. Convenient at these are useful to look at together, and I didn't want to pollute Internals with yet more flags. * platform/graphics/ca/GraphicsLayerCA.h: (WebCore::GraphicsLayerCA::LayerPropertyAnimation::LayerPropertyAnimation): Formatting. LayoutTests: Reviewed by Dean Jackson. New tests that dump contentsScale under various scaling scenarios: * compositing/contents-scale/animating-expected.txt: Added. * compositing/contents-scale/animating.html: Added. * compositing/contents-scale/scaled-ancestor-expected.txt: Added. * compositing/contents-scale/scaled-ancestor.html: Added. * compositing/contents-scale/simple-scale-expected.txt: Added. * compositing/contents-scale/simple-scale.html: Added. * compositing/contents-scale/z-translate-expected.txt: Added. * compositing/contents-scale/z-translate.html: Added. These tests had Mac-specific results (which include visible rects and now contents scale) in the cross-platform directory, so cleaned up the cross-platform results and moved the Mac results to platform-mac. * compositing/overflow/clipping-behaviour-change-is-not-propagated-to-descendants-expected.txt: * compositing/overflow/clipping-behaviour-change-is-not-propagated-to-descendants2-expected.txt: * compositing/visible-rect/2d-transformed-expected.txt: * compositing/visible-rect/3d-transform-style-expected.txt: * compositing/visible-rect/3d-transformed-expected.txt: * compositing/visible-rect/animated-expected.txt: * compositing/visible-rect/animated-from-none-expected.txt: * compositing/visible-rect/clipped-by-viewport-expected.txt: * compositing/visible-rect/clipped-visible-rect-expected.txt: * compositing/visible-rect/flipped-preserve-3d-expected.txt: * compositing/visible-rect/iframe-and-layers-expected.txt: * compositing/visible-rect/nested-transform-expected.txt: * compositing/visible-rect/scrolled-expected.txt: * platform/mac/compositing/tiling/rotated-tiled-clamped-expected.txt: * platform/mac/compositing/tiling/rotated-tiled-preserve3d-clamped-expected.txt: * platform/mac/compositing/tiling/tile-cache-zoomed-expected.txt: * platform/mac/compositing/visible-rect/2d-transformed-expected.txt: Copied from LayoutTests/compositing/visible-rect/2d-transformed-expected.txt. * platform/mac/compositing/visible-rect/3d-transform-style-expected.txt: Copied from LayoutTests/compositing/visible-rect/3d-transform-style-expected.txt. * platform/mac/compositing/visible-rect/3d-transformed-expected.txt: Copied from LayoutTests/compositing/visible-rect/3d-transformed-expected.txt. * platform/mac/compositing/visible-rect/animated-expected.txt: Copied from LayoutTests/compositing/visible-rect/animated-expected.txt. * platform/mac/compositing/visible-rect/animated-from-none-expected.txt: Copied from LayoutTests/compositing/visible-rect/animated-from-none-expected.txt. * platform/mac/compositing/visible-rect/clipped-by-viewport-expected.txt: Copied from LayoutTests/compositing/visible-rect/clipped-by-viewport-expected.txt. * platform/mac/compositing/visible-rect/clipped-visible-rect-expected.txt: Copied from LayoutTests/compositing/visible-rect/clipped-visible-rect-expected.txt. * platform/mac/compositing/visible-rect/flipped-preserve-3d-expected.txt: Copied from LayoutTests/compositing/visible-rect/flipped-preserve-3d-expected.txt. * platform/mac/compositing/visible-rect/iframe-and-layers-expected.txt: Copied from LayoutTests/compositing/visible-rect/iframe-and-layers-expected.txt. * platform/mac/compositing/visible-rect/iframe-no-layers-expected.txt: * platform/mac/compositing/visible-rect/nested-transform-expected.txt: Copied from LayoutTests/compositing/visible-rect/nested-transform-expected.txt. * platform/mac/compositing/visible-rect/scrolled-expected.txt: Copied from LayoutTests/compositing/visible-rect/scrolled-expected.txt. Canonical link: https://commits.webkit.org/139518@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-09-17 21:33:48 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
.box {
width: 100px;
height: 100px;
margin: 10px;
padding: 10px;
box-sizing: border-box;
background-color: silver;
-webkit-transform: scale3d(2, 2, 1);
-webkit-transform-origin: top left;
}
</style>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function doTest()
{
if (window.internals)
document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS)
}
window.addEventListener('load', doTest, false);
</script>
</head>
<body>
<div class="box">Box</div>
<pre id="layers">Layer tree goes here when testing</pre>
</body>
</html>