12013-08-30 Simon Fraser <simon.fraser@apple.com>
2
3 Video with object-fit: cover can spill outside the box
4 https://bugs.webkit.org/show_bug.cgi?id=52103
5
6 Reviewed by NOBODY (OOPS!).
7
8 object-fit on renderers which use accelerated compositing needs special
9 treatment.
10
11 For directly composited images, and video, GraphicsLayer needs to know
12 both the size of the content layer, and also a rectangle at which this
13 should be clipped (because, for the first time, that content layer can be
14 larger than the renderer's content box).
15
16 AVFoundation would always aspect-ratio fit video by default, so plumb
17 through MediaPlayer a way to override that when object-fit requires it.
18
19 Added a LAYER_TREE_INCLUDES_CONTENT_LAYERS enum to the layerTreeAsText()
20 flags so we can dump content layers for testing.
21
22 Tests: compositing/images/direct-image-object-fit.html
23 compositing/reflections/direct-image-object-fit-reflected.html
24 compositing/video/video-object-fit.html
25
26 * page/Frame.h: New LayerTreeFlagsIncludeContentLayers flag.
27 * platform/graphics/GraphicsLayer.h: New flag.
28 * platform/graphics/MediaPlayer.cpp:
29 (WebCore::MediaPlayer::shouldMaintainAspectRatio):
30 (WebCore::MediaPlayer::setShouldMaintainAspectRatio):
31 * platform/graphics/MediaPlayer.h:
32 * platform/graphics/MediaPlayerPrivate.h:
33 (WebCore::MediaPlayerPrivateInterface::shouldMaintainAspectRatio):
34 (WebCore::MediaPlayerPrivateInterface::setShouldMaintainAspectRatio):
35 * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
36 (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
37 (WebCore::MediaPlayerPrivateAVFoundation::setShouldMaintainAspectRatio):
38 * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
39 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
40 (WebCore::MediaPlayerPrivateAVFoundationCF::updateVideoLayerGravity):
41 (WebCore::AVFWrapper::platformLayer):
42 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
43 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
44 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
45 (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer):
46 (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoLayerGravity):
47 * platform/graphics/ca/GraphicsLayerCA.cpp: We need a new m_contentsClippingLayer to
48 clip the contents layer, which only gets created when necessary. It has to be cloned
49 for reflections.
50 (WebCore::GraphicsLayerCA::willBeDestroyed):
51 (WebCore::GraphicsLayerCA::setContentsRect):
52 (WebCore::GraphicsLayerCA::setContentsClippingRect):
53 (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
54 (WebCore::GraphicsLayerCA::updateSublayerList):
55 (WebCore::GraphicsLayerCA::updateContentsImage):
56 (WebCore::GraphicsLayerCA::updateContentsMediaLayer):
57 (WebCore::GraphicsLayerCA::updateContentsCanvasLayer):
58 (WebCore::GraphicsLayerCA::updateContentsColorLayer):
59 (WebCore::GraphicsLayerCA::updateContentsRects):
60 (WebCore::GraphicsLayerCA::dumpAdditionalProperties):
61 (WebCore::GraphicsLayerCA::ensureCloneLayers):
62 (WebCore::GraphicsLayerCA::removeCloneLayers):
63 (WebCore::GraphicsLayerCA::fetchCloneLayers):
64 * platform/graphics/ca/GraphicsLayerCA.h:
65 * rendering/RenderLayerBacking.cpp: Need to push both the contentsRect and
66 the contentsClippingRect down to the GraphicsLayers. Most of the time they
67 are the same, unless object-fit makes them different.
68 (WebCore::RenderLayerBacking::resetContentsRect):
69 (WebCore::RenderLayerBacking::positionOverflowControlsLayers):
70 (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
71 (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
72 (WebCore::RenderLayerBacking::updateImageContents):
73 (WebCore::RenderLayerBacking::contentsBox):
74 * rendering/RenderLayerCompositor.cpp:
75 (WebCore::RenderLayerCompositor::layerTreeAsText):
76 * rendering/RenderVideo.cpp:
77 (WebCore::RenderVideo::updatePlayer):
78 * testing/Internals.cpp:
79 (WebCore::Internals::layerTreeAsText):
80 * testing/Internals.h:
81 * testing/Internals.idl:
82