Changeset 217296 in webkit
- Timestamp:
- May 23, 2017, 1:44:10 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r217293 r217296 1 2017-05-22 Simon Fraser <simon.fraser@apple.com> 2 3 Snapshotting via -renderInContext: should do synchronous image decodes 4 https://bugs.webkit.org/show_bug.cgi?id=172485 5 rdar://problem/32276146 6 7 Reviewed by Tim Horton. 8 9 When UIWebView clients snapshot the view via -renderInContext: on the UIView's layer, 10 WebKit should do synchronous image decodes so that the images show in the snapshot. 11 12 Fix by plumbing through a "snapshotting" paint behavior flag from two source locations: 13 WebSimpleLayer, used by compositing layers, and LegacyTileLayer, used for the WK1 tile cache. 14 On WebSimpleLayer the flag propagates through PlatformCALayer to GraphicsLayer, and on LegacyTileLayer 15 it sets some state on the WAKWindow, which is detected by -[WebFrame _paintBehaviorForDestinationContext:]. 16 In both cases, the flag becomes PaintBehaviorSnapshotting which is passed down through painting 17 in PaintInfo.paintBehavior. 18 19 Fix code that was checking paintBehavior on the FrameView to just looking at PaintInfo.paintBehavior, 20 which required passing PaintInfo along in RenderImage::paintIntoRect(). 21 22 We can't just use the PaintBehaviorFlattenCompositingLayers flag, because that triggers 23 a flattening paint of compositing layers, and we don't want that behavior for -renderInContext:, 24 since CoreAnimation calls -renderInContext: on each of our layers and we need to avoid double-painting. 25 So PaintBehaviorSnapshotting is now added to the call sites that also set PaintBehaviorFlattenCompositingLayers 26 in most cases. 27 28 Tested by SnapshotViaRenderInContext API test. 29 30 * html/shadow/MediaControlElements.cpp: 31 (WebCore::MediaControlTextTrackContainerElement::createTextTrackRepresentationImage): 32 * page/FrameView.cpp: 33 (WebCore::FrameView::willPaintContents): 34 (WebCore::FrameView::paintContentsForSnapshot): 35 * page/PageOverlayController.cpp: 36 (WebCore::PageOverlayController::paintContents): 37 * page/PageOverlayController.h: 38 * page/mac/ServicesOverlayController.h: 39 * page/mac/ServicesOverlayController.mm: 40 (WebCore::ServicesOverlayController::Highlight::paintContents): 41 * platform/graphics/GraphicsLayer.cpp: 42 (WebCore::GraphicsLayer::paintGraphicsLayerContents): 43 * platform/graphics/GraphicsLayer.h: 44 * platform/graphics/GraphicsLayerClient.h: 45 (WebCore::GraphicsLayerClient::paintContents): 46 * platform/graphics/ca/GraphicsLayerCA.cpp: 47 (WebCore::GraphicsLayerCA::recursiveCommitChanges): 48 (WebCore::GraphicsLayerCA::platformCALayerPaintContents): 49 * platform/graphics/ca/GraphicsLayerCA.h: 50 * platform/graphics/ca/PlatformCALayer.h: 51 * platform/graphics/ca/PlatformCALayerClient.h: 52 * platform/graphics/ca/TileCoverageMap.cpp: 53 (WebCore::TileCoverageMap::platformCALayerPaintContents): 54 * platform/graphics/ca/TileCoverageMap.h: 55 * platform/graphics/ca/TileGrid.cpp: 56 (WebCore::TileGrid::platformCALayerPaintContents): 57 * platform/graphics/ca/TileGrid.h: 58 * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: 59 (PlatformCALayer::drawLayerContents): 60 * platform/graphics/mac/WebLayer.mm: 61 (-[WebLayer drawInContext:]): 62 (-[WebSimpleLayer renderInContext:]): 63 (-[WebSimpleLayer drawInContext:]): 64 * platform/ios/LegacyTileCache.h: Use initializers. 65 * platform/ios/LegacyTileCache.mm: 66 (WebCore::LegacyTileCache::LegacyTileCache): 67 (WebCore::LegacyTileCache::drawWindowContent): 68 (WebCore::LegacyTileCache::drawLayer): 69 * platform/ios/LegacyTileLayer.h: 70 * platform/ios/LegacyTileLayer.mm: 71 (-[LegacyTileHostLayer renderInContext:]): 72 (-[LegacyTileLayer renderInContext:]): 73 (-[LegacyTileLayer drawInContext:]): 74 (+[LegacyTileLayer layerBeingPainted]): Deleted. There were no callers. 75 * platform/ios/wak/WAKView.mm: 76 (-[WAKView _drawRect:context:lockFocus:]): bool -> BOOL 77 * platform/ios/wak/WAKWindow.h: 78 * platform/ios/wak/WAKWindow.mm: 79 (-[WAKWindow setIsInSnapshottingPaint:]): 80 (-[WAKWindow isInSnapshottingPaint]): 81 * rendering/PaintPhase.h: 82 * rendering/RenderBox.cpp: 83 (WebCore::RenderBox::paintMaskImages): 84 * rendering/RenderBoxModelObject.cpp: 85 (WebCore::RenderBoxModelObject::paintFillLayerExtended): 86 * rendering/RenderImage.cpp: 87 (WebCore::RenderImage::paintReplaced): 88 (WebCore::RenderImage::paintIntoRect): 89 * rendering/RenderImage.h: 90 * rendering/RenderLayer.cpp: 91 (WebCore::RenderLayer::paintLayerContents): 92 (WebCore::RenderLayer::paintForegroundForFragments): 93 * rendering/RenderLayerBacking.cpp: 94 (WebCore::RenderLayerBacking::paintContents): 95 * rendering/RenderLayerBacking.h: 96 * rendering/RenderLayerCompositor.cpp: 97 (WebCore::RenderLayerCompositor::paintContents): 98 * rendering/RenderLayerCompositor.h: 99 * rendering/RenderVideo.cpp: 100 (WebCore::RenderVideo::paintReplaced): 101 1 102 2017-05-23 Myles C. Maxfield <mmaxfield@apple.com> 2 103 -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r216902 r217296 1403 1403 return nullptr; 1404 1404 1405 layer->paint(buffer->context(), paintingRect, LayoutSize(), PaintBehaviorFlattenCompositingLayers , nullptr, RenderLayer::PaintLayerPaintingCompositingAllPhases);1405 layer->paint(buffer->context(), paintingRect, LayoutSize(), PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting, nullptr, RenderLayer::PaintLayerPaintingCompositingAllPhases); 1406 1406 1407 1407 return ImageBuffer::sinkIntoImage(WTFMove(buffer)); -
trunk/Source/WebCore/page/FrameView.cpp
r217293 r217296 4390 4390 if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers) 4391 4391 m_paintBehavior |= PaintBehaviorFlattenCompositingLayers; 4392 4393 if (parentView->paintBehavior() & PaintBehaviorSnapshotting) 4394 m_paintBehavior |= PaintBehaviorSnapshotting; 4392 4395 } 4393 4396 4394 4397 if (document->printing()) 4395 m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;4398 m_paintBehavior |= (PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting); 4396 4399 4397 4400 paintingState.isFlatteningPaintOfRootFrame = (m_paintBehavior & PaintBehaviorFlattenCompositingLayers) && !frame().ownerElement(); … … 4520 4523 // Cache paint behavior and set a new behavior appropriate for snapshots. 4521 4524 PaintBehavior oldBehavior = paintBehavior(); 4522 setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);4525 setPaintBehavior(oldBehavior | (PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting)); 4523 4526 4524 4527 // If the snapshot should exclude selection, then we'll clear the current selection -
trunk/Source/WebCore/page/PageOverlayController.cpp
r212228 r217296 361 361 } 362 362 363 void PageOverlayController::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect )363 void PageOverlayController::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect, GraphicsLayerPaintFlags) 364 364 { 365 365 for (auto& overlayAndGraphicsLayer : m_overlayGraphicsLayers) { -
trunk/Source/WebCore/page/PageOverlayController.h
r211683 r217296 89 89 // GraphicsLayerClient 90 90 void notifyFlushRequired(const GraphicsLayer*) override; 91 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clipRect ) override;91 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clipRect, GraphicsLayerPaintFlags) override; 92 92 float deviceScaleFactor() const override; 93 93 bool shouldSkipLayerInDump(const GraphicsLayer*, LayerTreeAsTextBehavior) const override; -
trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp
r216902 r217296 86 86 87 87 private: 88 void paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& clip ) override88 void paintContents(const GraphicsLayer*, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& clip, GraphicsLayerPaintFlags) override 89 89 { 90 90 GraphicsContextStateSaver stateSaver(context); -
trunk/Source/WebCore/page/mac/ServicesOverlayController.h
r215152 r217296 83 83 // GraphicsLayerClient 84 84 void notifyFlushRequired(const GraphicsLayer*) override; 85 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& inClip ) override;85 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& inClip, GraphicsLayerPaintFlags) override; 86 86 float deviceScaleFactor() const override; 87 87 -
trunk/Source/WebCore/page/mac/ServicesOverlayController.mm
r215160 r217296 130 130 } 131 131 132 void ServicesOverlayController::Highlight::paintContents(const GraphicsLayer*, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect& )132 void ServicesOverlayController::Highlight::paintContents(const GraphicsLayer*, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect&, GraphicsLayerPaintFlags) 133 133 { 134 134 if (!DataDetectorsLibrary()) -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp
r213466 r217296 418 418 } 419 419 420 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const FloatRect& clip )420 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const FloatRect& clip, GraphicsLayerPaintFlags flags) 421 421 { 422 422 FloatSize offset = offsetFromRenderer(); … … 426 426 clipRect.move(offset); 427 427 428 m_client.paintContents(this, context, m_paintingPhase, clipRect );428 m_client.paintContents(this, context, m_paintingPhase, clipRect, flags); 429 429 } 430 430 -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.h
r215469 r217296 443 443 // Transitions are identified by a special animation name that cannot clash with a keyframe identifier. 444 444 static String animationNameForTransition(AnimatedPropertyID); 445 445 446 446 // Return true if the animation is handled by the compositing system. If this returns 447 447 // false, the animation will be run by CSSAnimationController. … … 453 453 WEBCORE_EXPORT virtual void suspendAnimations(double time); 454 454 WEBCORE_EXPORT virtual void resumeAnimations(); 455 455 456 456 // Layer contents 457 457 virtual void setContentsToImage(Image*) { } … … 466 466 467 467 // Callback from the underlying graphics system to draw layer contents. 468 void paintGraphicsLayerContents(GraphicsContext&, const FloatRect& clip );469 468 void paintGraphicsLayerContents(GraphicsContext&, const FloatRect& clip, GraphicsLayerPaintFlags = GraphicsLayerPaintFlags::None); 469 470 470 // For hosting this GraphicsLayer in a native layer hierarchy. 471 471 virtual PlatformLayer* platformLayer() const { return 0; } 472 472 473 473 enum CompositingCoordinatesOrientation { CompositingCoordinatesTopDown, CompositingCoordinatesBottomUp }; 474 474 -
trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h
r211949 r217296 24 24 */ 25 25 26 #ifndef GraphicsLayerClient_h 27 #define GraphicsLayerClient_h 26 #pragma once 28 27 29 28 #include "IntSize.h" … … 77 76 typedef unsigned LayerTreeAsTextBehavior; 78 77 78 enum class GraphicsLayerPaintFlags { None, Snapshotting }; 79 79 80 class GraphicsLayerClient { 80 81 public: … … 94 95 virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) { } 95 96 96 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& /* inClip */ ) { }97 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& /* inClip */, GraphicsLayerPaintFlags) { } 97 98 virtual void didCommitChangesForLayer(const GraphicsLayer*) const { } 98 99 … … 140 141 } // namespace WebCore 141 142 142 #endif // GraphicsLayerClient_h -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
r212535 r217296 221 221 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { } 222 222 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; } 223 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& ) { }223 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintFlags) { } 224 224 virtual bool platformCALayerShowDebugBorders() const { return false; } 225 225 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; } -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r216702 r217296 1564 1564 } 1565 1565 1566 void GraphicsLayerCA::platformCALayerPaintContents(PlatformCALayer*, GraphicsContext& context, const FloatRect& clip )1566 void GraphicsLayerCA::platformCALayerPaintContents(PlatformCALayer*, GraphicsContext& context, const FloatRect& clip, GraphicsLayerPaintFlags flags) 1567 1567 { 1568 1568 m_hasEverPainted = true; … … 1580 1580 1581 1581 TraceScope tracingScope(PaintLayerStart, PaintLayerEnd); 1582 paintGraphicsLayerContents(context, clip );1582 paintGraphicsLayerContents(context, clip, flags); 1583 1583 } 1584 1584 -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
r216702 r217296 188 188 WEBCORE_EXPORT void platformCALayerAnimationEnded(const String& animationKey) override; 189 189 CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return contentsOrientation(); } 190 WEBCORE_EXPORT void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& clip ) override;190 WEBCORE_EXPORT void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& clip, GraphicsLayerPaintFlags) override; 191 191 bool platformCALayerShowDebugBorders() const override { return isShowingDebugBorder(); } 192 192 WEBCORE_EXPORT bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override; -
trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h
r216448 r217296 278 278 // Functions allows us to share implementation across WebTiledLayer and WebLayer 279 279 static RepaintRectList collectRectsToPaint(CGContextRef, PlatformCALayer*); 280 static void drawLayerContents(CGContextRef, PlatformCALayer*, RepaintRectList& dirtyRects );280 static void drawLayerContents(CGContextRef, PlatformCALayer*, RepaintRectList& dirtyRects, GraphicsLayerPaintFlags); 281 281 static void drawRepaintIndicator(CGContextRef, PlatformCALayer*, int repaintCount, CGColorRef customBackgroundColor); 282 282 static CGRect frameForLayer(const PlatformLayer*); -
trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h
r197541 r217296 24 24 */ 25 25 26 #ifndef PlatformCALayerClient_h 27 #define PlatformCALayerClient_h 26 #pragma once 28 27 29 28 #include "GraphicsLayer.h" … … 45 44 virtual void platformCALayerAnimationEnded(const String& /*animationKey*/) { } 46 45 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesTopDown; } 47 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& inClip ) = 0;46 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& inClip, GraphicsLayerPaintFlags) = 0; 48 47 virtual bool platformCALayerShowDebugBorders() const { return false; } 49 48 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; } … … 73 72 } 74 73 75 #endif // PlatformCALayerClient_h -
trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.cpp
r216448 r217296 153 153 } 154 154 155 void TileCoverageMap::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect& )155 void TileCoverageMap::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&, GraphicsLayerPaintFlags) 156 156 { 157 157 ASSERT_UNUSED(platformCALayer, platformCALayer == m_layer.ptr()); -
trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.h
r208213 r217296 62 62 bool platformCALayerContentsOpaque() const override { return true; } 63 63 bool platformCALayerDrawsContent() const override { return true; } 64 void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& ) override;64 void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintFlags) override; 65 65 float platformCALayerDeviceScaleFactor() const override; 66 66 -
trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp
r216448 r217296 713 713 } 714 714 715 void TileGrid::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect& )715 void TileGrid::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const FloatRect&, GraphicsLayerPaintFlags flags) 716 716 { 717 717 #if PLATFORM(IOS) … … 728 728 729 729 PlatformCALayer::RepaintRectList dirtyRects = PlatformCALayer::collectRectsToPaint(context.platformContext(), platformCALayer); 730 PlatformCALayer::drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects );730 PlatformCALayer::drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects, flags); 731 731 } 732 732 -
trunk/Source/WebCore/platform/graphics/ca/TileGrid.h
r206830 r217296 145 145 146 146 // PlatformCALayerClient 147 void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& ) override;147 void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintFlags) override; 148 148 bool platformCALayerShowDebugBorders() const override; 149 149 bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override; -
trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
r216448 r217296 1113 1113 } 1114 1114 1115 void PlatformCALayer::drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformCALayer, RepaintRectList& dirtyRects )1115 void PlatformCALayer::drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformCALayer, RepaintRectList& dirtyRects, GraphicsLayerPaintFlags flags) 1116 1116 { 1117 1117 WebCore::PlatformCALayerClient* layerContents = platformCALayer->owner(); … … 1160 1160 graphicsContext.clip(rect); 1161 1161 1162 layerContents->platformCALayerPaintContents(platformCALayer, graphicsContext, rect );1162 layerContents->platformCALayerPaintContents(platformCALayer, graphicsContext, rect, flags); 1163 1163 } 1164 1164 -
trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
r216702 r217296 110 110 } 111 111 112 void PlatformCALayer::drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformCALayer, RepaintRectList& )112 void PlatformCALayer::drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformCALayer, RepaintRectList&, GraphicsLayerPaintFlags) 113 113 { 114 114 intern(platformCALayer)->displayCallback(platformCALayer->platformLayer(), context); -
trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
r206830 r217296 105 105 CGRect clipBounds = CGContextGetClipBoundingBox(context); 106 106 IntRect clip(enclosingIntRect(clipBounds)); 107 client->platformCALayerPaintContents(owner(), graphicsContext, clip );107 client->platformCALayerPaintContents(owner(), graphicsContext, clip, GraphicsLayerPaintFlags::None); 108 108 109 109 if (client->platformCALayerShowRepaintCounter(owner()) -
trunk/Source/WebCore/platform/graphics/ca/win/WebTiledBackingLayerWin.cpp
r206830 r217296 96 96 CGRect clipBounds = CGContextGetClipBoundingBox(context); 97 97 IntRect clip(enclosingIntRect(clipBounds)); 98 client->platformCALayerPaintContents(owner(), graphicsContext, clip );98 client->platformCALayerPaintContents(owner(), graphicsContext, clip, GraphicsLayerPaintFlags::None); 99 99 100 100 if (client->platformCALayerShowRepaintCounter(owner())) { -
trunk/Source/WebCore/platform/graphics/mac/WebLayer.h
r169960 r217296 30 30 31 31 #ifdef __OBJC__ 32 @interface WebSimpleLayer : CALayer 32 @interface WebSimpleLayer : CALayer { 33 BOOL _isRenderingInContext; 34 } 35 @property (nonatomic, readonly) BOOL isRenderingInContext; 33 36 @end 34 37 -
trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm
r211305 r217296 31 31 #import "PlatformCALayer.h" 32 32 #import <QuartzCore/QuartzCore.h> 33 #import <wtf/SetForScope.h> 33 34 34 35 #if PLATFORM(IOS) … … 57 58 if (layer) { 58 59 PlatformCALayer::RepaintRectList rectsToPaint = PlatformCALayer::collectRectsToPaint(context, layer); 59 PlatformCALayer::drawLayerContents(context, layer, rectsToPaint );60 PlatformCALayer::drawLayerContents(context, layer, rectsToPaint, self.isRenderingInContext ? GraphicsLayerPaintFlags::Snapshotting : GraphicsLayerPaintFlags::None); 60 61 } 61 62 } … … 64 65 65 66 @implementation WebSimpleLayer 67 68 @synthesize isRenderingInContext = _isRenderingInContext; 69 70 - (void)renderInContext:(CGContextRef)context 71 { 72 SetForScope<BOOL> change(_isRenderingInContext, YES); 73 [super renderInContext:context]; 74 } 66 75 67 76 - (id<CAAction>)actionForKey:(NSString *)key … … 129 138 130 139 FloatRect clipBounds = CGContextGetClipBoundingBox(context); 131 layer->owner()->platformCALayerPaintContents(layer, graphicsContext, clipBounds );140 layer->owner()->platformCALayerPaintContents(layer, graphicsContext, clipBounds, self.isRenderingInContext ? GraphicsLayerPaintFlags::Snapshotting : GraphicsLayerPaintFlags::None); 132 141 } 133 142 } -
trunk/Source/WebCore/platform/ios/LegacyTileCache.h
r208985 r217296 134 134 // Internal 135 135 void doLayoutTiles(); 136 void drawLayer(LegacyTileLayer*, CGContextRef); 136 137 enum class DrawingFlags { None, Snapshotting }; 138 void drawLayer(LegacyTileLayer*, CGContextRef, DrawingFlags); 137 139 void prepareToDraw(); 138 140 void finishedCreatingTiles(bool didCreateTiles, bool createMore); … … 173 175 174 176 void drawReplacementImage(LegacyTileLayer*, CGContextRef, CGImageRef); 175 void drawWindowContent(LegacyTileLayer*, CGContextRef, CGRect dirtyRect );176 177 WAKWindow* m_window ;177 void drawWindowContent(LegacyTileLayer*, CGContextRef, CGRect dirtyRect, DrawingFlags); 178 179 WAKWindow* m_window { nullptr }; 178 180 179 181 RetainPtr<CGImageRef> m_contentReplacementImage; 180 182 181 bool m_keepsZoomedOutTiles;182 183 bool m_hasPendingLayoutTiles;184 bool m_hasPendingUpdateTilingMode;185 183 // Ensure there are no async calls on a dead tile cache. 186 184 RetainPtr<LegacyTileCacheTombstone> m_tombstone; … … 188 186 std::optional<FloatRect> m_overrideVisibleRect; 189 187 190 TilingMode m_tilingMode; 191 TilingDirection m_tilingDirection; 192 193 IntSize m_tileSize; 194 bool m_tilesOpaque; 195 196 bool m_tileBordersVisible; 197 bool m_tilePaintCountersVisible; 198 bool m_acceleratedDrawingEnabled; 199 bool m_isSpeculativeTileCreationEnabled; 200 201 bool m_didCallWillStartScrollingOrZooming; 188 IntSize m_tileSize { 512, 512 }; 189 190 TilingMode m_tilingMode { Normal }; 191 TilingDirection m_tilingDirection { TilingDirectionDown }; 192 193 bool m_keepsZoomedOutTiles { false }; 194 bool m_hasPendingLayoutTiles { false }; 195 bool m_hasPendingUpdateTilingMode { false }; 196 bool m_tilesOpaque { true }; 197 bool m_tileBordersVisible { false }; 198 bool m_tilePaintCountersVisible { false }; 199 bool m_acceleratedDrawingEnabled { false }; 200 bool m_isSpeculativeTileCreationEnabled { true }; 201 bool m_tileControllerShouldUseLowScaleTiles { false }; 202 bool m_didCallWillStartScrollingOrZooming { false }; 203 202 204 std::unique_ptr<LegacyTileGrid> m_zoomedOutTileGrid; 203 205 std::unique_ptr<LegacyTileGrid> m_zoomedInTileGrid; … … 207 209 Vector<IntRect> m_savedDisplayRects; 208 210 209 float m_currentScale ;210 211 float m_pendingScale ;212 float m_pendingZoomedOutScale ;211 float m_currentScale { 1 }; 212 213 float m_pendingScale { 0 }; 214 float m_pendingZoomedOutScale { 0 }; 213 215 214 216 mutable Lock m_tileMutex; 215 217 mutable Lock m_savedDisplayRectMutex; 216 218 mutable Lock m_contentReplacementImageMutex; 217 218 bool m_tileControllerShouldUseLowScaleTiles;219 219 }; 220 220 -
trunk/Source/WebCore/platform/ios/LegacyTileCache.mm
r215160 r217296 71 71 LegacyTileCache::LegacyTileCache(WAKWindow* window) 72 72 : m_window(window) 73 , m_keepsZoomedOutTiles(false)74 , m_hasPendingLayoutTiles(false)75 , m_hasPendingUpdateTilingMode(false)76 73 , m_tombstone(adoptNS([[LegacyTileCacheTombstone alloc] init])) 77 , m_tilingMode(Normal)78 , m_tilingDirection(TilingDirectionDown)79 , m_tileSize(512, 512)80 , m_tilesOpaque(true)81 , m_tileBordersVisible(false)82 , m_tilePaintCountersVisible(false)83 , m_acceleratedDrawingEnabled(false)84 , m_isSpeculativeTileCreationEnabled(true)85 , m_didCallWillStartScrollingOrZooming(false)86 74 , m_zoomedOutTileGrid(std::make_unique<LegacyTileGrid>(*this, m_tileSize)) 87 75 , m_tileCreationTimer(*this, &LegacyTileCache::tileCreationTimerFired) 88 , m_currentScale(1.f)89 , m_pendingScale(0)90 , m_pendingZoomedOutScale(0)91 , m_tileControllerShouldUseLowScaleTiles(false)92 76 { 93 77 [hostLayer() insertSublayer:m_zoomedOutTileGrid->tileHostLayer() atIndex:0]; … … 521 505 } 522 506 523 void LegacyTileCache::drawWindowContent(LegacyTileLayer* layer, CGContextRef context, CGRect dirtyRect )507 void LegacyTileCache::drawWindowContent(LegacyTileLayer* layer, CGContextRef context, CGRect dirtyRect, DrawingFlags drawingFlags) 524 508 { 525 509 CGRect frame = [layer frame]; … … 527 511 fontAntialiasingState.setup([WAKWindow hasLandscapeOrientation]); 528 512 513 if (drawingFlags == DrawingFlags::Snapshotting) 514 [m_window setIsInSnapshottingPaint:YES]; 515 529 516 CGSRegionObj drawRegion = (CGSRegionObj)[layer regionBeingDrawn]; 530 517 CGFloat contentsScale = [layer contentsScale]; 518 531 519 if (drawRegion && shouldRepaintInPieces(dirtyRect, drawRegion, contentsScale)) { 532 520 // Use fine grained repaint rectangles to minimize the amount of painted pixels. … … 551 539 552 540 fontAntialiasingState.restore(); 553 } 554 555 void LegacyTileCache::drawLayer(LegacyTileLayer* layer, CGContextRef context) 541 542 if (drawingFlags == DrawingFlags::Snapshotting) 543 [m_window setIsInSnapshottingPaint:NO]; 544 } 545 546 void LegacyTileCache::drawLayer(LegacyTileLayer* layer, CGContextRef context, DrawingFlags drawingFlags) 556 547 { 557 548 // The web lock unlock observer runs after CA commit observer. … … 572 563 drawReplacementImage(layer, context, contentReplacementImage.get()); 573 564 else 574 drawWindowContent(layer, context, dirtyRect );565 drawWindowContent(layer, context, dirtyRect, drawingFlags); 575 566 576 567 ++layer.paintCount; -
trunk/Source/WebCore/platform/ios/LegacyTileLayer.h
r166529 r217296 24 24 */ 25 25 26 #ifndef LegacyTileLayer_h 27 #define LegacyTileLayer_h 26 #pragma once 28 27 29 28 #if PLATFORM(IOS) … … 38 37 WebCore::LegacyTileGrid* _tileGrid; 39 38 unsigned _paintCount; 39 BOOL _isRenderingInContext; 40 40 } 41 41 @property (nonatomic) unsigned paintCount; 42 42 @property (nonatomic) WebCore::LegacyTileGrid* tileGrid; 43 + (LegacyTileLayer *)layerBeingPainted;43 @property (nonatomic, readonly) BOOL isRenderingInContext; 44 44 @end 45 45 … … 51 51 52 52 #endif // PLATFORM(IOS) 53 #endif // TileLayer_h 53 -
trunk/Source/WebCore/platform/ios/LegacyTileLayer.mm
r208985 r217296 32 32 #include "LegacyTileGrid.h" 33 33 #include "WebCoreThread.h" 34 #include <wtf/SetForScope.h> 34 35 35 36 using namespace WebCore; … … 72 73 @synthesize paintCount = _paintCount; 73 74 @synthesize tileGrid = _tileGrid; 74 75 static LegacyTileLayer *layerBeingPainted; 75 @synthesize isRenderingInContext = _isRenderingInContext; 76 76 77 77 - (void)setNeedsDisplayInRect:(CGRect)rect … … 94 94 } 95 95 96 - (void)renderInContext:(CGContextRef)context 97 { 98 SetForScope<BOOL> change(_isRenderingInContext, YES); 99 [super renderInContext:context]; 100 } 101 96 102 - (void)drawInContext:(CGContextRef)context 97 103 { … … 106 112 107 113 if (_tileGrid) 108 _tileGrid->tileCache().drawLayer(self, context );114 _tileGrid->tileCache().drawLayer(self, context, self.isRenderingInContext ? LegacyTileCache::DrawingFlags::Snapshotting : LegacyTileCache::DrawingFlags::None); 109 115 } 110 116 … … 116 122 } 117 123 118 + (LegacyTileLayer *)layerBeingPainted119 {120 return layerBeingPainted;121 }122 123 124 @end 124 125 -
trunk/Source/WebCore/platform/ios/wak/WAKView.mm
r211878 r217296 506 506 } 507 507 508 - (void)_drawRect:(NSRect)dirtyRect context:(CGContextRef)context lockFocus:( bool)lockFocus508 - (void)_drawRect:(NSRect)dirtyRect context:(CGContextRef)context lockFocus:(BOOL)lockFocus 509 509 { 510 510 if (_isHidden) -
trunk/Source/WebCore/platform/ios/wak/WAKWindow.h
r191484 r217296 85 85 86 86 BOOL _visible; 87 BOOL _isInSnapshottingPaint; 87 88 BOOL _useOrientationDependentFontAntialiasing; 88 89 BOOL _entireWindowVisibleForTesting; … … 131 132 - (void)sendEventSynchronously:(WebEvent *)anEvent; 132 133 - (void)sendMouseMoveEvent:(WebEvent *)anEvent contentChange:(WKContentChange *)aContentChange; 134 135 - (void)setIsInSnapshottingPaint:(BOOL)isInSnapshottingPaint; 136 - (BOOL)isInSnapshottingPaint; 133 137 134 138 // Thread safe way of providing the "usable" rect of the WAKWindow in the viewport/scrollview. -
trunk/Source/WebCore/platform/ios/wak/WAKWindow.mm
r191904 r217296 439 439 } 440 440 441 - (void)setIsInSnapshottingPaint:(BOOL)isInSnapshottingPaint 442 { 443 _isInSnapshottingPaint = isInSnapshottingPaint; 444 } 445 446 - (BOOL)isInSnapshottingPaint 447 { 448 return _isInSnapshottingPaint; 449 } 450 441 451 - (void)setEntireWindowVisibleForTesting:(BOOL)entireWindowVisible 442 452 { -
trunk/Source/WebCore/rendering/PaintPhase.h
r213614 r217296 59 59 PaintBehaviorForceBlackText = 1 << 2, 60 60 PaintBehaviorForceWhiteText = 1 << 3, 61 PaintBehaviorFlattenCompositingLayers = 1 << 4, 62 PaintBehaviorRenderingSVGMask = 1 << 5, 63 PaintBehaviorSkipRootBackground = 1 << 6, 64 PaintBehaviorRootBackgroundOnly = 1 << 7, 65 PaintBehaviorSelectionAndBackgroundsOnly = 1 << 8, 66 PaintBehaviorExcludeSelection = 1 << 9, 61 PaintBehaviorRenderingSVGMask = 1 << 4, 62 PaintBehaviorSkipRootBackground = 1 << 5, 63 PaintBehaviorRootBackgroundOnly = 1 << 6, 64 PaintBehaviorSelectionAndBackgroundsOnly = 1 << 7, 65 PaintBehaviorExcludeSelection = 1 << 8, 66 PaintBehaviorFlattenCompositingLayers = 1 << 9, // Paint doesn't stop at compositing layer boundaries. 67 PaintBehaviorSnapshotting = 1 << 10, // Indicates snapshotting, e.g. force synchronous image decoding. 67 68 }; 68 69 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r214173 r217296 1613 1613 bool pushTransparencyLayer = false; 1614 1614 bool compositedMask = hasLayer() && layer()->hasCompositedMask(); 1615 bool flattenCompositingLayers = view().frameView().paintBehavior()& PaintBehaviorFlattenCompositingLayers;1615 bool flattenCompositingLayers = paintInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers; 1616 1616 CompositeOperator compositeOp = CompositeSourceOver; 1617 1617 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r216135 r217296 883 883 884 884 auto interpolation = chooseInterpolationQuality(context, *image, &bgLayer, geometry.tileSize()); 885 auto decodingMode = ( view().frameView().paintBehavior() & PaintBehaviorFlattenCompositingLayers) ? DecodingMode::Synchronous : DecodingMode::Asynchronous;885 auto decodingMode = (paintInfo.paintBehavior & (PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting)) ? DecodingMode::Synchronous : DecodingMode::Asynchronous; 886 886 context.drawTiledImage(*image, geometry.destRect(), toLayoutPoint(geometry.relativePhase()), geometry.tileSize(), geometry.spaceSize(), ImagePaintingOptions(compositeOp, bgLayer.blendMode(), decodingMode, ImageOrientationDescription(), interpolation)); 887 887 } -
trunk/Source/WebCore/rendering/RenderImage.cpp
r216728 r217296 476 476 context.clip(contentBoxRect); 477 477 478 paintIntoRect( context, snapRectToDevicePixels(replacedContentRect, deviceScaleFactor));478 paintIntoRect(paintInfo, snapRectToDevicePixels(replacedContentRect, deviceScaleFactor)); 479 479 480 480 if (cachedImage() && paintInfo.phase == PaintPhaseForeground) { … … 560 560 } 561 561 562 void RenderImage::paintIntoRect( GraphicsContext& context, const FloatRect& rect)562 void RenderImage::paintIntoRect(PaintInfo& paintInfo, const FloatRect& rect) 563 563 { 564 564 if (!imageResource().cachedImage() || imageResource().errorOccurred() || rect.width() <= 0 || rect.height() <= 0) … … 574 574 // FIXME: Document when image != img.get(). 575 575 Image* image = imageResource().image().get(); 576 InterpolationQuality interpolation = image ? chooseInterpolationQuality( context, *image, image, LayoutSize(rect.size())) : InterpolationDefault;576 InterpolationQuality interpolation = image ? chooseInterpolationQuality(paintInfo.context(), *image, image, LayoutSize(rect.size())) : InterpolationDefault; 577 577 578 578 #if USE(CG) … … 585 585 586 586 ImageOrientationDescription orientationDescription(shouldRespectImageOrientation(), style().imageOrientation()); 587 auto decodingMode = (view().frameView().paintBehavior() & PaintBehaviorFlattenCompositingLayers) ? DecodingMode::Synchronous : DecodingMode::Asynchronous; 588 context.drawImage(*img, rect, ImagePaintingOptions(compositeOperator, BlendModeNormal, decodingMode, orientationDescription, interpolation)); 587 588 auto decodingMode = (paintInfo.paintBehavior & (PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting)) ? DecodingMode::Synchronous : DecodingMode::Asynchronous; 589 paintInfo.context().drawImage(*img, rect, ImagePaintingOptions(compositeOperator, BlendModeNormal, decodingMode, orientationDescription, interpolation)); 589 590 } 590 591 -
trunk/Source/WebCore/rendering/RenderImage.h
r214173 r217296 89 89 void imageChanged(WrappedImagePtr, const IntRect* = nullptr) override; 90 90 91 void paintIntoRect( GraphicsContext&, const FloatRect&);91 void paintIntoRect(PaintInfo&, const FloatRect&); 92 92 void paint(PaintInfo&, const LayoutPoint&) final; 93 93 void layout() override; -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r217084 r217296 4384 4384 paintBehavior |= PaintBehaviorRootBackgroundOnly; 4385 4385 4386 if (paintingInfo.paintBehavior & PaintBehaviorSnapshotting) 4387 paintBehavior |= PaintBehaviorSnapshotting; 4388 4386 4389 if (paintingInfo.paintBehavior & PaintBehaviorExcludeSelection) 4387 4390 paintBehavior |= PaintBehaviorExcludeSelection; … … 4786 4789 localPaintBehavior |= PaintBehaviorExcludeSelection; 4787 4790 4791 if (localPaintingInfo.paintBehavior & PaintBehaviorSnapshotting) 4792 localPaintBehavior |= PaintBehaviorSnapshotting; 4793 4788 4794 // Optimize clipping for the single fragment case. 4789 4795 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && layerFragments[0].shouldPaintContent && !layerFragments[0].foregroundRect.isEmpty(); -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r216688 r217296 2546 2546 2547 2547 // Up-call from compositing layer drawing callback. 2548 void RenderLayerBacking::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase paintingPhase, const FloatRect& clip )2548 void RenderLayerBacking::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase paintingPhase, const FloatRect& clip, GraphicsLayerPaintFlags flags) 2549 2549 { 2550 2550 #ifndef NDEBUG … … 2569 2569 2570 2570 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 2571 paintIntoLayer(graphicsLayer, context, dirtyRect, PaintBehaviorNormal, paintingPhase); 2571 PaintBehavior behavior = PaintBehaviorNormal; 2572 if (flags == GraphicsLayerPaintFlags::Snapshotting) 2573 behavior |= PaintBehaviorSnapshotting; 2574 2575 paintIntoLayer(graphicsLayer, context, dirtyRect, behavior, paintingPhase); 2572 2576 2573 2577 InspectorInstrumentation::didPaint(renderer(), dirtyRect); -
trunk/Source/WebCore/rendering/RenderLayerBacking.h
r213466 r217296 198 198 void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) override; 199 199 200 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clip ) override;200 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clip, GraphicsLayerPaintFlags) override; 201 201 202 202 float deviceScaleFactor() const override; -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r216688 r217296 2864 2864 } 2865 2865 2866 void RenderLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& clip )2866 void RenderLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& clip, GraphicsLayerPaintFlags) 2867 2867 { 2868 2868 IntRect pixelSnappedRectForIntegralPositionedItems = snappedIntRect(LayoutRect(clip)); -
trunk/Source/WebCore/rendering/RenderLayerCompositor.h
r215759 r217296 333 333 // GraphicsLayerClient implementation 334 334 void notifyFlushRequired(const GraphicsLayer*) override; 335 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& ) override;335 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect&, GraphicsLayerPaintFlags) override; 336 336 void customPositionForVisibleRectComputation(const GraphicsLayer*, FloatPoint&) const override; 337 337 bool isTrackingRepaints() const override; -
trunk/Source/WebCore/rendering/RenderVideo.cpp
r216766 r217296 199 199 200 200 if (displayingPoster) 201 paintIntoRect( context, rect);201 paintIntoRect(paintInfo, rect); 202 202 else if (!videoElement().isFullscreen() || !mediaPlayer->supportsAcceleratedRendering()) { 203 if ( view().frameView().paintBehavior()& PaintBehaviorFlattenCompositingLayers)203 if (paintInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) 204 204 mediaPlayer->paintCurrentFrameInContext(context, rect); 205 205 else -
trunk/Source/WebKit/mac/ChangeLog
r217293 r217296 1 2017-05-22 Simon Fraser <simon.fraser@apple.com> 2 3 Snapshotting via -renderInContext: should do synchronous image decodes 4 https://bugs.webkit.org/show_bug.cgi?id=172485 5 rdar://problem/32276146 6 7 Reviewed by Tim Horton. 8 9 Remove the _setIncludesFlattenedCompositingLayersWhenDrawingToBitmap: SPI that no longer 10 has any callers. 11 12 * Plugins/WebBaseNetscapePluginView.h: 13 * Plugins/WebBaseNetscapePluginView.mm: 14 (-[WebBaseNetscapePluginView inFlatteningPaint]): Deleted. 15 * WebView/WebFrame.mm: 16 (-[WebFrame _paintBehaviorForDestinationContext:]): 17 (-[WebFrame _drawRect:contentsOnly:]): 18 (-[WebFrame _shouldFlattenCompositingLayers:]): Deleted. 19 * WebView/WebHTMLView.mm: 20 (imageFromRect): 21 * WebView/WebView.mm: 22 (-[WebView _commonInitializationWithFrameName:groupName:]): 23 (-[WebView _setIncludesFlattenedCompositingLayersWhenDrawingToBitmap:]): Deleted. 24 (-[WebView _includesFlattenedCompositingLayersWhenDrawingToBitmap]): Deleted. 25 * WebView/WebViewData.h: 26 * WebView/WebViewPrivate.h: 27 1 28 2017-05-23 Myles C. Maxfield <mmaxfield@apple.com> 2 29 -
trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.h
r216816 r217296 113 113 - (void)removeWindowObservers; 114 114 - (BOOL)shouldClipOutPlugin; 115 - (BOOL)inFlatteningPaint;116 115 117 116 - (BOOL)supportsSnapshotting; -
trunk/Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
r216816 r217296 437 437 NSWindow *window = [self window]; 438 438 return !window || [window isMiniaturized] || [NSApp isHidden] || ![self isDescendantOf:[[self window] contentView]] || [self isHiddenOrHasHiddenAncestor]; 439 }440 441 - (BOOL)inFlatteningPaint442 {443 auto* renderer = _element->renderer();444 if (!is<RenderEmbeddedObject>(renderer))445 return NO;446 return !!(downcast<RenderEmbeddedObject>(*renderer).view().frameView().paintBehavior() & PaintBehaviorFlattenCompositingLayers);447 439 } 448 440 -
trunk/Source/WebKit/mac/WebView/WebFrame.mm
r216816 r217296 121 121 #import <WebCore/TextResourceDecoder.h> 122 122 #import <WebCore/WAKScrollView.h> 123 #import <WebCore/WAKWindow.h> 123 124 #import <WebCore/WKGraphics.h> 124 125 #import <WebCore/WebCoreThreadRun.h> … … 583 584 } 584 585 585 - (BOOL)_shouldFlattenCompositingLayers:(CGContextRef)context 586 587 - (PaintBehavior)_paintBehaviorForDestinationContext:(CGContextRef)context 586 588 { 587 589 #if !PLATFORM(IOS) … … 589 591 BOOL isPrinting = ![NSGraphicsContext currentContextDrawingToScreen]; 590 592 if (isPrinting) 591 return YES;593 return PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting; 592 594 #endif 593 595 594 596 if (!WKCGContextIsBitmapContext(context)) 595 return NO;597 return 0; 596 598 597 599 // If we're drawing into a bitmap, we might be snapshotting, or drawing into a layer-backed view. 598 600 id documentView = [_private->webFrameView documentView]; 599 if ([documentView isKindOfClass:[WebHTMLView class]] && [(WebHTMLView *)documentView _web_isDrawingIntoLayer]) 600 return NO; 601 602 return [getWebView(self) _includesFlattenedCompositingLayersWhenDrawingToBitmap]; 601 if ([documentView isKindOfClass:[WebHTMLView class]]) { 602 #if PLATFORM(IOS) 603 if ([[documentView window] isInSnapshottingPaint]) 604 return PaintBehaviorSnapshotting; 605 #endif 606 if ([(WebHTMLView *)documentView _web_isDrawingIntoLayer]) 607 return 0; 608 } 609 610 return PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting; 603 611 } 604 612 … … 623 631 FrameView* view = _private->coreFrame->view(); 624 632 625 bool shouldFlatten = false; 633 PaintBehavior oldBehavior = view->paintBehavior(); 634 PaintBehavior paintBehavior = oldBehavior; 635 626 636 if (Frame* parentFrame = _private->coreFrame->tree().parent()) { 627 637 // For subframes, we need to inherit the paint behavior from our parent 628 FrameView* parentView = parentFrame ? parentFrame->view() : 0; 629 if (parentView) 630 shouldFlatten = parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers; 638 if (FrameView* parentView = parentFrame ? parentFrame->view() : nullptr) { 639 if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers) 640 paintBehavior |= PaintBehaviorFlattenCompositingLayers; 641 642 if (parentView->paintBehavior() & PaintBehaviorSnapshotting) 643 paintBehavior |= PaintBehaviorSnapshotting; 644 } 631 645 } else 632 shouldFlatten = [self _shouldFlattenCompositingLayers:ctx]; 633 634 PaintBehavior oldBehavior = PaintBehaviorNormal; 635 if (shouldFlatten) { 636 oldBehavior = view->paintBehavior(); 637 view->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers); 638 } 639 646 paintBehavior |= [self _paintBehaviorForDestinationContext:ctx]; 647 648 view->setPaintBehavior(paintBehavior); 649 640 650 if (contentsOnly) 641 651 view->paintContents(context, enclosingIntRect(rect)); … … 643 653 view->paint(context, enclosingIntRect(rect)); 644 654 645 if (shouldFlatten) 646 view->setPaintBehavior(oldBehavior); 655 view->setPaintBehavior(oldBehavior); 647 656 } 648 657 -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r216816 r217296 7298 7298 7299 7299 PaintBehavior oldPaintBehavior = frame->view()->paintBehavior(); 7300 frame->view()->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers );7301 7300 frame->view()->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting); 7301 7302 7302 BEGIN_BLOCK_OBJC_EXCEPTIONS; 7303 7303 -
trunk/Source/WebKit/mac/WebView/WebView.mm
r217273 r217296 1370 1370 _private->backgroundColor = CGColorRetain(cachedCGColor(Color::white)); 1371 1371 #endif 1372 _private->includesFlattenedCompositingLayersWhenDrawingToBitmap = YES;1373 1372 1374 1373 #if PLATFORM(MAC) … … 4503 4502 4504 4503 return YES; 4505 }4506 4507 - (void)_setIncludesFlattenedCompositingLayersWhenDrawingToBitmap:(BOOL)flag4508 {4509 _private->includesFlattenedCompositingLayersWhenDrawingToBitmap = flag;4510 }4511 4512 - (BOOL)_includesFlattenedCompositingLayersWhenDrawingToBitmap4513 {4514 return _private->includesFlattenedCompositingLayersWhenDrawingToBitmap;4515 4504 } 4516 4505 -
trunk/Source/WebKit/mac/WebView/WebViewData.h
r216816 r217296 308 308 BOOL shouldUpdateWhileOffscreen; 309 309 310 BOOL includesFlattenedCompositingLayersWhenDrawingToBitmap;311 312 310 // When this flag is set, next time a WebHTMLView draws, it needs to temporarily disable screen updates 313 311 // so that the NSView drawing is visually synchronized with CALayer updates. -
trunk/Source/WebKit/mac/WebView/WebViewPrivate.h
r215866 r217296 766 766 // Returns YES if NSView -displayRectIgnoringOpacity:inContext: will produce a faithful representation of the content. 767 767 - (BOOL)_isSoftwareRenderable; 768 // When drawing into a bitmap context, we normally flatten compositing layers (and distort 3D transforms).769 // Clients who are able to capture their own copy of the compositing layers need to be able to disable this.770 - (void)_setIncludesFlattenedCompositingLayersWhenDrawingToBitmap:(BOOL)flag;771 - (BOOL)_includesFlattenedCompositingLayersWhenDrawingToBitmap;772 768 773 769 - (void)setTracksRepaints:(BOOL)flag; -
trunk/Source/WebKit/win/FullscreenVideoController.cpp
r216702 r217296 188 188 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { } 189 189 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; } 190 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& ) { }190 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintFlags) { } 191 191 virtual bool platformCALayerShowDebugBorders() const { return false; } 192 192 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; } -
trunk/Source/WebKit2/ChangeLog
r217293 r217296 1 2017-05-22 Simon Fraser <simon.fraser@apple.com> 2 3 Snapshotting via -renderInContext: should do synchronous image decodes 4 https://bugs.webkit.org/show_bug.cgi?id=172485 5 rdar://problem/32276146 6 7 Reviewed by Tim Horton. 8 9 Pass the PaintBehaviorSnapshotting flag in functions that do snapshotting. 10 11 * Shared/mac/RemoteLayerBackingStore.mm: 12 (WebKit::RemoteLayerBackingStore::drawInContext): 13 * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp: 14 (WebKit::imageForRect): 15 * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp: 16 (WebKit::InjectedBundleRangeHandle::renderedImage): 17 1 18 2017-05-23 Myles C. Maxfield <mmaxfield@apple.com> 2 19 -
trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm
r213940 r217296 341 341 case PlatformCALayer::LayerTypeSimpleLayer: 342 342 case PlatformCALayer::LayerTypeTiledBackingTileLayer: 343 m_layer->owner()->platformCALayerPaintContents(m_layer, context, dirtyBounds );343 m_layer->owner()->platformCALayerPaintContents(m_layer, context, dirtyBounds, GraphicsLayerPaintFlags::None); 344 344 break; 345 345 case PlatformCALayer::LayerTypeWebLayer: 346 346 case PlatformCALayer::LayerTypeBackdropLayer: 347 PlatformCALayer::drawLayerContents(cgContext, m_layer, m_paintingRects );347 PlatformCALayer::drawLayerContents(cgContext, m_layer, m_paintingRects, GraphicsLayerPaintFlags::None); 348 348 break; 349 349 case PlatformCALayer::LayerTypeDarkSystemBackdropLayer: … … 351 351 // FIXME: These have a more complicated layer hierarchy. We need to paint into 352 352 // a child layer in order to see the rendered results. 353 PlatformCALayer::drawLayerContents(cgContext, m_layer, m_paintingRects );353 PlatformCALayer::drawLayerContents(cgContext, m_layer, m_paintingRects, GraphicsLayerPaintFlags::None); 354 354 break; 355 355 case PlatformCALayer::LayerTypeLayer: -
trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp
r216185 r217296 170 170 shouldPaintSelection = FrameView::ExcludeSelection; 171 171 172 PaintBehavior paintBehavior = frameView->paintBehavior() | PaintBehaviorFlattenCompositingLayers;172 PaintBehavior paintBehavior = frameView->paintBehavior() | (PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting); 173 173 if (options & SnapshotOptionsForceBlackText) 174 174 paintBehavior |= PaintBehaviorForceBlackText; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
r216810 r217296 144 144 145 145 PaintBehavior oldPaintBehavior = frameView->paintBehavior(); 146 PaintBehavior paintBehavior = oldPaintBehavior | PaintBehaviorSelectionOnly | PaintBehaviorFlattenCompositingLayers ;146 PaintBehavior paintBehavior = oldPaintBehavior | PaintBehaviorSelectionOnly | PaintBehaviorFlattenCompositingLayers | PaintBehaviorSnapshotting; 147 147 if (options & SnapshotOptionsForceBlackText) 148 148 paintBehavior |= PaintBehaviorForceBlackText; -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
r217214 r217296 269 269 } 270 270 271 void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect& clipRect )271 void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect& clipRect, GraphicsLayerPaintFlags) 272 272 { 273 273 m_client.paintLayerContents(graphicsLayer, graphicsContext, enclosingIntRect(clipRect)); -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h
r217214 r217296 100 100 void notifyAnimationStarted(const WebCore::GraphicsLayer*, const String&, double time) override; 101 101 void notifyFlushRequired(const WebCore::GraphicsLayer*) override; 102 void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect ) override;102 void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::FloatRect& clipRect, WebCore::GraphicsLayerPaintFlags) override; 103 103 float deviceScaleFactor() const override; 104 104 float pageScaleFactor() const override; -
trunk/Tools/ChangeLog
r217293 r217296 1 2017-05-22 Simon Fraser <simon.fraser@apple.com> 2 3 Snapshotting via -renderInContext: should do synchronous image decodes 4 https://bugs.webkit.org/show_bug.cgi?id=172485 5 rdar://problem/32276146 6 7 Reviewed by Tim Horton. 8 9 New API test. 10 11 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 12 * TestWebKitAPI/Tests/WebKit/ios/SnapshotViaRenderInContext.mm: Added. 13 (-[RenderInContextWebViewDelegate webViewDidFinishLoad:]): 14 (-[RenderInContextWebViewDelegate webView:didFailLoadWithError:]): 15 (TestWebKitAPI::getPixelIndex): 16 (TestWebKitAPI::TEST): 17 1 18 2017-05-23 Myles C. Maxfield <mmaxfield@apple.com> 2 19 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r217152 r217296 34 34 0F2C20B81DCD545000542D9E /* Time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2C20B71DCD544800542D9E /* Time.cpp */; }; 35 35 0F3B94A71A77267400DE3272 /* WKWebViewEvaluateJavaScript.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */; }; 36 0F4FFA9E1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F4FFA9D1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm */; }; 36 37 1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A02C84B125D4A5E00E3F4BD /* find.html */; }; 37 38 1A3524AE1D63A4FB0031729B /* Scope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3524AC1D63A4FB0031729B /* Scope.cpp */; }; … … 901 902 0F2C20B71DCD544800542D9E /* Time.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Time.cpp; sourceTree = "<group>"; }; 902 903 0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewEvaluateJavaScript.mm; sourceTree = "<group>"; }; 904 0F4FFA9D1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SnapshotViaRenderInContext.mm; sourceTree = "<group>"; }; 905 0F4FFAA01ED3D0DE00F7111F /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; 903 906 0FC6C4CB141027E0005B7F0C /* RedBlackTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RedBlackTree.cpp; sourceTree = "<group>"; }; 904 907 0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MetaAllocator.cpp; sourceTree = "<group>"; }; … … 1871 1874 isa = PBXGroup; 1872 1875 children = ( 1876 0F4FFAA01ED3D0DE00F7111F /* ImageIO.framework */, 1873 1877 634910DF1E9D3FF300880309 /* CoreLocation.framework */, 1874 1878 7A010BCA1D877C0500EDE72A /* CoreGraphics.framework */, … … 2521 2525 CDC8E49A1BC728FE00594FEC /* Resources */, 2522 2526 CDC8E4851BC5B19400594FEC /* AudioSessionCategoryIOS.mm */, 2527 0F4FFA9D1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm */, 2523 2528 ); 2524 2529 path = ios; … … 3046 3051 CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */, 3047 3052 7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */, 3053 0F4FFA9E1ED3AA8500F7111F /* SnapshotViaRenderInContext.mm in Sources */, 3048 3054 7CCE7ED31A411A7E00447C4C /* TypingStyleCrash.mm in Sources */, 3049 3055 7CCE7EDE1A411A9200447C4C /* URL.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.