Source/WebCore/ChangeLog

112017-02-16 Simon Fraser <simon.fraser@apple.com>
22
 3 Allow PlatformCALayers to specify that they want deep color backing store
 4 https://bugs.webkit.org/show_bug.cgi?id=168495
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Currently capable iOS devices get deep color backing store by virtue of a supports
 9 check in PlatformCALayerCocoa::PlatformCALayerCocoa(), and LegacyTileGridTile.
 10
 11 Future work will make layer contents format selection more complex, so express the need
 12 for deep color on PlatformCALayer, and have the creators of PlatformCALayer (mainly the
 13 flavors of GraphicsLayerCA) choose for them to support deep color. A bit of special-casing
 14 is needed to propagte the state to TileControllers.
 15
 16 The deep-colorness now propagates from PlatformCALayerRemote to RemoteLayerBackingStore,
 17 instead of RemoteLayerBackingStore looking at the properties of the screen directly.
 18
 19 Remove PlatformCALayer::LayerTypeWebTiledLayer which was only used for the old CATiledLayers
 20 that we no longer use.
 21
 22 An iphone7 test verifies that page tiles, normal layers and tiled layers get the deep
 23 color state set on them.
 24
 25 Test: tiled-drawing/ios/iphone7/compositing-layers-deep-color.html
 26
 27 * platform/graphics/ca/GraphicsLayerCA.cpp:
 28 (WebCore::GraphicsLayerCA::createPlatformCALayer):
 29 (WebCore::GraphicsLayerCA::dumpAdditionalProperties):
 30 * platform/graphics/ca/GraphicsLayerCA.h:
 31 * platform/graphics/ca/PlatformCALayer.cpp:
 32 (WebCore::PlatformCALayer::canHaveBackingStore):
 33 (WebCore::operator<<):
 34 * platform/graphics/ca/PlatformCALayer.h:
 35 * platform/graphics/ca/TileController.cpp:
 36 (WebCore::TileController::setZoomedOutContentsScale):
 37 (WebCore::TileController::setAcceleratesDrawing):
 38 (WebCore::TileController::setWantsDeepColorBackingStore):
 39 (WebCore::TileController::createTileLayer):
 40 * platform/graphics/ca/TileController.h:
 41 * platform/graphics/ca/TileGrid.cpp:
 42 (WebCore::TileGrid::updateTileLayerProperties):
 43 * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
 44 * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
 45 (PlatformCALayerCocoa::PlatformCALayerCocoa):
 46 (PlatformCALayerCocoa::commonInit):
 47 (PlatformCALayerCocoa::wantsDeepColorBackingStore):
 48 (PlatformCALayerCocoa::setWantsDeepColorBackingStore):
 49 (layerContentsFormat):
 50 (PlatformCALayerCocoa::updateContentsFormat):
 51 * platform/graphics/ca/cocoa/WebTiledBackingLayer.h:
 52 * platform/graphics/ca/cocoa/WebTiledBackingLayer.mm:
 53 (-[WebTiledBackingLayer setWantsDeepColorBackingStore:]):
 54 (-[WebTiledBackingLayer wantsDeepColorBackingStore]):
 55 * platform/graphics/ca/win/PlatformCALayerWin.cpp:
 56 (printLayer):
 57
 582017-02-16 Simon Fraser <simon.fraser@apple.com>
 59
360 REGRESSION(r212439): Web Inspector Toolbar / Window appears broken
461 https://bugs.webkit.org/show_bug.cgi?id=168494
562

Source/WebKit2/ChangeLog

 12017-02-16 Simon Fraser <simon.fraser@apple.com>
 2
 3 Allow PlatformCALayers to specify that they want deep color backing store
 4 https://bugs.webkit.org/show_bug.cgi?id=168495
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Currently capable iOS devices get deep color backing store by virtue of a supports
 9 check in PlatformCALayerCocoa::PlatformCALayerCocoa(), and LegacyTileGridTile.
 10
 11 Future work will make layer contents format selection more complex, so express the need
 12 for deep color on PlatformCALayer, and have the creators of PlatformCALayer (mainly the
 13 flavors of GraphicsLayerCA) choose for them to support deep color. A bit of special-casing
 14 is needed to propagte the state to TileControllers.
 15
 16 The deep-colorness now propagates from PlatformCALayerRemote to RemoteLayerBackingStore,
 17 instead of RemoteLayerBackingStore looking at the properties of the screen directly.
 18
 19 Remove PlatformCALayer::LayerTypeWebTiledLayer which was only used for the old CATiledLayers
 20 that we no longer use.
 21
 22 * Shared/mac/RemoteLayerBackingStore.h:
 23 * Shared/mac/RemoteLayerBackingStore.mm:
 24 (WebKit::RemoteLayerBackingStore::ensureBackingStore):
 25 (WebKit::RemoteLayerBackingStore::bytesPerPixel):
 26 (WebKit::RemoteLayerBackingStore::swapToValidFrontBuffer):
 27 (WebKit::RemoteLayerBackingStore::drawInContext):
 28 (WebKit::RemoteLayerBackingStore::surfaceBufferFormat):
 29 (WebKit::bufferFormat): Deleted.
 30 * WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp:
 31 (WebKit::GraphicsLayerCARemote::createPlatformCALayer):
 32 * WebProcess/WebPage/mac/GraphicsLayerCARemote.h:
 33 * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
 34 (WebKit::PlatformCALayerRemote::PlatformCALayerRemote):
 35 (WebKit::PlatformCALayerRemote::updateBackingStore):
 36 (WebKit::PlatformCALayerRemote::wantsDeepColorBackingStore):
 37 (WebKit::PlatformCALayerRemote::setWantsDeepColorBackingStore):
 38 * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
 39 * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp:
 40 (WebKit::PlatformCALayerRemoteTiledBacking::wantsDeepColorBackingStore):
 41 (WebKit::PlatformCALayerRemoteTiledBacking::setWantsDeepColorBackingStore):
 42 * WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h:
 43
1442017-02-16 Youenn Fablet <youenn@apple.com>
245
346 [WebRTC] libwebrtc socket addresses should not be passed as strings

Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

3939#include "Logging.h"
4040#include "PlatformCAFilters.h"
4141#include "PlatformCALayer.h"
 42#include "PlatformScreen.h"
4243#include "RotateTransformOperation.h"
4344#include "ScaleTransformOperation.h"
4445#include "TextStream.h"

@@bool GraphicsLayerCA::filtersCanBeComposited(const FilterOperations& filters)
341342PassRefPtr<PlatformCALayer> GraphicsLayerCA::createPlatformCALayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* owner)
342343{
343344#if PLATFORM(COCOA)
344  return PlatformCALayerCocoa::create(layerType, owner);
 345 auto result = PlatformCALayerCocoa::create(layerType, owner);
 346
 347 if (result->canHaveBackingStore())
 348 result->setWantsDeepColorBackingStore(screenSupportsExtendedColor());
 349
 350 return result;
345351#elif PLATFORM(WIN)
346352 return PlatformCALayerWin::create(layerType, owner);
347353#endif

@@void GraphicsLayerCA::dumpAdditionalProperties(TextStream& textStream, int inden
34993505 textStream << "(in window " << tiledBacking()->isInWindow() << ")\n";
35003506 }
35013507
 3508 if (m_layer->wantsDeepColorBackingStore()) {
 3509 writeIndent(textStream, indent + 1);
 3510 textStream << "(deep color 1)\n";
 3511 }
 3512
35023513 if (behavior & LayerTreeAsTextIncludeContentLayers) {
35033514 dumpInnerLayer(textStream, "structural layer", m_structuralLayer.get(), indent, behavior);
35043515 dumpInnerLayer(textStream, "contents clipping layer", m_contentsClippingLayer.get(), indent, behavior);

Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424 */
2525
26 #ifndef GraphicsLayerCA_h
27 #define GraphicsLayerCA_h
 26#pragma once
2827
2928#include "GraphicsLayer.h"
3029#include "PlatformCAAnimation.h"

@@private:
594593} // namespace WebCore
595594
596595SPECIALIZE_TYPE_TRAITS_GRAPHICSLAYER(WebCore::GraphicsLayerCA, isGraphicsLayerCA())
597 
598 #endif // GraphicsLayerCA_h

Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp

@@PlatformCALayer::~PlatformCALayer()
6666 setOwner(nullptr);
6767}
6868
 69bool PlatformCALayer::canHaveBackingStore() const
 70{
 71 return m_layerType == LayerType::LayerTypeWebLayer
 72 || m_layerType == LayerType::LayerTypeTiledBackingLayer
 73 || m_layerType == LayerType::LayerTypePageTiledBackingLayer
 74 || m_layerType == LayerType::LayerTypeTiledBackingTileLayer;
 75}
 76
6977void PlatformCALayer::drawRepaintIndicator(CGContextRef context, PlatformCALayer* platformCALayer, int repaintCount, CGColorRef customBackgroundColor)
7078{
7179 char text[16]; // that's a lot of repaints

@@TextStream& operator<<(TextStream& ts, PlatformCALayer::LayerType layerType)
177185 case PlatformCALayer::LayerTypeTransformLayer:
178186 ts << "transform-layer";
179187 break;
180  case PlatformCALayer::LayerTypeWebTiledLayer:
181  ts << "tiled-layer";
182  break;
183188 case PlatformCALayer::LayerTypeTiledBackingLayer:
184189 ts << "tiled-backing-layer";
185190 break;

Source/WebCore/platform/graphics/ca/PlatformCALayer.h

2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424 */
2525
26 #ifndef PlatformCALayer_h
27 #define PlatformCALayer_h
 26#pragma once
2827
2928#include "FloatRoundedRect.h"
3029#include "GraphicsLayer.h"

@@public:
6867 LayerTypeWebLayer,
6968 LayerTypeSimpleLayer,
7069 LayerTypeTransformLayer,
71  LayerTypeWebTiledLayer,
7270 LayerTypeTiledBackingLayer,
7371 LayerTypePageTiledBackingLayer,
7472 LayerTypeTiledBackingTileLayer,

@@public:
114112 virtual void copyContentsFromLayer(PlatformCALayer*) = 0;
115113
116114 LayerType layerType() const { return m_layerType; }
 115
 116 bool canHaveBackingStore() const;
117117
118118 virtual PlatformCALayer* superlayer() const = 0;
119119 virtual void removeFromSuperlayer() = 0;

@@public:
176176 virtual bool acceleratesDrawing() const = 0;
177177 virtual void setAcceleratesDrawing(bool) = 0;
178178
 179 virtual bool wantsDeepColorBackingStore() const = 0;
 180 virtual void setWantsDeepColorBackingStore(bool) = 0;
 181
179182 virtual CFTypeRef contents() const = 0;
180183 virtual void setContents(CFTypeRef) = 0;
181184

@@WEBCORE_EXPORT TextStream& operator<<(TextStream&, PlatformCALayer::FilterType);
298301SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName) \
299302 static bool isType(const WebCore::PlatformCALayer& layer) { return layer.predicate; } \
300303SPECIALIZE_TYPE_TRAITS_END()
301 
302 #endif // PlatformCALayer_h

Source/WebCore/platform/graphics/ca/TileController.cpp

@@void TileController::setZoomedOutContentsScale(float scale)
157157
158158 if (m_zoomedOutContentsScale == scale)
159159 return;
 160
160161 m_zoomedOutContentsScale = scale;
161162
162163 if (m_zoomedOutTileGrid && m_zoomedOutTileGrid->scale() != m_zoomedOutContentsScale)

@@void TileController::setAcceleratesDrawing(bool acceleratesDrawing)
167168{
168169 if (m_acceleratesDrawing == acceleratesDrawing)
169170 return;
 171
170172 m_acceleratesDrawing = acceleratesDrawing;
 173 tileGrid().updateTileLayerProperties();
 174}
 175
 176void TileController::setWantsDeepColorBackingStore(bool wantsDeepColorBackingStore)
 177{
 178 if (m_wantsDeepColorBackingStore == wantsDeepColorBackingStore)
 179 return;
 180
 181 m_wantsDeepColorBackingStore = wantsDeepColorBackingStore;
171182
172183 tileGrid().updateTileLayerProperties();
173184}

@@RefPtr<PlatformCALayer> TileController::createTileLayer(const IntRect& tileRect,
723734
724735 layer->setContentsScale(m_deviceScaleFactor * temporaryScaleFactor);
725736 layer->setAcceleratesDrawing(m_acceleratesDrawing);
 737 layer->setWantsDeepColorBackingStore(m_wantsDeepColorBackingStore);
726738
727739 layer->setNeedsDisplay();
728740

Source/WebCore/platform/graphics/ca/TileController.h

@@public:
7171 bool acceleratesDrawing() const { return m_acceleratesDrawing; }
7272 WEBCORE_EXPORT void setAcceleratesDrawing(bool);
7373
 74 bool wantsDeepColorBackingStore() const { return m_wantsDeepColorBackingStore; }
 75 WEBCORE_EXPORT void setWantsDeepColorBackingStore(bool);
 76
7477 WEBCORE_EXPORT void setTilesOpaque(bool);
7578 bool tilesAreOpaque() const { return m_tilesAreOpaque; }
7679

@@private:
217220 bool m_isInWindow { false };
218221 bool m_scrollingPerformanceLoggingEnabled { false };
219222 bool m_acceleratesDrawing { false };
 223 bool m_wantsDeepColorBackingStore { false };
220224 bool m_tilesAreOpaque { false };
221225 bool m_hasTilesWithTemporaryScaleFactor { false }; // Used to make low-res tiles when zooming.
222226 bool m_inLiveResize { false };

Source/WebCore/platform/graphics/ca/TileGrid.cpp

@@void TileGrid::setTileNeedsDisplayInRect(const TileIndex& tileIndex, TileInfo& t
198198void TileGrid::updateTileLayerProperties()
199199{
200200 bool acceleratesDrawing = m_controller.acceleratesDrawing();
 201 bool deepColor = m_controller.wantsDeepColorBackingStore();
201202 bool opaque = m_controller.tilesAreOpaque();
202203 Color tileDebugBorderColor = m_controller.tileDebugBorderColor();
203204 float tileDebugBorderWidth = m_controller.tileDebugBorderWidth();

@@void TileGrid::updateTileLayerProperties()
205206 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
206207 const TileInfo& tileInfo = it->value;
207208 tileInfo.layer->setAcceleratesDrawing(acceleratesDrawing);
 209 tileInfo.layer->setWantsDeepColorBackingStore(deepColor);
208210 tileInfo.layer->setOpaque(opaque);
209211 tileInfo.layer->setBorderColor(tileDebugBorderColor);
210212 tileInfo.layer->setBorderWidth(tileDebugBorderWidth);

Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h

2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424 */
2525
26 #ifndef PlatformCALayerCocoa_h
27 #define PlatformCALayerCocoa_h
 26#pragma once
2827
2928#include "PlatformCALayer.h"
3029

@@public:
111110 bool acceleratesDrawing() const override;
112111 void setAcceleratesDrawing(bool) override;
113112
 113 bool wantsDeepColorBackingStore() const override;
 114 void setWantsDeepColorBackingStore(bool) override;
 115
114116 CFTypeRef contents() const override;
115117 void setContents(CFTypeRef) override;
116118

@@private:
180182
181183 bool requiresCustomAppearanceUpdateOnBoundsChange() const;
182184
 185 void updateContentsFormat();
 186
183187 AVPlayerLayer *avPlayerLayer() const;
184188
185189 RetainPtr<NSObject> m_delegate;
186190 std::unique_ptr<PlatformCALayerList> m_customSublayers;
187191 GraphicsLayer::CustomAppearance m_customAppearance;
188192 std::unique_ptr<FloatRoundedRect> m_shapeRoundedRect;
 193 bool m_wantsDeepColorBackingStore { false };
189194};
190195
191196} // namespace WebCore
192197
193198SPECIALIZE_TYPE_TRAITS_PLATFORM_CALAYER(WebCore::PlatformCALayerCocoa, isPlatformCALayerCocoa())
194 
195 #endif // PlatformCALayerCocoa_h

Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm

3232#import "LengthFunctions.h"
3333#import "PlatformCAAnimationCocoa.h"
3434#import "PlatformCAFilters.h"
35 #import "PlatformScreen.h"
3635#import "QuartzCoreSPI.h"
3736#import "ScrollbarThemeMac.h"
3837#import "SoftLinking.h"

@@PlatformCALayerCocoa::PlatformCALayerCocoa(LayerType layerType, PlatformCALayerC
240239 layerClass = [CALayer class];
241240 break;
242241#endif
243  case LayerTypeWebTiledLayer:
244  ASSERT_NOT_REACHED();
245  break;
246242 case LayerTypeTiledBackingLayer:
247243 case LayerTypePageTiledBackingLayer:
248244 layerClass = [WebTiledBackingLayer class];

@@void PlatformCALayerCocoa::commonInit()
293289 else
294290 [m_layer setDelegate:[WebActionDisablingCALayerDelegate shared]];
295291
296  if (m_layerType == LayerTypeWebLayer || m_layerType == LayerTypeTiledBackingTileLayer) {
297 #if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300
298  if (screenSupportsExtendedColor())
299  [m_layer setContentsFormat:kCAContentsFormatRGBA10XR];
300 #endif
301  }
302 
303292 // So that the scrolling thread's performance logging code can find all the tiles, mark this as being a tile.
304293 if (m_layerType == LayerTypeTiledBackingTileLayer)
305294 [m_layer setValue:@YES forKey:@"isTile"];

@@void PlatformCALayerCocoa::setAcceleratesDrawing(bool acceleratesDrawing)
696685 END_BLOCK_OBJC_EXCEPTIONS
697686}
698687
 688bool PlatformCALayerCocoa::wantsDeepColorBackingStore() const
 689{
 690 return m_wantsDeepColorBackingStore;
 691}
 692
 693void PlatformCALayerCocoa::setWantsDeepColorBackingStore(bool wantsDeepColorBackingStore)
 694{
 695 if (wantsDeepColorBackingStore == m_wantsDeepColorBackingStore)
 696 return;
 697
 698 m_wantsDeepColorBackingStore = wantsDeepColorBackingStore;
 699
 700 if (usesTiledBackingLayer()) {
 701 [static_cast<WebTiledBackingLayer *>(m_layer.get()) setWantsDeepColorBackingStore:m_wantsDeepColorBackingStore];
 702 return;
 703 }
 704
 705 updateContentsFormat();
 706}
 707
699708CFTypeRef PlatformCALayerCocoa::contents() const
700709{
701710 return [m_layer contents];

@@void PlatformCALayerCocoa::updateCustomAppearance(GraphicsLayer::CustomAppearanc
965974#endif
966975}
967976
 977#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
 978static NSString *layerContentsFormat(bool wantsDeepColor)
 979{
 980#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300
 981 if (wantsDeepColor)
 982 return kCAContentsFormatRGBA10XR;
 983#else
 984 UNUSED_PARAM(wantsDeepColor);
 985#endif
 986 return nil;
 987}
 988#endif
 989
 990void PlatformCALayerCocoa::updateContentsFormat()
 991{
 992 if (m_layerType == LayerTypeWebLayer || m_layerType == LayerTypeTiledBackingTileLayer) {
 993 BEGIN_BLOCK_OBJC_EXCEPTIONS
 994#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
 995 if (NSString *formatString = layerContentsFormat(wantsDeepColorBackingStore()))
 996 [m_layer setContentsFormat:formatString];
 997#endif
 998 END_BLOCK_OBJC_EXCEPTIONS
 999 }
 1000}
 1001
9681002TiledBacking* PlatformCALayerCocoa::tiledBacking()
9691003{
9701004 if (!usesTiledBackingLayer())

Source/WebCore/platform/graphics/ca/cocoa/WebTiledBackingLayer.h

@@class TiledBacking;
4343- (WebCore::TiledBacking*)tiledBacking;
4444- (void)invalidate;
4545
 46- (void)setWantsDeepColorBackingStore:(BOOL)wantsDeepColor;
 47- (BOOL)wantsDeepColorBackingStore;
 48
4649@end
4750
4851#endif // WebTiledBackingLayer_h

Source/WebCore/platform/graphics/ca/cocoa/WebTiledBackingLayer.mm

@@- (void)setDrawsAsynchronously:(BOOL)acceleratesDrawing
108108 _tileController->setAcceleratesDrawing(acceleratesDrawing);
109109}
110110
 111- (void)setWantsDeepColorBackingStore:(BOOL)wantsDeepColor
 112{
 113 _tileController->setWantsDeepColorBackingStore(wantsDeepColor);
 114}
 115
 116- (BOOL)wantsDeepColorBackingStore
 117{
 118 return _tileController->wantsDeepColorBackingStore();
 119}
 120
111121- (BOOL)drawsAsynchronously
112122{
113123 return _tileController ? _tileController->acceleratesDrawing() : NO;

Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp

@@void PlatformCALayerWin::setAcceleratesDrawing(bool)
519519{
520520}
521521
 522bool PlatformCALayerCocoa::wantsDeepColorBackingStore() const
 523{
 524 return false;
 525}
 526
 527void PlatformCALayerCocoa::setWantsDeepColorBackingStore(bool)
 528{
 529}
 530
522531CFTypeRef PlatformCALayerWin::contents() const
523532{
524533 return CACFLayerGetContents(m_layer.get());

@@static void printLayer(StringBuilder& builder, const PlatformCALayer* layer, int
745754 case PlatformCALayer::LayerTypeWebLayer: layerTypeName = "web-layer"; break;
746755 case PlatformCALayer::LayerTypeSimpleLayer: layerTypeName = "simple-layer"; break;
747756 case PlatformCALayer::LayerTypeTransformLayer: layerTypeName = "transform-layer"; break;
748  case PlatformCALayer::LayerTypeWebTiledLayer: layerTypeName = "web-tiled-layer"; break;
749757 case PlatformCALayer::LayerTypeTiledBackingLayer: layerTypeName = "tiled-backing-layer"; break;
750758 case PlatformCALayer::LayerTypePageTiledBackingLayer: layerTypeName = "page-tiled-backing-layer"; break;
751759 case PlatformCALayer::LayerTypeTiledBackingTileLayer: layerTypeName = "tiled-backing-tile-layer"; break;

Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h

@@public:
102102 bool acceleratesDrawing() const override;
103103 void setAcceleratesDrawing(bool) override;
104104
 105 bool wantsDeepColorBackingStore() const override;
 106 void setWantsDeepColorBackingStore(bool) override;
 107
105108 CFTypeRef contents() const override;
106109 void setContents(CFTypeRef) override;
107110

Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h

@@typedef struct CAColorMatrix CAColorMatrix;
124124@property (copy) NSString *name;
125125@end
126126
127 #if TARGET_OS_IPHONE || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
 127#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
128128typedef enum {
129129 kCATransactionPhasePreLayout,
130130 kCATransactionPhasePreCommit,

Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h

2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424 */
2525
26 #ifndef RemoteLayerBackingStore_h
27 #define RemoteLayerBackingStore_h
 26#pragma once
2827
2928#include "ShareableBitmap.h"
3029#include <WebCore/FloatRect.h>

@@public:
5150 RemoteLayerBackingStore(PlatformCALayerRemote*);
5251 ~RemoteLayerBackingStore();
5352
54  void ensureBackingStore(WebCore::FloatSize, float scale, bool acceleratesDrawing, bool isOpaque);
 53 void ensureBackingStore(WebCore::FloatSize, float scale, bool acceleratesDrawing, bool deepColor, bool isOpaque);
5554
5655 void setNeedsDisplay(const WebCore::IntRect);
5756 void setNeedsDisplay();

@@private:
9998 void drawInContext(WebCore::GraphicsContext&, CGImageRef backImage);
10099 void clearBackingStore();
101100 void swapToValidFrontBuffer();
102 
 101
 102#if USE(IOSURFACE)
 103 WebCore::IOSurface::Format surfaceBufferFormat() const;
 104#endif
 105
103106 WebCore::IntSize backingStoreSize() const;
104107
105108 PlatformCALayerRemote* m_layer;

@@private:
141144
142145 RetainPtr<CGContextRef> m_frontContextPendingFlush;
143146
144  bool m_acceleratesDrawing;
 147 bool m_acceleratesDrawing { false };
 148 bool m_deepColor { false };
145149
146150 WebCore::RepaintRectList m_paintingRects;
147151

@@private:
149153};
150154
151155} // namespace WebKit
152 
153 #endif // RemoteLayerBackingStore_h

Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm

3737#import <WebCore/GraphicsContextCG.h>
3838#import <WebCore/IOSurface.h>
3939#import <WebCore/PlatformCALayerClient.h>
40 #import <WebCore/PlatformScreen.h>
4140#import <WebCore/QuartzCoreSPI.h>
4241#import <WebCore/WebLayer.h>
4342

@@using namespace WebCore;
4948
5049namespace WebKit {
5150
52 #if USE(IOSURFACE)
53 static WebCore::IOSurface::Format bufferFormat(bool isOpaque)
54 {
55  if (screenSupportsExtendedColor())
56  return isOpaque ? WebCore::IOSurface::Format::RGB10 : WebCore::IOSurface::Format::RGB10A8;
57 
58  return WebCore::IOSurface::Format::RGBA;
59 }
60 #endif // USE(IOSURFACE)
61 
6251RemoteLayerBackingStore::RemoteLayerBackingStore(PlatformCALayerRemote* layer)
6352 : m_layer(layer)
6453 , m_isOpaque(false)

@@RemoteLayerBackingStore::~RemoteLayerBackingStore()
8170 context->backingStoreWillBeDestroyed(*this);
8271}
8372
84 void RemoteLayerBackingStore::ensureBackingStore(FloatSize size, float scale, bool acceleratesDrawing, bool isOpaque)
 73void RemoteLayerBackingStore::ensureBackingStore(FloatSize size, float scale, bool acceleratesDrawing, bool deepColor, bool isOpaque)
8574{
86  if (m_size == size && m_scale == scale && m_acceleratesDrawing == acceleratesDrawing && m_isOpaque == isOpaque)
 75 if (m_size == size && m_scale == scale && m_deepColor == deepColor && m_acceleratesDrawing == acceleratesDrawing && m_isOpaque == isOpaque)
8776 return;
8877
8978 m_size = size;
9079 m_scale = scale;
9180 m_acceleratesDrawing = acceleratesDrawing;
 81 m_deepColor = deepColor;
9282 m_isOpaque = isOpaque;
9383
9484 if (m_frontBuffer) {

@@IntSize RemoteLayerBackingStore::backingStoreSize() const
187177unsigned RemoteLayerBackingStore::bytesPerPixel() const
188178{
189179#if USE(IOSURFACE)
190  switch (bufferFormat(m_isOpaque)) {
 180 switch (surfaceBufferFormat()) {
191181 case WebCore::IOSurface::Format::RGBA: return 4;
192182 case WebCore::IOSurface::Format::YUV422: return 2;
193183 case WebCore::IOSurface::Format::RGB10: return 4;

@@void RemoteLayerBackingStore::swapToValidFrontBuffer()
212202 std::swap(m_frontBuffer, m_backBuffer);
213203
214204 if (!m_frontBuffer.surface)
215  m_frontBuffer.surface = WebCore::IOSurface::create(expandedScaledSize, sRGBColorSpaceRef(), bufferFormat(m_isOpaque));
 205 m_frontBuffer.surface = WebCore::IOSurface::create(expandedScaledSize, sRGBColorSpaceRef(), surfaceBufferFormat());
216206
217207 setBufferVolatility(BufferType::Front, false);
218208 return;

@@void RemoteLayerBackingStore::drawInContext(GraphicsContext& context, CGImageRef
364354 break;
365355 case PlatformCALayer::LayerTypeLayer:
366356 case PlatformCALayer::LayerTypeTransformLayer:
367  case PlatformCALayer::LayerTypeWebTiledLayer:
368357 case PlatformCALayer::LayerTypeTiledBackingLayer:
369358 case PlatformCALayer::LayerTypePageTiledBackingLayer:
370359 case PlatformCALayer::LayerTypeRootLayer:

@@void RemoteLayerBackingStore::Buffer::discard()
491480 bitmap = nullptr;
492481}
493482
 483#if USE(IOSURFACE)
 484WebCore::IOSurface::Format RemoteLayerBackingStore::surfaceBufferFormat() const
 485{
 486 if (m_deepColor)
 487 return m_isOpaque ? WebCore::IOSurface::Format::RGB10 : WebCore::IOSurface::Format::RGB10A8;
 488
 489 return WebCore::IOSurface::Format::RGBA;
 490}
 491#endif // USE(IOSURFACE)
 492
494493} // namespace WebKit

Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.cpp

2727#include "GraphicsLayerCARemote.h"
2828#include "PlatformCAAnimationRemote.h"
2929#include "PlatformCALayerRemote.h"
 30#include <WebCore/PlatformScreen.h>
3031
3132using namespace WebCore;
3233

@@bool GraphicsLayerCARemote::filtersCanBeComposited(const FilterOperations& filte
4344
4445PassRefPtr<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* owner)
4546{
46  return PlatformCALayerRemote::create(layerType, owner, m_context);
 47 auto result = PlatformCALayerRemote::create(layerType, owner, m_context);
 48
 49 if (result->canHaveBackingStore())
 50 result->setWantsDeepColorBackingStore(screenSupportsExtendedColor());
 51
 52 return result;
4753}
4854
4955PassRefPtr<PlatformCALayer> GraphicsLayerCARemote::createPlatformCALayer(PlatformLayer* platformLayer, PlatformCALayerClient* owner)

Source/WebKit2/WebProcess/WebPage/mac/GraphicsLayerCARemote.h

2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424 */
2525
26 #ifndef GraphicsLayerCARemote_h
27 #define GraphicsLayerCARemote_h
 26#pragma once
2827
2928#include <WebCore/GraphicsLayerCA.h>
3029#include <WebCore/PlatformLayer.h>

@@private:
6160} // namespace WebKit
6261
6362SPECIALIZE_TYPE_TRAITS_GRAPHICSLAYER(WebKit::GraphicsLayerCARemote, isGraphicsLayerCARemote())
64 
65 #endif // GraphicsLayerCARemote_h

Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

@@PassRefPtr<PlatformCALayerRemote> PlatformCALayerRemote::create(const PlatformCA
7474
7575PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
7676 : PlatformCALayer(layerType, owner)
77  , m_superlayer(nullptr)
78  , m_maskLayer(nullptr)
79  , m_acceleratesDrawing(false)
8077 , m_context(&context)
8178{
8279 if (owner)

@@PlatformCALayerRemote::PlatformCALayerRemote(LayerType layerType, PlatformCALaye
8582
8683PlatformCALayerRemote::PlatformCALayerRemote(const PlatformCALayerRemote& other, PlatformCALayerClient* owner, RemoteLayerTreeContext& context)
8784 : PlatformCALayer(other.layerType(), owner)
88  , m_superlayer(nullptr)
89  , m_maskLayer(nullptr)
9085 , m_acceleratesDrawing(other.acceleratesDrawing())
9186 , m_context(&context)
9287{

@@void PlatformCALayerRemote::updateBackingStore()
206201 if (!m_properties.backingStore)
207202 return;
208203
209  m_properties.backingStore->ensureBackingStore(m_properties.bounds.size(), m_properties.contentsScale, m_acceleratesDrawing, m_properties.opaque);
 204 m_properties.backingStore->ensureBackingStore(m_properties.bounds.size(), m_properties.contentsScale, m_acceleratesDrawing, m_wantsDeepColorBackingStore, m_properties.opaque);
210205}
211206
212207void PlatformCALayerRemote::setNeedsDisplayInRect(const FloatRect& rect)

@@void PlatformCALayerRemote::setAcceleratesDrawing(bool acceleratesDrawing)
601596 updateBackingStore();
602597}
603598
 599bool PlatformCALayerRemote::wantsDeepColorBackingStore() const
 600{
 601 return m_wantsDeepColorBackingStore;
 602}
 603
 604void PlatformCALayerRemote::setWantsDeepColorBackingStore(bool wantsDeepColorBackingStore)
 605{
 606 m_wantsDeepColorBackingStore = wantsDeepColorBackingStore;
 607 updateBackingStore();
 608}
 609
604610CFTypeRef PlatformCALayerRemote::contents() const
605611{
606612 return nullptr;

Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424 */
2525
26 #ifndef PlatformCALayerRemote_h
27 #define PlatformCALayerRemote_h
 26#pragma once
2827
2928#include "RemoteLayerTreeTransaction.h"
3029#include <WebCore/PlatformCALayer.h>

@@public:
116115 bool acceleratesDrawing() const override;
117116 void setAcceleratesDrawing(bool) override;
118117
 118 bool wantsDeepColorBackingStore() const override;
 119 void setWantsDeepColorBackingStore(bool) override;
 120
119121 CFTypeRef contents() const override;
120122 void setContents(CFTypeRef) override;
121123

@@private:
208210
209211 RemoteLayerTreeTransaction::LayerProperties m_properties;
210212 WebCore::PlatformCALayerList m_children;
211  PlatformCALayerRemote* m_superlayer;
212  PlatformCALayerRemote* m_maskLayer;
 213 PlatformCALayerRemote* m_superlayer { nullptr };
 214 PlatformCALayerRemote* m_maskLayer { nullptr };
213215 HashMap<String, RefPtr<WebCore::PlatformCAAnimation>> m_animations;
214  bool m_acceleratesDrawing;
 216
 217 bool m_acceleratesDrawing { false };
 218 bool m_wantsDeepColorBackingStore { false };
215219
216220 RemoteLayerTreeContext* m_context;
217221};

@@private:
219223} // namespace WebKit
220224
221225SPECIALIZE_TYPE_TRAITS_PLATFORM_CALAYER(WebKit::PlatformCALayerRemote, isPlatformCALayerRemote())
222 
223 #endif // PlatformCALayerRemote_h

Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.cpp

@@void PlatformCALayerRemoteTiledBacking::setAcceleratesDrawing(bool acceleratesDr
8787 m_tileController->setAcceleratesDrawing(acceleratesDrawing);
8888}
8989
 90bool PlatformCALayerRemoteTiledBacking::wantsDeepColorBackingStore() const
 91{
 92 return m_tileController->wantsDeepColorBackingStore();
 93}
 94
 95void PlatformCALayerRemoteTiledBacking::setWantsDeepColorBackingStore(bool wantsDeepColorBackingStore)
 96{
 97 m_tileController->setWantsDeepColorBackingStore(wantsDeepColorBackingStore);
 98}
 99
90100float PlatformCALayerRemoteTiledBacking::contentsScale() const
91101{
92102 return m_tileController->contentsScale();

Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteTiledBacking.h

@@private:
5353
5454 bool acceleratesDrawing() const override;
5555 void setAcceleratesDrawing(bool) override;
 56
 57 bool wantsDeepColorBackingStore() const override;
 58 void setWantsDeepColorBackingStore(bool) override;
5659
5760 float contentsScale() const override;
5861 void setContentsScale(float) override;

LayoutTests/ChangeLog

 12017-02-16 Simon Fraser <simon.fraser@apple.com>
 2
 3 Allow PlatformCALayers to specify that they want deep color backing store
 4 https://bugs.webkit.org/show_bug.cgi?id=168495
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * platform/ios-simulator-wk2/TestExpectations:
 9 * platform/mac-wk2/TestExpectations:
 10 * tiled-drawing/ios/iphone7/compositing-layers-deep-color-expected.txt: Added.
 11 * tiled-drawing/ios/iphone7/compositing-layers-deep-color.html: Added.
 12
1132017-02-16 Ryan Haddad <ryanhaddad@apple.com>
214
315 Mark storage/indexeddb/modern/idbcursor-continue-primary-key-1.html as flaky.

LayoutTests/platform/ios-simulator-wk2/TestExpectations

@@fast/scrolling/ios [ Pass ]
1010fast/viewport/ios [ Pass ]
1111fast/visual-viewport/ios/ [ Pass ]
1212scrollingcoordinator/ios [ Pass ]
 13tiled-drawing/ios [ Pass ]
1314editing/selection/character-granularity-rect.html [ Pass ]
1415
1516fast/media/mq-inverted-colors-live-update.html [ Pass ]

LayoutTests/platform/mac-wk2/TestExpectations

66#//////////////////////////////////////////////////////////////////////////////////////////
77
88tiled-drawing [ Pass ]
 9tiled-drawing/ios [ Skip ]
910fast/visual-viewport/tiled-drawing [ Pass ]
1011swipe [ Pass ]
1112

LayoutTests/tiled-drawing/ios/iphone7/compositing-layers-deep-color-expected.txt

 1Box
 2Box
 3(GraphicsLayer
 4 (anchor 0.00 0.00)
 5 (bounds 5018.00 2018.00)
 6 (deep color 1)
 7 (children 1
 8 (GraphicsLayer
 9 (bounds 5018.00 2018.00)
 10 (contentsOpaque 1)
 11 (tile cache coverage 0, 0 1024 x 1024)
 12 (tile size 512 x 512)
 13 (top left tile 0, 0 tiles grid 2 x 2)
 14 (in window 1)
 15 (deep color 1)
 16 (children 2
 17 (GraphicsLayer
 18 (position 18.00 10.00)
 19 (bounds 100.00 100.00)
 20 (contentsOpaque 1)
 21 (drawsContent 1)
 22 (deep color 1)
 23 )
 24 (GraphicsLayer
 25 (position 18.00 120.00)
 26 (bounds 5000.00 100.00)
 27 (usingTiledLayer 1)
 28 (contentsOpaque 1)
 29 (drawsContent 1)
 30 (tile cache coverage 0, 0 1024 x 100)
 31 (tile size 512 x 512)
 32 (top left tile 0, 0 tiles grid 2 x 1)
 33 (in window 1)
 34 (deep color 1)
 35 )
 36 )
 37 )
 38 )
 39)
 40

LayoutTests/tiled-drawing/ios/iphone7/compositing-layers-deep-color.html

 1<!DOCTYPE html>
 2
 3<html>
 4<head>
 5 <style>
 6 body {
 7 height: 2000px;
 8 }
 9
 10 .box {
 11 height: 100px;
 12 width: 100px;
 13 background-color: blue;
 14 margin: 10px;
 15 }
 16
 17 .composited {
 18 transform: translateZ(0);
 19 }
 20
 21 .tiled {
 22 width: 5000px;
 23 }
 24 </style>
 25 <script>
 26 if (window.testRunner)
 27 testRunner.dumpAsText();
 28
 29 function doTest()
 30 {
 31 if (window.internals) {
 32 document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
 33 }
 34 }
 35 window.addEventListener('load', doTest, false);
 36 </script>
 37</head>
 38<body>
 39
 40<div class="composited box">
 41 Box
 42</div>
 43
 44<div class="tiled composited box">
 45 Box
 46</div>
 47
 48<pre id="layers"></pre>
 49</body>
 50</html>