Changeset 287967 in webkit
- Timestamp:
- Jan 12, 2022, 6:17:09 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 10 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Headers.cmake (modified) (1 diff)
-
WebCore/platform/TextureMapper.cmake (modified) (1 diff)
-
WebCore/platform/graphics/texmap/TextureMapperSparseBackingStore.cpp (added)
-
WebCore/platform/graphics/texmap/TextureMapperSparseBackingStore.h (added)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/GPUProcess/graphics/wc/WCScene.cpp (modified) (4 diffs)
-
WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp (modified) (9 diffs)
-
WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h (modified) (2 diffs)
-
WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp (modified) (11 diffs)
-
WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h (modified) (3 diffs)
-
WebKit/WebProcess/WebPage/wc/WCUpateInfo.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287959 r287967 1 2022-01-12 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [WinCairo] Tiling scroll support 4 https://bugs.webkit.org/show_bug.cgi?id=233676 5 6 Reviewed by Don Olmstead. 7 8 Added a new class TextureMapperSparseBackingStore that supports 9 partially tiling the layer and removing tiles outside of the 10 coverage rect. 11 12 * Headers.cmake: 13 * platform/TextureMapper.cmake: 14 * platform/graphics/texmap/TextureMapperSparseBackingStore.cpp: Added. 15 (WebCore::TextureMapperSparseBackingStore::TextureMapperSparseBackingStore): 16 (WebCore::TextureMapperSparseBackingStore::setSize): 17 (WebCore::TextureMapperSparseBackingStore::removeUncoveredTiles): 18 (WebCore::TextureMapperSparseBackingStore::adjustedTransformForRect): 19 (WebCore::TextureMapperSparseBackingStore::paintToTextureMapper): 20 (WebCore::TextureMapperSparseBackingStore::drawBorder): 21 (WebCore::TextureMapperSparseBackingStore::drawRepaintCounter): 22 (WebCore::TextureMapperSparseBackingStore::tileDimension const): 23 (WebCore::TextureMapperSparseBackingStore::updateContents): 24 * platform/graphics/texmap/TextureMapperSparseBackingStore.h: Added. 25 1 26 2022-01-12 Megan Gardner <megan_gardner@apple.com> 2 27 -
trunk/Source/WebCore/Headers.cmake
r287782 r287967 1646 1646 platform/graphics/transforms/TransformOperation.h 1647 1647 platform/graphics/transforms/TransformOperations.h 1648 platform/graphics/transforms/TransformState.h 1648 1649 platform/graphics/transforms/TransformationMatrix.h 1649 1650 platform/graphics/transforms/TranslateTransformOperation.h -
trunk/Source/WebCore/platform/TextureMapper.cmake
r286205 r287967 130 130 ) 131 131 endif () 132 133 if (USE_GRAPHICS_LAYER_WC) 134 list(APPEND WebCore_SOURCES 135 platform/graphics/texmap/TextureMapperSparseBackingStore.cpp 136 ) 137 list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS 138 platform/graphics/texmap/TextureMapperSparseBackingStore.h 139 ) 140 endif () -
trunk/Source/WebKit/ChangeLog
r287964 r287967 1 2022-01-12 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [WinCairo] Tiling scroll support 4 https://bugs.webkit.org/show_bug.cgi?id=233676 5 6 Reviewed by Don Olmstead. 7 8 Added a new class WCTiledBacking that implements TiledBacking. 9 10 Copied computeVisibleAndCoverageRect, 11 transformByApplyingAnchorPoint and layerTransform from 12 GraphicsLayerAC. 13 14 * GPUProcess/graphics/wc/WCScene.cpp: 15 (WebKit::WCScene::update): 16 * WebProcess/WebPage/wc/DrawingAreaWC.cpp: 17 (WebKit::DrawingAreaWC::DrawingAreaWC): 18 (WebKit::DrawingAreaWC::updatePreferences): 19 (WebKit::DrawingAreaWC::shouldUseTiledBackingForFrameView const): 20 (WebKit::DrawingAreaWC::setNeedsDisplayInRect): 21 (WebKit::DrawingAreaWC::scroll): 22 (WebKit::flushLayerImageBuffers): 23 (WebKit::DrawingAreaWC::sendUpdateAC): 24 (WebKit::DrawingAreaWC::RootLayerClient::RootLayerClient): Deleted. 25 (WebKit::DrawingAreaWC::RootLayerClient::paintContents): Deleted. 26 (WebKit::DrawingAreaWC::RootLayerClient::deviceScaleFactor const): Deleted. 27 * WebProcess/WebPage/wc/DrawingAreaWC.h: 28 * WebProcess/WebPage/wc/GraphicsLayerWC.cpp: 29 (WebKit::GraphicsLayerWC::GraphicsLayerWC): 30 (WebKit::GraphicsLayerWC::setNeedsDisplay): 31 (WebKit::GraphicsLayerWC::setNeedsDisplayInRect): 32 (WebKit::GraphicsLayerWC::setBackgroundColor): 33 (WebKit::GraphicsLayerWC::setDrawsContent): 34 (WebKit::GraphicsLayerWC::noteLayerPropertyChanged): 35 (WebKit::GraphicsLayerWC::flushCompositingState): 36 (WebKit::GraphicsLayerWC::flushCompositingStateForThisLayerOnly): 37 (WebKit::GraphicsLayerWC::tiledBacking const): 38 (WebKit::GraphicsLayerWC::createImageBuffer): 39 (WebKit::accumulatesTransform): 40 (WebKit::GraphicsLayerWC::transformByApplyingAnchorPoint const): 41 (WebKit::GraphicsLayerWC::layerTransform const): 42 (WebKit::GraphicsLayerWC::computeVisibleAndCoverageRect const): 43 (WebKit::GraphicsLayerWC::recursiveCommitChanges): 44 * WebProcess/WebPage/wc/GraphicsLayerWC.h: 45 * WebProcess/WebPage/wc/WCUpateInfo.h: 46 (WebKit::WCLayerUpateInfo::encode const): 47 (WebKit::WCLayerUpateInfo::decode): 48 1 49 2022-01-12 Ryan Haddad <ryanhaddad@apple.com> 2 50 -
trunk/Source/WebKit/GPUProcess/graphics/wc/WCScene.cpp
r287288 r287967 37 37 #include <WebCore/TextureMapperLayer.h> 38 38 #include <WebCore/TextureMapperPlatformLayer.h> 39 #include <WebCore/TextureMapper TiledBackingStore.h>39 #include <WebCore/TextureMapperSparseBackingStore.h> 40 40 41 41 namespace WebKit { … … 53 53 54 54 WebCore::TextureMapperLayer texmapLayer; 55 RefPtr<WebCore::TextureMapperTiledBackingStore> backingStore;55 std::optional<WebCore::TextureMapperSparseBackingStore> backingStore; 56 56 std::unique_ptr<WebCore::TextureMapperLayer> backdropLayer; 57 57 }; … … 123 123 if (layerUpdate.changes & WCLayerChange::MasksToBounds) 124 124 layer->texmapLayer.setMasksToBounds(layerUpdate.masksToBounds); 125 if (layerUpdate.changes & WCLayerChange::BackingStore) { 126 auto bitmap = layerUpdate.backingStore.bitmap(); 127 if (bitmap) { 128 layer->backingStore = WebCore::TextureMapperTiledBackingStore::create(); 129 auto image = bitmap->createImage(); 130 layer->backingStore->updateContents(*m_textureMapper, image.get(), bitmap->size(), { { }, bitmap->size() }); 131 layer->texmapLayer.setBackingStore(layer->backingStore.get()); 125 if (layerUpdate.changes & WCLayerChange::Background) { 126 if (layerUpdate.hasBackingStore) { 127 if (!layer->backingStore) { 128 const int tileSize = 512; 129 layer->backingStore.emplace<WebCore::TextureMapperSparseBackingStore>(tileSize); 130 auto& backingStore = *layer->backingStore; 131 layer->texmapLayer.setBackgroundColor({ }); 132 layer->texmapLayer.setBackingStore(&backingStore); 133 } 134 auto& backingStore = *layer->backingStore; 135 backingStore.setSize(WebCore::IntSize(layer->texmapLayer.size())); 136 backingStore.removeUncoveredTiles(layerUpdate.coverageRect); 137 auto bitmap = layerUpdate.backingStore.bitmap(); 138 if (bitmap) { 139 auto image = bitmap->createImage(); 140 backingStore.updateContents(*m_textureMapper, *image, layerUpdate.dirtyRect); 141 } 132 142 } else { 143 layer->texmapLayer.setBackgroundColor(layerUpdate.backgroundColor); 133 144 layer->texmapLayer.setBackingStore(nullptr); 134 layer->backingStore = nullptr;145 layer->backingStore = std::nullopt; 135 146 } 136 147 } … … 141 152 if (layerUpdate.changes & WCLayerChange::RepaintCount) 142 153 layer->texmapLayer.setRepaintCounter(layerUpdate.showRepaintCounter, layerUpdate.repaintCount); 143 if (layerUpdate.changes & WCLayerChange::BackgroundColor)144 layer->texmapLayer.setBackgroundColor(layerUpdate.backgroundColor);145 154 if (layerUpdate.changes & WCLayerChange::Opacity) 146 155 layer->texmapLayer.setOpacity(layerUpdate.opacity); -
trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.cpp
r285099 r287967 32 32 #include "RemoteWCLayerTreeHostProxy.h" 33 33 #include "UpdateInfo.h" 34 #include "WebFrame.h" 34 35 #include "WebPageCreationParameters.h" 35 36 #include "WebProcess.h" … … 43 44 DrawingAreaWC::DrawingAreaWC(WebPage& webPage, const WebPageCreationParameters& parameters) 44 45 : DrawingArea(DrawingAreaType::WC, parameters.drawingAreaIdentifier, webPage) 45 , m_rootLayerClient(webPage)46 46 , m_remoteWCLayerTreeHostProxy(makeUnique<RemoteWCLayerTreeHostProxy>(webPage, *this)) 47 47 , m_layerFactory(*this) … … 51 51 { 52 52 m_rootLayer->setName(MAKE_STATIC_STRING_IMPL("drawing area root")); 53 m_rootLayer->setDrawsContent(true);54 m_rootLayer->setContentsOpaque(true);55 53 m_rootLayer->setSize(m_webPage.size()); 56 m_rootLayer->setNeedsDisplay();57 54 } 58 55 … … 94 91 } 95 92 93 void DrawingAreaWC::updatePreferences(const WebPreferencesStore&) 94 { 95 Settings& settings = m_webPage.corePage()->settings(); 96 settings.setAcceleratedCompositingForFixedPositionEnabled(settings.acceleratedCompositingEnabled()); 97 } 98 99 bool DrawingAreaWC::shouldUseTiledBackingForFrameView(const WebCore::FrameView& frameView) const 100 { 101 return frameView.frame().isMainFrame(); 102 } 103 96 104 void DrawingAreaWC::setLayerTreeStateIsFrozen(bool isFrozen) 97 105 { … … 123 131 { 124 132 if (isCompositingMode()) 125 m_rootLayer->setNeedsDisplayInRect(rect); 126 else 127 m_dirtyRegion.unite(rect); 133 return; 134 m_dirtyRegion.unite(rect); 128 135 triggerRenderingUpdate(); 129 136 } … … 132 139 { 133 140 if (isCompositingMode()) 134 m_rootLayer->setNeedsDisplayInRect(scrollRect); 135 else { 136 if (scrollRect != m_scrollRect) { 137 // Just repaint the entire current scroll rect, we'll scroll the new rect instead. 138 setNeedsDisplayInRect(m_scrollRect); 139 m_scrollRect = { }; 140 m_scrollOffset = { }; 141 } 142 // Get the part of the dirty region that is in the scroll rect. 143 Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion); 144 if (!dirtyRegionInScrollRect.isEmpty()) { 145 // There are parts of the dirty region that are inside the scroll rect. 146 // We need to subtract them from the region, move them and re-add them. 147 m_dirtyRegion.subtract(scrollRect); 148 // Move the dirty parts. 149 Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect); 150 // And add them back. 151 m_dirtyRegion.unite(movedDirtyRegionInScrollRect); 152 } 153 // Compute the scroll repaint region. 154 Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta)); 155 m_dirtyRegion.unite(scrollRepaintRegion); 156 m_scrollRect = scrollRect; 157 m_scrollOffset += scrollDelta; 158 triggerRenderingUpdate(); 159 } 141 return; 142 143 if (scrollRect != m_scrollRect) { 144 // Just repaint the entire current scroll rect, we'll scroll the new rect instead. 145 setNeedsDisplayInRect(m_scrollRect); 146 m_scrollRect = { }; 147 m_scrollOffset = { }; 148 } 149 // Get the part of the dirty region that is in the scroll rect. 150 Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion); 151 if (!dirtyRegionInScrollRect.isEmpty()) { 152 // There are parts of the dirty region that are inside the scroll rect. 153 // We need to subtract them from the region, move them and re-add them. 154 m_dirtyRegion.subtract(scrollRect); 155 // Move the dirty parts. 156 Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect); 157 // And add them back. 158 m_dirtyRegion.unite(movedDirtyRegionInScrollRect); 159 } 160 // Compute the scroll repaint region. 161 Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta)); 162 m_dirtyRegion.unite(scrollRepaintRegion); 163 m_scrollRect = scrollRect; 164 m_scrollOffset += scrollDelta; 165 triggerRenderingUpdate(); 160 166 } 161 167 … … 174 180 { 175 181 for (auto& layerInfo : info.changedLayers) { 176 if (layerInfo.changes & WCLayerChange::Back ingStore) {182 if (layerInfo.changes & WCLayerChange::Background) { 177 183 if (auto image = layerInfo.backingStore.imageBuffer()) { 178 184 if (auto flusher = image->createFlusher()) … … 221 227 222 228 // Because our view-relative overlay root layer is not attached to the FrameView's GraphicsLayer tree, we need to flush it manually. 223 if (m_viewOverlayRootLayer) 224 m_viewOverlayRootLayer->flushCompositingState({ }); 229 if (m_viewOverlayRootLayer) { 230 FloatRect visibleRect({ }, m_webPage.size()); 231 m_viewOverlayRootLayer->flushCompositingState(visibleRect); 232 } 225 233 226 234 m_updateInfo.rootLayer = m_rootLayer->primaryLayerID(); … … 342 350 } 343 351 344 DrawingAreaWC::RootLayerClient::RootLayerClient(WebPage& webPage)345 : m_webPage(webPage)346 {347 }348 349 void DrawingAreaWC::RootLayerClient::paintContents(const GraphicsLayer*, GraphicsContext& context, const FloatRect& rectToPaint, GraphicsLayerPaintBehavior)350 {351 context.save();352 context.clip(rectToPaint);353 m_webPage.corePage()->mainFrame().view()->paint(context, enclosingIntRect(rectToPaint));354 context.restore();355 }356 357 float DrawingAreaWC::RootLayerClient::deviceScaleFactor() const358 {359 return m_webPage.corePage()->deviceScaleFactor();360 }361 362 352 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/wc/DrawingAreaWC.h
r285099 r287967 58 58 void setRootCompositingLayer(WebCore::GraphicsLayer*) override; 59 59 void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override; 60 void updatePreferences(const WebPreferencesStore&) override; 61 bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const override; 60 62 // GraphicsLayerWC::Observer 61 63 void graphicsLayerAdded(GraphicsLayerWC&) override; … … 72 74 void updateRootLayers(); 73 75 74 class RootLayerClient : public WebCore::GraphicsLayerClient { 75 public: 76 RootLayerClient(WebPage&); 77 private: 78 void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, const WebCore::FloatRect& rectToPaint, WebCore::GraphicsLayerPaintBehavior) override; 79 float deviceScaleFactor() const override; 80 WebPage& m_webPage; 81 }; 82 83 RootLayerClient m_rootLayerClient; 76 WebCore::GraphicsLayerClient m_rootLayerClient; 84 77 std::unique_ptr<RemoteWCLayerTreeHostProxy> m_remoteWCLayerTreeHostProxy; 85 78 WCLayerFactory m_layerFactory; -
trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.cpp
r287288 r287967 1 1 /* 2 * Copyright (C) 2010-2021 Apple Inc. All rights reserved. 2 3 * Copyright (C) 2021 Sony Interactive Entertainment Inc. 3 4 * … … 28 29 29 30 #include "WCPlatformLayerGCGL.h" 31 #include <WebCore/TransformState.h> 30 32 31 33 namespace WebKit { 32 34 using namespace WebCore; 35 36 class WCTiledBacking final : public TiledBacking { 37 WTF_MAKE_FAST_ALLOCATED; 38 public: 39 WCTiledBacking(GraphicsLayerWC& owner) 40 : m_owner(owner) { } 41 42 bool paintAndFlush(WCLayerUpateInfo& update) 43 { 44 update.dirtyRect = enclosingIntRect(m_dirtyRect); 45 update.coverageRect = m_coverageRect; 46 m_dirtyRect = { }; 47 auto& imageRect = update.dirtyRect; 48 if (imageRect.isEmpty()) 49 return false; 50 auto image = m_owner.createImageBuffer(imageRect.size()); 51 auto& context = image->context(); 52 context.translate(-imageRect.x(), -imageRect.y()); 53 m_owner.paintGraphicsLayerContents(context, update.dirtyRect); 54 image->flushDrawingContextAsync(); 55 update.backingStore.setImageBuffer(WTFMove(image)); 56 return true; 57 } 58 59 void setDirtyRect(const WebCore::FloatRect& rect) 60 { 61 m_dirtyRect.unite(rect); 62 } 63 64 bool hasDirtyRect() 65 { 66 return !m_dirtyRect.isEmpty(); 67 } 68 69 TiledBacking* tiledBacking() const { return const_cast<WCTiledBacking*>(this); }; 70 71 IntRect adjustCoverageRect(IntRect coverage) 72 { 73 int x = coverage.x() / tileSize().width() * tileSize().width(); 74 int y = coverage.y() / tileSize().height() * tileSize().height(); 75 int maxX = (coverage.maxX() + tileSize().width() - 1) / tileSize().width() * tileSize().width(); 76 int maxY = (coverage.maxY() + tileSize().height() - 1) / tileSize().height() * tileSize().height(); 77 IntRect newCoverage { x, y, maxX - x, maxY - y }; 78 newCoverage.intersect(bounds()); 79 return newCoverage; 80 } 81 82 // TiledBacking override 83 void setVisibleRect(const FloatRect&) final { } 84 FloatRect visibleRect() const final { return { }; }; 85 void setLayoutViewportRect(std::optional<FloatRect>) final { } 86 void setCoverageRect(const FloatRect& rect) final 87 { 88 auto newCoverage = adjustCoverageRect(enclosingIntRect(rect)); 89 WebCore::Region region(newCoverage); 90 region.subtract(m_coverageRect); 91 setDirtyRect(region.bounds()); 92 m_coverageRect = newCoverage; 93 m_dirtyRect.intersect(m_coverageRect); 94 } 95 FloatRect coverageRect() const final { return { }; }; 96 bool tilesWouldChangeForCoverageRect(const FloatRect&) const final { return false; } 97 void setTiledScrollingIndicatorPosition(const FloatPoint&) final { } 98 void setTopContentInset(float) final { } 99 void setVelocity(const VelocityData&) final { } 100 void setTileSizeUpdateDelayDisabledForTesting(bool) final { }; 101 void setScrollability(Scrollability) final { } 102 void prepopulateRect(const FloatRect&) final { } 103 void setIsInWindow(bool) final { } 104 bool isInWindow() const final { return m_isInWindow; } 105 void setTileCoverage(TileCoverage) final { } 106 TileCoverage tileCoverage() const final { return { }; }; 107 FloatRect adjustTileCoverageRect(const FloatRect& coverageRect, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, bool sizeChanged) final { return { }; }; 108 FloatRect adjustTileCoverageRectForScrolling(const FloatRect& coverageRect, const FloatSize& newSize, const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect, float contentsScale) final { return { }; }; 109 void willStartLiveResize() final { }; 110 void didEndLiveResize() final { }; 111 IntSize tileSize() const final { return { 512, 512 }; }; 112 void revalidateTiles() final { } 113 void forceRepaint() final { } 114 IntRect tileGridExtent() const final { return { }; } 115 void setScrollingPerformanceTestingEnabled(bool flag) final { } 116 bool scrollingPerformanceTestingEnabled() const final { return false; }; 117 double retainedTileBackingStoreMemory() const final { return 0; } 118 IntRect tileCoverageRect() const final { return { }; } 119 void setScrollingModeIndication(ScrollingModeIndication) final { } 120 void setHasMargins(bool marginTop, bool marginBottom, bool marginLeft, bool marginRight) final { } 121 bool hasMargins() const final { return false; }; 122 bool hasHorizontalMargins() const final { return false; }; 123 bool hasVerticalMargins() const final { return false; }; 124 void setMarginSize(int) final { } 125 int topMarginHeight() const final { return 0; }; 126 int bottomMarginHeight() const final { return 0; }; 127 int leftMarginWidth() const final { return 0; }; 128 int rightMarginWidth() const final { return 0; }; 129 void setZoomedOutContentsScale(float) final { } 130 float zoomedOutContentsScale() const final { return 1; } 131 IntRect bounds() const final { return { { }, IntSize(m_owner.size()) }; }; 132 IntRect boundsWithoutMargin() const final { return bounds(); }; 133 134 private: 135 bool m_isInWindow { false }; 136 WebCore::IntRect m_coverageRect; 137 WebCore::FloatRect m_dirtyRect; 138 GraphicsLayerWC& m_owner; 139 }; 140 33 141 34 142 GraphicsLayerWC::GraphicsLayerWC(Type layerType, GraphicsLayerClient& client, Observer& observer) … … 36 144 , m_observer(&observer) 37 145 { 146 m_tiledBacking = makeUnique<WCTiledBacking>(*this); 147 if (layerType == Type::Normal) 148 client.tiledBackingUsageChanged(this, true); 38 149 m_observer->graphicsLayerAdded(*this); 39 150 } … … 60 171 void GraphicsLayerWC::setNeedsDisplay() 61 172 { 173 setNeedsDisplayInRect({ { }, m_size }, ClipToLayer); 174 } 175 176 void GraphicsLayerWC::setNeedsDisplayInRect(const WebCore::FloatRect& rect, ShouldClipToLayer shouldClip) 177 { 62 178 if (!drawsContent()) 63 179 return; 64 noteLayerPropertyChanged(WCLayerChange::BackingStore); 65 addRepaintRect({ { }, m_size }); 66 } 67 68 void GraphicsLayerWC::setNeedsDisplayInRect(const WebCore::FloatRect& rect, ShouldClipToLayer) 69 { 70 if (!drawsContent()) 71 return; 72 noteLayerPropertyChanged(WCLayerChange::BackingStore); 180 181 m_tiledBacking->setDirtyRect(rect); 182 noteLayerPropertyChanged(WCLayerChange::Background); 73 183 addRepaintRect(rect); 74 184 } … … 222 332 return; 223 333 GraphicsLayer::setBackgroundColor(value); 224 noteLayerPropertyChanged(WCLayerChange::Background Color);334 noteLayerPropertyChanged(WCLayerChange::Background); 225 335 } 226 336 … … 254 364 return; 255 365 GraphicsLayer::setDrawsContent(value); 256 noteLayerPropertyChanged(WCLayerChange::Back ingStore);366 noteLayerPropertyChanged(WCLayerChange::Background); 257 367 updateDebugIndicators(); 258 368 } … … 375 485 } 376 486 377 void GraphicsLayerWC::noteLayerPropertyChanged(OptionSet<WCLayerChange> flags )487 void GraphicsLayerWC::noteLayerPropertyChanged(OptionSet<WCLayerChange> flags, ScheduleFlushOrNot scheduleFlush) 378 488 { 379 489 if (beingDestroyed()) … … 381 491 bool needsFlush = !m_uncommittedChanges; 382 492 m_uncommittedChanges.add(flags); 383 if (needsFlush )493 if (needsFlush && scheduleFlush == ScheduleFlush) 384 494 client().notifyFlushRequired(this); 385 495 } 386 496 387 void GraphicsLayerWC::flushCompositingState(const FloatRect& rect) 388 { 389 if (auto* mask = maskLayer()) 390 mask->flushCompositingStateForThisLayerOnly(); 391 if (auto* replica = replicaLayer()) 392 replica->flushCompositingStateForThisLayerOnly(); 393 flushCompositingStateForThisLayerOnly(); 394 for (auto& child : children()) 395 child->flushCompositingState(rect); 497 void GraphicsLayerWC::flushCompositingState(const FloatRect& passedVisibleRect) 498 { 499 // passedVisibleRect doesn't contain the scrollbar area. Inflate it. 500 FloatRect visibleRect = passedVisibleRect; 501 visibleRect.inflate(20.f); 502 TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(visibleRect)); 503 state.setSecondaryQuad(FloatQuad { visibleRect }); 504 recursiveCommitChanges(state); 396 505 } 397 506 … … 438 547 if (update.changes & WCLayerChange::MasksToBounds) 439 548 update.masksToBounds = masksToBounds(); 440 if (update.changes & WCLayerChange::BackingStore) { 441 if (drawsContent() && contentsAreVisible() && !size().isEmpty()) { 442 auto image = m_observer->createImageBuffer(size()); 443 FloatRect clipRect = { { }, size() }; 444 paintGraphicsLayerContents(image->context(), clipRect); 445 image->flushDrawingContextAsync(); 446 update.backingStore.setImageBuffer(WTFMove(image)); 447 448 incrementRepaintCount(); 449 update.changes.add(WCLayerChange::RepaintCount); 450 } 549 if (update.changes & WCLayerChange::Background) { 550 update.backgroundColor = backgroundColor(); 551 if (drawsContent() && contentsAreVisible()) { 552 update.hasBackingStore = true; 553 if (m_tiledBacking->paintAndFlush(update)) { 554 incrementRepaintCount(); 555 update.changes.add(WCLayerChange::RepaintCount); 556 } 557 } else 558 update.hasBackingStore = false; 451 559 } 452 560 if (update.changes & WCLayerChange::SolidColor) … … 461 569 update.repaintCount = repaintCount(); 462 570 } 463 if (update.changes & WCLayerChange::BackgroundColor)464 update.backgroundColor = backgroundColor();465 571 if (update.changes & WCLayerChange::Opacity) 466 572 update.opacity = opacity(); … … 483 589 } 484 590 591 TiledBacking* GraphicsLayerWC::tiledBacking() const 592 { 593 return m_tiledBacking->tiledBacking(); 594 } 595 596 RefPtr<WebCore::ImageBuffer> GraphicsLayerWC::createImageBuffer(WebCore::FloatSize size) 597 { 598 return m_observer->createImageBuffer(size); 599 } 600 601 static inline bool accumulatesTransform(const GraphicsLayerWC& layer) 602 { 603 return !layer.masksToBounds() && (layer.preserves3D() || (layer.parent() && layer.parent()->preserves3D())); 604 } 605 606 TransformationMatrix GraphicsLayerWC::transformByApplyingAnchorPoint(const TransformationMatrix& matrix) const 607 { 608 if (matrix.isIdentity()) 609 return matrix; 610 611 TransformationMatrix result; 612 FloatPoint3D absoluteAnchorPoint(anchorPoint()); 613 absoluteAnchorPoint.scale(size().width(), size().height(), 1); 614 result.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z()); 615 result.multiply(matrix); 616 result.translate3d(-absoluteAnchorPoint.x(), -absoluteAnchorPoint.y(), -absoluteAnchorPoint.z()); 617 return result; 618 } 619 620 TransformationMatrix GraphicsLayerWC::layerTransform(const FloatPoint& position, const TransformationMatrix* customTransform) const 621 { 622 TransformationMatrix transform; 623 transform.translate(position.x(), position.y()); 624 625 TransformationMatrix currentTransform; 626 if (customTransform) 627 currentTransform = *customTransform; 628 else if (m_transform) 629 currentTransform = *m_transform; 630 631 transform.multiply(transformByApplyingAnchorPoint(currentTransform)); 632 633 if (GraphicsLayer* parentLayer = parent()) { 634 if (parentLayer->hasNonIdentityChildrenTransform()) { 635 FloatPoint boundsOrigin = parentLayer->boundsOrigin(); 636 637 FloatPoint3D parentAnchorPoint(parentLayer->anchorPoint()); 638 parentAnchorPoint.scale(parentLayer->size().width(), parentLayer->size().height(), 1); 639 parentAnchorPoint += boundsOrigin; 640 641 transform.translateRight3d(-parentAnchorPoint.x(), -parentAnchorPoint.y(), -parentAnchorPoint.z()); 642 transform = parentLayer->childrenTransform() * transform; 643 transform.translateRight3d(parentAnchorPoint.x(), parentAnchorPoint.y(), parentAnchorPoint.z()); 644 } 645 } 646 647 return transform; 648 } 649 650 GraphicsLayerWC::VisibleAndCoverageRects GraphicsLayerWC::computeVisibleAndCoverageRect(TransformState& state, bool preserves3D) const 651 { 652 FloatPoint position = approximatePosition(); 653 client().customPositionForVisibleRectComputation(this, position); 654 655 TransformationMatrix layerTransform; 656 TransformationMatrix currentTransform; 657 if (client().getCurrentTransform(this, currentTransform)) 658 layerTransform = this->layerTransform(position, ¤tTransform); 659 else 660 layerTransform = this->layerTransform(position); 661 662 bool applyWasClamped; 663 TransformState::TransformAccumulation accumulation = preserves3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform; 664 state.applyTransform(layerTransform, accumulation, &applyWasClamped); 665 666 bool mapWasClamped; 667 FloatRect clipRectForChildren = state.mappedQuad(&mapWasClamped).boundingBox(); 668 FloatPoint boundsOrigin = m_boundsOrigin; 669 clipRectForChildren.move(boundsOrigin.x(), boundsOrigin.y()); 670 671 FloatRect clipRectForSelf(boundsOrigin, m_size); 672 if (!applyWasClamped && !mapWasClamped) 673 clipRectForSelf.intersect(clipRectForChildren); 674 675 if (masksToBounds()) { 676 ASSERT(accumulation == TransformState::FlattenTransform); 677 // Flatten, and replace the quad in the TransformState with one that is clipped to this layer's bounds. 678 state.flatten(); 679 state.setQuad(clipRectForSelf); 680 if (state.isMappingSecondaryQuad()) 681 state.setSecondaryQuad(FloatQuad { clipRectForSelf }); 682 } 683 684 FloatRect coverageRect = clipRectForSelf; 685 auto quad = state.mappedSecondaryQuad(&mapWasClamped); 686 if (quad && !mapWasClamped && !applyWasClamped) 687 coverageRect = (*quad).boundingBox(); 688 689 return { clipRectForSelf, coverageRect, currentTransform }; 690 } 691 692 void GraphicsLayerWC::recursiveCommitChanges(const TransformState& state) 693 { 694 TransformState localState = state; 695 696 bool accumulateTransform = accumulatesTransform(*this); 697 VisibleAndCoverageRects rects = computeVisibleAndCoverageRect(localState, accumulateTransform); 698 m_tiledBacking->setCoverageRect(rects.coverageRect); 699 if (m_tiledBacking->hasDirtyRect()) 700 noteLayerPropertyChanged(WCLayerChange::Background, DontScheduleFlush); 701 702 flushCompositingStateForThisLayerOnly(); 703 if (auto* mask = maskLayer()) 704 static_cast<GraphicsLayerWC*>(mask)->recursiveCommitChanges(localState); 705 if (auto* replica = replicaLayer()) 706 static_cast<GraphicsLayerWC*>(replica)->recursiveCommitChanges(localState); 707 for (auto& child : children()) 708 static_cast<GraphicsLayerWC*>(child.ptr())->recursiveCommitChanges(localState); 709 } 710 485 711 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/wc/GraphicsLayerWC.h
r286943 r287967 30 30 #include <wtf/DoublyLinkedList.h> 31 31 32 namespace WebCore { 33 class TransformState; 34 } 35 32 36 namespace WebKit { 37 class WCTiledBacking; 33 38 34 39 class GraphicsLayerWC final : public WebCore::GraphicsLayer, public DoublyLinkedListNode<GraphicsLayerWC> { … … 89 94 void flushCompositingState(const WebCore::FloatRect& clipRect) override; 90 95 void flushCompositingStateForThisLayerOnly() override; 96 WebCore::TiledBacking* tiledBacking() const override; 91 97 98 protected: 99 friend WCTiledBacking; 100 101 RefPtr<WebCore::ImageBuffer> createImageBuffer(WebCore::FloatSize); 102 92 103 private: 93 void noteLayerPropertyChanged(OptionSet<WCLayerChange>); 104 struct VisibleAndCoverageRects { 105 WTF_MAKE_STRUCT_FAST_ALLOCATED; 106 WebCore::FloatRect visibleRect; 107 WebCore::FloatRect coverageRect; 108 WebCore::TransformationMatrix animatingTransform; 109 }; 110 111 enum ScheduleFlushOrNot { ScheduleFlush, DontScheduleFlush }; 112 void noteLayerPropertyChanged(OptionSet<WCLayerChange>, ScheduleFlushOrNot = ScheduleFlush); 113 WebCore::TransformationMatrix transformByApplyingAnchorPoint(const WebCore::TransformationMatrix&) const; 114 WebCore::TransformationMatrix layerTransform(const WebCore::FloatPoint&, const WebCore::TransformationMatrix* = nullptr) const; 115 VisibleAndCoverageRects computeVisibleAndCoverageRect(WebCore::TransformState&, bool preserves3D) const; 116 void recursiveCommitChanges(const WebCore::TransformState&); 94 117 95 118 static GraphicsLayer::PlatformLayerID generateLayerID(); … … 101 124 WebCore::GraphicsLayer::PlatformLayerID m_layerID { generateLayerID() }; 102 125 Observer* m_observer; 126 std::unique_ptr<WCTiledBacking> m_tiledBacking; 103 127 PlatformLayer* m_platformLayer { nullptr }; 104 128 WebCore::Color m_solidColor; -
trunk/Source/WebKit/WebProcess/WebPage/wc/WCUpateInfo.h
r287288 r287967 51 51 ContentsClippingRect = 1 << 12, 52 52 Opacity = 1 << 13, 53 Back ingStore= 1 << 14,53 Background = 1 << 14, 54 54 Transform = 1 << 15, 55 55 ChildrenTransform = 1 << 16, … … 57 57 BackdropFilters = 1 << 18, 58 58 PlatformLayer = 1 << 19, 59 BackgroundColor = 1 << 20,60 59 }; 61 60 … … 77 76 bool preserves3D; 78 77 bool hasPlatformLayer; 78 bool hasBackingStore; 79 79 WebCore::Color solidColor; 80 80 WebCore::Color backgroundColor; … … 85 85 WebCore::FloatRect contentsRect; 86 86 WCBackingStore backingStore; 87 WebCore::IntRect dirtyRect; 88 WebCore::IntRect coverageRect; 87 89 WebCore::TransformationMatrix transform; 88 90 WebCore::TransformationMatrix childrenTransform; … … 124 126 if (changes & WCLayerChange::ContentsClippingRect) 125 127 encoder << contentsClippingRect; 126 if (changes & WCLayerChange::BackgroundColor)127 encoder << backgroundColor;128 128 if (changes & WCLayerChange::Opacity) 129 129 encoder << opacity; 130 if (changes & WCLayerChange::Back ingStore)131 encoder << back ingStore;130 if (changes & WCLayerChange::Background) 131 encoder << backgroundColor << hasBackingStore << backingStore << dirtyRect << coverageRect; 132 132 if (changes & WCLayerChange::Transform) 133 133 encoder << transform; … … 213 213 return false; 214 214 } 215 if (result.changes & WCLayerChange::BackgroundColor) {216 if (!decoder.decode(result.backgroundColor))217 return false;218 }219 215 if (result.changes & WCLayerChange::Opacity) { 220 216 if (!decoder.decode(result.opacity)) 221 217 return false; 222 218 } 223 if (result.changes & WCLayerChange::BackingStore) { 219 if (result.changes & WCLayerChange::Background) { 220 if (!decoder.decode(result.backgroundColor)) 221 return false; 222 if (!decoder.decode(result.hasBackingStore)) 223 return false; 224 224 if (!decoder.decode(result.backingStore)) 225 return false; 226 if (!decoder.decode(result.dirtyRect)) 227 return false; 228 if (!decoder.decode(result.coverageRect)) 225 229 return false; 226 230 } … … 304 308 WebKit::WCLayerChange::ContentsClippingRect, 305 309 WebKit::WCLayerChange::Opacity, 306 WebKit::WCLayerChange::Back ingStore,310 WebKit::WCLayerChange::Background, 307 311 WebKit::WCLayerChange::Transform, 308 312 WebKit::WCLayerChange::ChildrenTransform, 309 313 WebKit::WCLayerChange::Filters, 310 314 WebKit::WCLayerChange::BackdropFilters, 311 WebKit::WCLayerChange::PlatformLayer, 312 WebKit::WCLayerChange::BackgroundColor 315 WebKit::WCLayerChange::PlatformLayer 313 316 >; 314 317 };
Note:
See TracChangeset
for help on using the changeset viewer.