Changeset 166997 in webkit
- Timestamp:
- Apr 8, 2014 10:01:54 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166996 r166997 1 2014-04-08 Antti Koivisto <antti@apple.com> 2 3 Factor tile coverage map into a class 4 https://bugs.webkit.org/show_bug.cgi?id=131417 5 6 Reviewed by Tim Horton. 7 8 * WebCore.xcodeproj/project.pbxproj: 9 * platform/graphics/ca/PlatformCALayerClient.h: 10 (WebCore::PlatformCALayerClient::platformCALayerLayoutSublayersOfLayer): 11 (WebCore::PlatformCALayerClient::platformCALayerRespondsToLayoutChanges): 12 (WebCore::PlatformCALayerClient::platformCALayerAnimationStarted): 13 (WebCore::PlatformCALayerClient::platformCALayerContentsOrientation): 14 (WebCore::PlatformCALayerClient::platformCALayerShowDebugBorders): 15 (WebCore::PlatformCALayerClient::platformCALayerShowRepaintCounter): 16 (WebCore::PlatformCALayerClient::platformCALayerIncrementRepaintCount): 17 (WebCore::PlatformCALayerClient::platformCALayerLayerDidDisplay): 18 19 Added default implementation to some of these to make clients less messy. 20 21 * platform/graphics/ca/mac/TileController.h: 22 * platform/graphics/ca/mac/TileController.mm: 23 (WebCore::TileController::~TileController): 24 (WebCore::TileController::platformCALayerPaintContents): 25 (WebCore::TileController::setTiledScrollingIndicatorPosition): 26 (WebCore::TileController::updateTileCoverageMap): 27 (WebCore::TileController::tiledScrollingIndicatorLayer): 28 * platform/graphics/ca/mac/TileCoverageMap.h: Added. 29 (WebCore::TileCoverageMap::setPosition): 30 (WebCore::TileCoverageMap::layer): 31 * platform/graphics/ca/mac/TileCoverageMap.mm: Added. 32 33 The new class. 34 35 (WebCore::TileCoverageMap::TileCoverageMap): 36 (WebCore::TileCoverageMap::~TileCoverageMap): 37 (WebCore::TileCoverageMap::update): 38 (WebCore::TileCoverageMap::platformCALayerPaintContents): 39 (WebCore::TileCoverageMap::platformCALayerDeviceScaleFactor): 40 * platform/graphics/ca/mac/TileGrid.h: 41 * platform/graphics/ca/mac/TileGrid.mm: 42 (WebCore::TileGrid::drawTileMapContents): 43 1 44 2014-04-08 Zalan Bujtas <zalan@apple.com> 2 45 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r166965 r166997 6051 6051 E47E276516036ED200EE2AFB /* DocumentStyleSheetCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = E47E276416036ED200EE2AFB /* DocumentStyleSheetCollection.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6052 6052 E47E276816036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */; }; 6053 E4830A3918F4C59400154A1B /* TileCoverageMap.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4830A3818F4C59400154A1B /* TileCoverageMap.mm */; }; 6054 E4830A3D18F4C5B700154A1B /* TileCoverageMap.h in Headers */ = {isa = PBXBuildFile; fileRef = E4830A3C18F4C5B700154A1B /* TileCoverageMap.h */; }; 6053 6055 E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */; }; 6054 6056 E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 13436 13438 E47E276416036ED200EE2AFB /* DocumentStyleSheetCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentStyleSheetCollection.h; sourceTree = "<group>"; }; 13437 13439 E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentStyleSheetCollection.cpp; sourceTree = "<group>"; }; 13440 E4830A3818F4C59400154A1B /* TileCoverageMap.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileCoverageMap.mm; path = ca/mac/TileCoverageMap.mm; sourceTree = "<group>"; }; 13441 E4830A3C18F4C5B700154A1B /* TileCoverageMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileCoverageMap.h; path = ca/mac/TileCoverageMap.h; sourceTree = "<group>"; }; 13438 13442 E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayout.cpp; sourceTree = "<group>"; }; 13439 13443 E48944A1180B57D800F165D8 /* SimpleLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayout.h; sourceTree = "<group>"; }; … … 15620 15624 1AA71609149BC4DB0016EC19 /* TileController.h */, 15621 15625 1AA71608149BC4DA0016EC19 /* TileController.mm */, 15626 E4830A3C18F4C5B700154A1B /* TileCoverageMap.h */, 15627 E4830A3818F4C59400154A1B /* TileCoverageMap.mm */, 15622 15628 E4C274CB18E988F500602C76 /* TileGrid.h */, 15623 15629 E4C274C918E988EA00602C76 /* TileGrid.mm */, … … 24685 24691 B2FA3DB90AB75A6F000E5AC4 /* JSSVGPathSegArcAbs.h in Headers */, 24686 24692 B2FA3DBB0AB75A6F000E5AC4 /* JSSVGPathSegArcRel.h in Headers */, 24693 E4830A3D18F4C5B700154A1B /* TileCoverageMap.h in Headers */, 24687 24694 B2FA3DBD0AB75A6F000E5AC4 /* JSSVGPathSegClosePath.h in Headers */, 24688 24695 B2FA3DBF0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoCubicAbs.h in Headers */, … … 26867 26874 E19AC3F9182566F700349426 /* CryptoKeyMac.cpp in Sources */, 26868 26875 E1F80B8718317252007885C3 /* CryptoKeyPair.cpp in Sources */, 26876 E4830A3918F4C59400154A1B /* TileCoverageMap.mm in Sources */, 26869 26877 E164FAA518315E1A00DB4E61 /* CryptoKeyRSAMac.cpp in Sources */, 26870 26878 E125F859182C1AA600D84CD9 /* CryptoKeySerializationRaw.cpp in Sources */, -
trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h
r166516 r166997 37 37 class PlatformCALayerClient { 38 38 public: 39 virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) = 0;40 virtual bool platformCALayerRespondsToLayoutChanges() const = 0;39 virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) { } 40 virtual bool platformCALayerRespondsToLayoutChanges() const { return false; } 41 41 42 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) = 0;43 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const = 0;42 virtual void platformCALayerAnimationStarted(CFTimeInterval) { } 43 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesTopDown; } 44 44 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& inClip) = 0; 45 virtual bool platformCALayerShowDebugBorders() const = 0;46 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const = 0;47 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) = 0;45 virtual bool platformCALayerShowDebugBorders() const { return false; } 46 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; } 47 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) { return 0; } 48 48 49 49 virtual bool platformCALayerContentsOpaque() const = 0; 50 50 virtual bool platformCALayerDrawsContent() const = 0; 51 virtual void platformCALayerLayerDidDisplay(PlatformLayer*) = 0;51 virtual void platformCALayerLayerDidDisplay(PlatformLayer*) { } 52 52 53 53 virtual void platformCALayerSetNeedsToRevalidateTiles() { } -
trunk/Source/WebCore/platform/graphics/ca/mac/TileController.h
r166958 r166997 44 44 class IntPoint; 45 45 class IntRect; 46 class TileCoverageMap; 46 47 class TileGrid; 47 48 … … 70 71 71 72 PlatformCALayer& rootLayer() { return *m_tileCacheLayer; } 73 const PlatformCALayer& rootLayer() const { return *m_tileCacheLayer; } 72 74 73 75 void setTileDebugBorderWidth(float); … … 85 87 86 88 public: 87 // Public for TileGrid 89 // Public for TileGrid and TileCoverageMap 88 90 bool isInWindow() const { return m_isInWindow; } 89 91 … … 92 94 Color tileDebugBorderColor() const { return m_tileDebugBorderColor; } 93 95 float tileDebugBorderWidth() const { return m_tileDebugBorderWidth; } 96 ScrollingModeIndication indicatorMode() const { return m_indicatorMode; } 94 97 95 98 virtual IntSize tileSize() const override { return m_tileSize; } … … 122 125 RefPtr<PlatformCALayer> createTileLayer(const IntRect&); 123 126 127 const TileGrid& tileGrid() const { return *m_tileGrid; } 128 124 129 Vector<RefPtr<PlatformCALayer>> containerLayers(); 125 130 … … 128 133 129 134 TileGrid& tileGrid() { return *m_tileGrid; } 130 const TileGrid& tileGrid() const { return *m_tileGrid; }131 135 132 136 // TiledBacking member functions. … … 150 154 151 155 // PlatformCALayerClient 152 virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) override { }153 virtual bool platformCALayerRespondsToLayoutChanges() const override { return false; }154 virtual void platformCALayerAnimationStarted(CFTimeInterval) override { }155 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return GraphicsLayer::CompositingCoordinatesTopDown; }156 156 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&) override; 157 157 virtual bool platformCALayerShowDebugBorders() const override; 158 158 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const override; 159 159 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) override; 160 161 160 virtual bool platformCALayerContentsOpaque() const override { return m_tilesAreOpaque; } 162 161 virtual bool platformCALayerDrawsContent() const override { return true; } 163 virtual void platformCALayerLayerDidDisplay(PlatformLayer*) override { }164 165 virtual void platformCALayerSetNeedsToRevalidateTiles() override { }166 162 virtual float platformCALayerDeviceScaleFactor() const override; 167 163 … … 171 167 void setNeedsRevalidateTiles(); 172 168 173 void drawTileMapContents(CGContextRef, CGRect);174 175 169 PlatformCALayerClient* owningGraphicsLayer() const { return m_tileCacheLayer->owner(); } 176 170 177 171 PlatformCALayer* m_tileCacheLayer; 178 RefPtr<PlatformCALayer> m_tiledScrollingIndicatorLayer; // Used for coverage visualization. 179 RefPtr<PlatformCALayer> m_visibleRectIndicatorLayer;172 173 std::unique_ptr<TileCoverageMap> m_coverageMap; 180 174 181 175 std::unique_ptr<TileGrid> m_tileGrid; … … 184 178 FloatRect m_visibleRect; 185 179 FloatRect m_visibleRectAtLastRevalidate; 186 FloatPoint m_tiledScrollingIndicatorPosition;187 180 IntRect m_boundsAtLastRevalidate; 188 181 -
trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm
r166958 r166997 31 31 #import "PlatformCALayer.h" 32 32 #import "Region.h" 33 #import "TileCoverageMap.h" 33 34 #import "TileGrid.h" 34 35 #if !PLATFORM(IOS) … … 85 86 tileControllerMemoryHandler().removeTileController(this); 86 87 #endif 87 88 if (m_tiledScrollingIndicatorLayer)89 m_tiledScrollingIndicatorLayer->setOwner(nullptr);90 88 } 91 89 … … 113 111 #endif 114 112 115 if (platformCALayer == m_tiledScrollingIndicatorLayer.get()) {116 tileGrid().drawTileMapContents(context.platformContext(), m_tiledScrollingIndicatorLayer->bounds());117 return;118 }119 120 113 { 121 114 GraphicsContextStateSaver stateSaver(context); … … 215 208 void TileController::setTiledScrollingIndicatorPosition(const FloatPoint& position) 216 209 { 217 if ( m_tiledScrollingIndicatorPosition == position)218 return; 219 m_ tiledScrollingIndicatorPosition = position;220 updateTileCoverageMap();210 if (!m_coverageMap) 211 return; 212 m_coverageMap->setPosition(position); 213 m_coverageMap->update(); 221 214 } 222 215 … … 413 406 void TileController::updateTileCoverageMap() 414 407 { 415 if (!m_tiledScrollingIndicatorLayer) 416 return; 417 FloatRect containerBounds = bounds(); 418 FloatRect visibleRect = this->visibleRect(); 419 visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges. 420 421 float widthScale = 1; 422 float scale = 1; 423 if (!containerBounds.isEmpty()) { 424 widthScale = std::min<float>(visibleRect.width() / containerBounds.width(), 0.1); 425 scale = std::min(widthScale, visibleRect.height() / containerBounds.height()); 426 } 427 428 float indicatorScale = scale * tileGrid().scale(); 429 FloatRect mapBounds = containerBounds; 430 mapBounds.scale(indicatorScale, indicatorScale); 431 432 m_tiledScrollingIndicatorLayer->setPosition(m_tiledScrollingIndicatorPosition + FloatPoint(2, 2)); 433 m_tiledScrollingIndicatorLayer->setBounds(mapBounds); 434 m_tiledScrollingIndicatorLayer->setNeedsDisplay(); 435 436 visibleRect.scale(indicatorScale, indicatorScale); 437 visibleRect.expand(2, 2); 438 m_visibleRectIndicatorLayer->setPosition(visibleRect.location()); 439 m_visibleRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), visibleRect.size())); 440 441 Color visibleRectIndicatorColor; 442 switch (m_indicatorMode) { 443 case SynchronousScrollingBecauseOfStyleIndication: 444 visibleRectIndicatorColor = Color(255, 0, 0); 445 break; 446 case SynchronousScrollingBecauseOfEventHandlersIndication: 447 visibleRectIndicatorColor = Color(255, 255, 0); 448 break; 449 case AsyncScrollingIndication: 450 visibleRectIndicatorColor = Color(0, 200, 0); 451 break; 452 } 453 454 m_visibleRectIndicatorLayer->setBorderColor(visibleRectIndicatorColor); 408 if (m_coverageMap) 409 m_coverageMap->update(); 455 410 } 456 411 … … 473 428 PlatformCALayer* TileController::tiledScrollingIndicatorLayer() 474 429 { 475 if (!m_tiledScrollingIndicatorLayer) { 476 m_tiledScrollingIndicatorLayer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeSimpleLayer, this); 477 m_tiledScrollingIndicatorLayer->setOpacity(0.75); 478 m_tiledScrollingIndicatorLayer->setAnchorPoint(FloatPoint3D()); 479 m_tiledScrollingIndicatorLayer->setBorderColor(Color::black); 480 m_tiledScrollingIndicatorLayer->setBorderWidth(1); 481 m_tiledScrollingIndicatorLayer->setPosition(FloatPoint(2, 2)); 482 483 m_visibleRectIndicatorLayer = m_tileCacheLayer->createCompatibleLayer(PlatformCALayer::LayerTypeLayer, nullptr); 484 m_visibleRectIndicatorLayer->setBorderWidth(2); 485 m_visibleRectIndicatorLayer->setAnchorPoint(FloatPoint3D()); 486 m_visibleRectIndicatorLayer->setBorderColor(Color(255, 0, 0)); 487 488 m_tiledScrollingIndicatorLayer->appendSublayer(m_visibleRectIndicatorLayer.get()); 489 490 updateTileCoverageMap(); 491 } 492 493 return m_tiledScrollingIndicatorLayer.get(); 430 if (!m_coverageMap) 431 m_coverageMap = std::make_unique<TileCoverageMap>(*this); 432 433 return &m_coverageMap->layer(); 494 434 } 495 435 -
trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.h
r166958 r166997 68 68 unsigned blankPixelCount() const; 69 69 70 void drawTileMapContents(CGContextRef, CGRect layerBounds) ;70 void drawTileMapContents(CGContextRef, CGRect layerBounds) const; 71 71 72 72 #if PLATFORM(IOS) -
trunk/Source/WebCore/platform/graphics/ca/mac/TileGrid.mm
r166958 r166997 599 599 } 600 600 601 void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) 601 void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) const 602 602 { 603 603 CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1);
Note: See TracChangeset
for help on using the changeset viewer.