Source/WebCore/ChangeLog

 12013-10-24 Tim Horton <timothy_horton@apple.com>
 2
 3 Make TileController manipulate PlatformCALayers instead of CALayers
 4 https://bugs.webkit.org/show_bug.cgi?id=123279
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 In the interest of making TileController more platform-independent
 9 (so that it can be used with the remote layer tree, and maybe Windows),
 10 move TileController onto our PlatformCALayer abstraction instead of
 11 direct manipulation of CALayers.
 12
 13 Some fallout from this includes getting rid of special Mac-specific
 14 TileController-specific CALayer subclasses, and reworking tile
 15 painting to work in a more generic way.
 16
 17 This is a first step, and doesn't get us all the way to a platform independent
 18 TileController, but more patches are forthcoming.
 19
 20 No new tests, just a (largeish) refactor.
 21
 22 * WebCore.exp.in:
 23 The signature of some methods has changed.
 24
 25 * WebCore.xcodeproj/project.pbxproj:
 26 Remove WebTileLayer.*
 27
 28 * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
 29 (WebCore::ScrollingTreeScrollingNodeMac::logExposedUnfilledArea):
 30 Use the "isTile" key on the CALayer dictionary instead of the layer's
 31 class to determine if it's a tile. TileController will set this on a tile
 32 when it is created, for now.
 33
 34 * platform/graphics/TiledBacking.h:
 35 tiledScrollingIndicatorLayer() should return a PlatformCALayer.
 36
 37 * platform/graphics/ca/GraphicsLayerCA.cpp:
 38 (WebCore::GraphicsLayerCA::platformCALayerPaintContents):
 39 * platform/graphics/ca/GraphicsLayerCA.h:
 40 (WebCore::GraphicsLayerCA::platformCALayerIncrementRepaintCount):
 41 * platform/graphics/ca/PlatformCALayerClient.h:
 42 The PlatformCALayerClient paintContents and incrementRepaintCount callbacks
 43 should include the platformCALayer that caused the callback.
 44
 45 * platform/graphics/ca/PlatformCALayer.h:
 46 Add LayerTypeSimpleLayer, which is similar to LayerTypeWebLayer
 47 except it just calls back its client to paint, instead of doing
 48 complicated things with repaint rects. This is so that TileController
 49 doesn't re-enter drawLayerContents when asking its GraphicsLayer
 50 to paint for each PlatformCALayer (it will be entering drawLayerContents
 51 for the first time for each layer). It also happens to be useful
 52 for things like the tile controller overlay, which don't need
 53 all that complication.
 54
 55 Add LayerTypeTiledBackingTileLayer, which is used simply to distinguish
 56 TileController Tile layers from other LayerTypeSimpleLayers.
 57
 58 * platform/graphics/ca/mac/LayerPool.h:
 59 * platform/graphics/ca/mac/LayerPool.mm:
 60 (WebCore::LayerPool::addLayer):
 61 (WebCore::LayerPool::takeLayerWithSize):
 62 LayerPool should operate on PlatformCALayers now.
 63
 64 * platform/graphics/ca/mac/PlatformCALayerMac.h:
 65 * platform/graphics/ca/mac/PlatformCALayerMac.mm:
 66 (PlatformCALayerMac::PlatformCALayerMac):
 67 Set the "isTile" key on the CALayer to true for TiledBackingTileLayers,
 68 so that the scrolling performance logging can tell a tile apart from
 69 any other layer, on the scrolling thread, without touching PlatformCALayers
 70 or the TileController or any other main-thread data structures.
 71
 72 (PlatformCALayerMac::setEdgeAntialiasingMask): Added.
 73 * platform/graphics/ca/mac/TileController.h:
 74 Remove references to Objective-C classes; instead use PlatformCALayer everywhere.
 75 TileController is now a PlatformCALayerClient, and the layers it owns are
 76 all PlatformCALayers (and it is constructed with a PlatformCALayer, etc.).
 77 Hand in the tile debug border color as a WebCore color, instead of a CGColorRef.
 78 blankPixelCountForTiles() now operates on a list of PlatformLayers instead of
 79 WebTileLayers specifically, since WebTileLayer is gone.
 80 Make drawTileMapContents private because WebTileCacheMapLayer no longer exists.
 81
 82 (WebCore::TileController::platformCALayerDrawsContent):
 83 All of the layers who have TileController as their client paint their contents.
 84
 85 (WebCore::TileController::platformCALayerContentsOpaque):
 86 This will only be called for layers which paint via drawLayerContents,
 87 so it's OK that we don't special-case the debugging overlay here.
 88
 89 * platform/graphics/ca/mac/TileController.mm:
 90 Remove CALayer (WebCALayerDetails), WebTiledScrollingIndicatorLayer,
 91 and a bunch of includes that we don't need anymore.
 92
 93 (WebCore::TileController::create):
 94 (WebCore::TileController::TileController):
 95 TileController is passed a PlatformCALayer for the tile cache root layer,
 96 instead of a WebTiledBackingLayer. It also creates a PlatformCALayer with
 97 LayerTypeLayer instead of a bare CALayer for the container layer.
 98
 99 (WebCore::TileController::~TileController):
 100 Clear the owner of the PlatformCALayers which the TileController previously owned,
 101 so they don't try to call back a destroyed TileController.
 102
 103 (WebCore::TileController::tileCacheLayerBoundsChanged):
 104 (WebCore::TileController::setNeedsDisplay):
 105 Straightforward adjustments towards use of PlatformCALayer.
 106
 107 (WebCore::TileController::setTileNeedsDisplayInRect):
 108 Adjustments towards use of PlatformCALayer; we need FloatRects so we can
 109 pass pointers to PlatformCALayer::setNeedsDisplay.
 110
 111 (WebCore::TileController::platformCALayerPaintContents):
 112 Replace drawLayer with platformCALayerPaintContents, which will be called
 113 back from our various WebSimpleLayers. If the PlatformCALayer is our
 114 tiled scrolling debug indicator, paint that. Otherwise, it's a tile.
 115 Make use of drawLayerContents() to paint the tile contents.
 116 Make use of drawRepaintIndicator() to paint the repaint indicator if needed.
 117 Move scrolling performance logging code that used to be in WebTileLayer here.
 118
 119 (WebCore::TileController::platformCALayerDeviceScaleFactor):
 120 (WebCore::TileController::platformCALayerShowDebugBorders):
 121 (WebCore::TileController::platformCALayerShowRepaintCounter):
 122 Forward these to the owning GraphicsLayerCA, because it will have the right answers.
 123
 124 (WebCore::TileController::setScale):
 125 Adjustments towards use of PlatformCALayer; remove some code that Simon
 126 caused to be unused in 156291 but did not remove.
 127
 128 (WebCore::TileController::setAcceleratesDrawing):
 129 (WebCore::TileController::setTilesOpaque):
 130 (WebCore::TileController::setVisibleRect):
 131 (WebCore::TileController::revalidateTiles):
 132 (WebCore::TileController::setTileDebugBorderWidth):
 133 (WebCore::TileController::setTileDebugBorderColor):
 134 (WebCore::TileController::bounds):
 135 (WebCore::TileController::blankPixelCount):
 136 (WebCore::TileController::blankPixelCountForTiles):
 137 (WebCore::queueTileForRemoval):
 138 (WebCore::TileController::setNeedsRevalidateTiles):
 139 (WebCore::TileController::ensureTilesForRect):
 140 (WebCore::TileController::retainedTileBackingStoreMemory):
 141 Straightforward adjustments towards use of PlatformCALayer.
 142
 143 (WebCore::TileController::updateTileCoverageMap):
 144 Adjustments towards use of PlatformCALayer; rename backgroundColor
 145 to visibleRectIndicatorColor, since it's actually a border, not a background.
 146
 147 (WebCore::TileController::tiledScrollingIndicatorLayer):
 148 Create a LayerTypeSimpleLayer PlatformCALayer for the tiled scrolling indicator.
 149 It will be asked to paint straightforwardly, like a CALayer would.
 150 Create a LayerTypeLayer PlatformCALayer for the visible rect indicator.
 151 It doesn't need to paint anything, so it doesn't get an owner.
 152
 153 (WebCore::TileController::createTileLayer):
 154 When creating a new tile layer, adopt it by setting its owner.
 155 Otherwise, straightforward adjustments towards use of PlatformCALayer.
 156
 157 (WebCore::TileController::platformCALayerIncrementRepaintCount):
 158 Manage repaint counts for tiles in TileController now.
 159
 160 (WebCore::TileController::drawTileMapContents):
 161 Adjustments towards use of PlatformCALayer.
 162
 163 * platform/graphics/ca/mac/WebTileLayer.h: Removed.
 164 * platform/graphics/ca/mac/WebTileLayer.mm: Removed.
 165 We don't need WebTileLayer anymore, tiles are now just WebSimpleLayers
 166 owned by TileController. Its behavior has been moved into TileController.
 167
 168 * platform/graphics/ca/mac/WebTiledBackingLayer.h:
 169 * platform/graphics/ca/mac/WebTiledBackingLayer.mm:
 170 (-[WebTiledBackingLayer createTileController:]):
 171 Add createTileController: so that the WebTiledBackingLayer's owner can
 172 hand the TileController the PlatformCALayer for the WebTiledBackingLayer
 173 without propagating additional usage of PlatformCALayer::platformCALayer(),
 174 which we need to remove in light of the remote layer tree work.
 175
 176 (-[WebTiledBackingLayer setBorderColor:]):
 177
 178 * platform/graphics/ca/win/PlatformCALayerWin.h:
 179 Add an empty implementation of setEdgeAntialiasingMask.
 180 We'll probably want to implement it before adopting TileController on Windows.
 181
 182 * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
 183 (PlatformCALayerWinInternal::displayCallback):
 184 * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:
 185 (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerPaintContents):
 186 (WebCore::MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerIncrementRepaintCount):
 187 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
 188 (WebCore::LayerClient::platformCALayerPaintContents):
 189 (WebCore::LayerClient::platformCALayerIncrementRepaintCount):
 190 Adjust for new parameters on PlatformCALayerClient callbacks.
 191
 192 * platform/graphics/mac/WebLayer.h:
 193 Add WebSimpleLayer, which inherits directly from CALayer, and make
 194 our standard WebLayer (which is used for compositing layers in web content)
 195 inherit from that.
 196
 197 * platform/graphics/mac/WebLayer.mm:
 198 Move most of the behavior of WebLayer onto WebSimpleLayer, except for its
 199 complex painting code. That stays as an override on WebLayer.
 200
 201 (WebCore::drawLayerContents):
 202 Use the PlatformCALayer's PlatformLayer - if it exists - to extract
 203 fine-grained repaint rects. If it doesn't, we'll just use the CGContext's
 204 clip rect as our single repaint rect.
 205 Rename platformLayer to platformCALayer for accuracy.
 206 Remove special code for CATiledLayer since we ought not use it on Mac anymore.
 207
 208 (WebCore::drawRepaintIndicator):
 209 Factor repaint indicator code out into its own function so that TileController
 210 can use it. It can't be called from drawLayerContents for TileController, since
 211 the PlatformCALayer that TileController passes in to drawLayerContents is actually
 212 that of the tile cache's root layer, not the tile itself.
 213 Also, add a custom background color parameter so TileController can override
 214 the default green color with its own standard purple.
 215
 216 (-[WebLayer drawInContext:]):
 217 (-[WebSimpleLayer drawInContext:]):
 218 * platform/graphics/mac/WebTiledLayer.mm:
 219 (-[WebTiledLayer drawInContext:]):
 220 Removed a param from drawLayerContents because it's trivially acquirable
 221 from the PlatformCALayer.
 222
12232013-10-23 Mark Lam <mark.lam@apple.com>
2224
3225 Re-instate ProposedDatabases needed by detailsForNameAndOrigin().

Source/WebCore/WebCore.exp.in

@@__ZN7WebCore15GraphicsLayerCA23setContentsNeedsDisplayEv
540540__ZN7WebCore15GraphicsLayerCA23setContentsToSolidColorERKNS_5ColorE
541541__ZN7WebCore15GraphicsLayerCA23setDebugBackgroundColorERKNS_5ColorE
542542__ZN7WebCore15GraphicsLayerCA26setMaintainsPixelAlignmentEb
543 __ZN7WebCore15GraphicsLayerCA28platformCALayerPaintContentsERNS_15GraphicsContextERKNS_7IntRectE
 543__ZN7WebCore15GraphicsLayerCA28platformCALayerPaintContentsEPNS_15PlatformCALayerERNS_15GraphicsContextERKNS_7IntRectE
544544__ZN7WebCore15GraphicsLayerCA30deviceOrPageScaleFactorChangedEv
545545__ZN7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedEd
546546__ZN7WebCore15GraphicsLayerCA32platformCALayerDeviceScaleFactorEv

@@__ZN7WebCore17SQLiteTransactionC1ERNS_14SQLiteDatabaseEb
680680__ZN7WebCore17SQLiteTransactionD1Ev
681681__ZN7WebCore17SubresourceLoader6createEPNS_5FrameEPNS_14CachedResourceERKNS_15ResourceRequestERKNS_21ResourceLoaderOptionsE
682682__ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
683 __ZN7WebCore17drawLayerContentsEP9CGContextPNS_15PlatformCALayerENS_9FloatRectEN3WTF6VectorIS4_Lm5ENS5_15CrashOnOverflowEEEb
 683__ZN7WebCore17drawLayerContentsEP9CGContextPNS_15PlatformCALayerEN3WTF6VectorINS_9FloatRectELm5ENS4_15CrashOnOverflowEEE
684684__ZN7WebCore17languageDidChangeEv
685685__ZN7WebCore17openTemporaryFileERKN3WTF6StringERi
686686__ZN7WebCore17setCookiesFromDOMERKNS_21NetworkStorageSessionERKNS_3URLES5_RKN3WTF6StringE

@@__ZTVN7WebCore25DropShadowFilterOperationE
18131813__ZTVN7WebCore28InspectorFrontendClientLocal8SettingsE
18141814__ZTVN7WebCore31BasicColorMatrixFilterOperationE
18151815__ZTVN7WebCore37BasicComponentTransferFilterOperationE
1816 __ZThn???_N7WebCore15GraphicsLayerCA28platformCALayerPaintContentsERNS_15GraphicsContextERKNS_7IntRectE
 1816__ZThn???_N7WebCore15GraphicsLayerCA28platformCALayerPaintContentsEPNS_15PlatformCALayerERNS_15GraphicsContextERKNS_7IntRectE
18171817__ZThn???_N7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedEd
18181818__ZThn???_N7WebCore15GraphicsLayerCA32platformCALayerDeviceScaleFactorEv
18191819__ZThn???_N7WebCore15GraphicsLayerCA40platformCALayerSetNeedsToRevalidateTilesEv

Source/WebCore/WebCore.xcodeproj/project.pbxproj

686686 1AA21250163F0DA80000E63F /* AtomicStringCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA2124F163F0DA80000E63F /* AtomicStringCF.cpp */; };
687687 1AA7160A149BC4DB0016EC19 /* TileController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA71608149BC4DA0016EC19 /* TileController.mm */; };
688688 1AA7160B149BC4DB0016EC19 /* TileController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA71609149BC4DB0016EC19 /* TileController.h */; };
689  1AA7161E149BF2FA0016EC19 /* WebTileLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA7161C149BF2FA0016EC19 /* WebTileLayer.mm */; };
690689 1AA84F04143BA7BD0051D153 /* ScrollElasticityController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */; };
691690 1AA84F05143BA7BD0051D153 /* ScrollElasticityController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */; };
692691 1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA8798F11CBE846003C664F /* PluginStrategy.h */; settings = {ATTRIBUTES = (Private, ); }; };

71547153 1AA2124F163F0DA80000E63F /* AtomicStringCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AtomicStringCF.cpp; sourceTree = "<group>"; };
71557154 1AA71608149BC4DA0016EC19 /* TileController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TileController.mm; path = ca/mac/TileController.mm; sourceTree = "<group>"; };
71567155 1AA71609149BC4DB0016EC19 /* TileController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileController.h; path = ca/mac/TileController.h; sourceTree = "<group>"; };
7157  1AA7161C149BF2FA0016EC19 /* WebTileLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebTileLayer.mm; path = ca/mac/WebTileLayer.mm; sourceTree = "<group>"; };
7158  1AA71625149BFFB20016EC19 /* WebTileLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebTileLayer.h; path = ca/mac/WebTileLayer.h; sourceTree = "<group>"; };
71597156 1AA84F02143BA7BD0051D153 /* ScrollElasticityController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollElasticityController.mm; sourceTree = "<group>"; };
71607157 1AA84F03143BA7BD0051D153 /* ScrollElasticityController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollElasticityController.h; sourceTree = "<group>"; };
71617158 1AA8798F11CBE846003C664F /* PluginStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginStrategy.h; sourceTree = "<group>"; };

1473314730 1AA71608149BC4DA0016EC19 /* TileController.mm */,
1473414731 0F580FA11496939100FB5BD8 /* WebTiledBackingLayer.h */,
1473514732 0F580FA21496939100FB5BD8 /* WebTiledBackingLayer.mm */,
14736  1AA71625149BFFB20016EC19 /* WebTileLayer.h */,
14737  1AA7161C149BF2FA0016EC19 /* WebTileLayer.mm */,
1473814733 );
1473914734 name = mac;
1474014735 sourceTree = "<group>";

2763627631 97AABD2614FA09D5007457AE /* WebSocketHandshake.cpp in Sources */,
2763727632 0F580FA41496939100FB5BD8 /* WebTiledBackingLayer.mm in Sources */,
2763827633 0FCF332C0F2B9A25004B6795 /* WebTiledLayer.mm in Sources */,
27639  1AA7161E149BF2FA0016EC19 /* WebTileLayer.mm in Sources */,
2764027634 CD82030B1395AB6A00F956C6 /* WebVideoFullscreenController.mm in Sources */,
2764127635 CD61FE691794AADB004101EB /* WebKitSourceBuffer.cpp in Sources */,
2764227636 CD82030D1395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm in Sources */,

Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm

3636#import "ScrollingStateTree.h"
3737#import "Settings.h"
3838#import "TileController.h"
39 #import "WebTileLayer.h"
 39#import "WebLayer.h"
4040
4141#import <QuartzCore/QuartzCore.h>
4242#import <wtf/CurrentTime.h>

@@void ScrollingTreeScrollingNodeMac::logExposedUnfilledArea()
419419
420420 Deque<CALayer*> layerQueue;
421421 layerQueue.append(m_scrollLayer.get());
422  WebTileLayerList tiles;
 422 PlatformLayerList tiles;
423423
424424 while (!layerQueue.isEmpty() && tiles.isEmpty()) {
425425 CALayer* layer = layerQueue.takeFirst();
426426 NSArray* sublayers = [[layer sublayers] copy];
427427
428428 // If this layer is the parent of a tile, it is the parent of all of the tiles and nothing else.
429  if ([[sublayers objectAtIndex:0] isKindOfClass:[WebTileLayer class]]) {
430  for (CALayer* sublayer in sublayers) {
431  ASSERT([sublayer isKindOfClass:[WebTileLayer class]]);
432  tiles.append(static_cast<WebTileLayer*>(sublayer));
433  }
 429 if ([[[sublayers objectAtIndex:0] valueForKey:@"isTile"] boolValue]) {
 430 for (CALayer* sublayer in sublayers)
 431 tiles.append(sublayer);
434432 } else {
435433 for (CALayer* sublayer in sublayers)
436434 layerQueue.append(sublayer);

Source/WebCore/platform/graphics/TiledBacking.h

2626#ifndef TiledBacking_h
2727#define TiledBacking_h
2828
29 #if PLATFORM(MAC)
30 OBJC_CLASS CALayer;
31 #endif
32 
3329namespace WebCore {
3430
3531class IntRect;
 32#if PLATFORM(MAC)
 33class PlatformCALayer;
 34#endif
3635
3736enum ScrollingModeIndication {
3837 MainThreadScrollingBecauseOfStyleIndication,

@@public:
9089 virtual void setScrollingModeIndication(ScrollingModeIndication) = 0;
9190
9291#if PLATFORM(MAC)
93  virtual CALayer *tiledScrollingIndicatorLayer() = 0;
 92 virtual PlatformCALayer* tiledScrollingIndicatorLayer() = 0;
9493#endif
9594};
9695

Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

@@private:
185185
186186 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { }
187187 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
188  virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& inClip) { }
 188 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const IntRect& inClip) { }
189189 virtual bool platformCALayerShowDebugBorders() const { return false; }
190190 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; }
191  virtual int platformCALayerIncrementRepaintCount() { return 0; }
 191 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) { return 0; }
192192
193193 virtual bool platformCALayerContentsOpaque() const { return false; }
194194 virtual bool platformCALayerDrawsContent() const { return false; }

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

@@bool GraphicsLayerCA::platformCALayerShowRepaintCounter(PlatformCALayer* platfor
12141214 // so we don't want to overpaint the repaint counter when called with the TileController's own layer.
12151215 if (m_isPageTiledBackingLayer && platformLayer)
12161216 return false;
1217 
 1217
12181218 return isShowingRepaintCounter();
12191219}
12201220
1221 void GraphicsLayerCA::platformCALayerPaintContents(GraphicsContext& context, const IntRect& clip)
 1221void GraphicsLayerCA::platformCALayerPaintContents(PlatformCALayer*, GraphicsContext& context, const IntRect& clip)
12221222{
12231223 paintGraphicsLayerContents(context, clip);
12241224}

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

@@private:
167167
168168 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime);
169169 virtual CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return contentsOrientation(); }
170  virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& clip);
 170 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const IntRect& clip);
171171 virtual bool platformCALayerShowDebugBorders() const { return isShowingDebugBorder(); }
172172 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const;
173  virtual int platformCALayerIncrementRepaintCount() { return incrementRepaintCount(); }
 173 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) { return incrementRepaintCount(); }
174174
175175 virtual bool platformCALayerContentsOpaque() const { return contentsOpaque(); }
176176 virtual bool platformCALayerDrawsContent() const { return drawsContent(); }

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

@@public:
6464 enum LayerType {
6565 LayerTypeLayer,
6666 LayerTypeWebLayer,
 67 LayerTypeSimpleLayer,
6768 LayerTypeTransformLayer,
6869 LayerTypeWebTiledLayer,
6970 LayerTypeTiledBackingLayer,
7071 LayerTypePageTiledBackingLayer,
 72 LayerTypeTiledBackingTileLayer,
7173 LayerTypeRootLayer,
7274 LayerTypeAVPlayerLayer,
7375 LayerTypeCustom

@@public:
183185 virtual float contentsScale() const = 0;
184186 virtual void setContentsScale(float) = 0;
185187
 188 virtual void setEdgeAntialiasingMask(unsigned) = 0;
 189
186190 virtual TiledBacking* tiledBacking() = 0;
187191
188192#if PLATFORM(WIN)

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

@@public:
5050
5151 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) = 0;
5252 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const = 0;
53  virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& inClip) = 0;
 53 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const IntRect& inClip) = 0;
5454 virtual bool platformCALayerShowDebugBorders() const = 0;
5555 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const = 0;
56  virtual int platformCALayerIncrementRepaintCount() = 0;
 56 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) = 0;
5757
5858 virtual bool platformCALayerContentsOpaque() const = 0;
5959 virtual bool platformCALayerDrawsContent() const = 0;

Source/WebCore/platform/graphics/ca/mac/LayerPool.h

2828
2929#include "IntSize.h"
3030#include "IntSizeHash.h"
 31#include "PlatformCALayer.h"
3132#include "Timer.h"
3233#include <wtf/Deque.h>
3334#include <wtf/HashMap.h>

3536#include <wtf/RetainPtr.h>
3637#include <wtf/Vector.h>
3738
38 @class WebTileLayer;
39 
4039namespace WebCore {
4140
4241class LayerPool {

@@class LayerPool {
4443public:
4544 static LayerPool* sharedPool();
4645
47  void addLayer(const RetainPtr<WebTileLayer>&);
48  RetainPtr<WebTileLayer> takeLayerWithSize(const IntSize&);
 46 void addLayer(const RefPtr<PlatformCALayer>&);
 47 RefPtr<PlatformCALayer> takeLayerWithSize(const IntSize&);
4948
5049 void drain();
5150

@@public:
5554private:
5655 LayerPool();
5756
58  typedef Deque<RetainPtr<WebTileLayer>> LayerList;
 57 typedef Deque<RefPtr<PlatformCALayer>> LayerList;
5958
6059 unsigned decayedCapacity() const;
6160

Source/WebCore/platform/graphics/ca/mac/LayerPool.mm

2727#include "LayerPool.h"
2828
2929#include "Logging.h"
30 #include "WebTileLayer.h"
3130#include <wtf/CurrentTime.h>
3231
3332namespace WebCore {
34 
 33
3534static const double capacityDecayTime = 5;
36 
 35
3736LayerPool::LayerPool()
3837 : m_totalBytes(0)
3938 , m_maxBytesForPool(48 * 1024 * 1024)

@@LayerPool::LayerList& LayerPool::listOfLayersWithSize(const IntSize& size, Acces
6665 return it->value;
6766}
6867
69 void LayerPool::addLayer(const RetainPtr<WebTileLayer>& layer)
 68void LayerPool::addLayer(const RefPtr<PlatformCALayer>& layer)
7069{
71  IntSize layerSize([layer.get() bounds].size);
 70 IntSize layerSize(expandedIntSize(layer->bounds().size()));
7271 if (!canReuseLayerWithSize(layerSize))
7372 return;
7473

@@void LayerPool::addLayer(const RetainPtr<WebTileLayer>& layer)
7978 schedulePrune();
8079}
8180
82 RetainPtr<WebTileLayer> LayerPool::takeLayerWithSize(const IntSize& size)
 81RefPtr<PlatformCALayer> LayerPool::takeLayerWithSize(const IntSize& size)
8382{
8483 if (!canReuseLayerWithSize(size))
8584 return nil;

Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h

@@public:
133133 virtual float contentsScale() const OVERRIDE;
134134 virtual void setContentsScale(float) OVERRIDE;
135135
 136 virtual void setEdgeAntialiasingMask(unsigned) OVERRIDE;
 137
136138 virtual TiledBacking* tiledBacking() OVERRIDE;
137139
138140 virtual void synchronouslyDisplayTilesInRect(const FloatRect&) OVERRIDE;

Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

3737#import "PlatformCAFilters.h"
3838#import "SoftLinking.h"
3939#import "TiledBacking.h"
 40#import "TileController.h"
4041#import "WebLayer.h"
4142#import "WebTiledLayer.h"
4243#import "WebTiledBackingLayer.h"

@@PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformLayer* layer
189190 case LayerTypeWebLayer:
190191 layerClass = [WebLayer class];
191192 break;
 193 case LayerTypeSimpleLayer:
 194 case LayerTypeTiledBackingTileLayer:
 195 layerClass = [WebSimpleLayer class];
 196 break;
192197 case LayerTypeTransformLayer:
193198 layerClass = [CATransformLayer class];
194199 break;

@@PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformLayer* layer
224229 [tiledLayer setLevelsOfDetailBias:0];
225230 [tiledLayer setContentsGravity:@"bottomLeft"];
226231 }
 232
 233 // So that the scrolling thread's performance logging code can find all the tiles, mark this as being a tile.
 234 if (m_layerType == LayerTypeTiledBackingTileLayer)
 235 [m_layer setValue:@YES forKey:@"isTile"];
227236
228237 if (usesTiledBackingLayer()) {
 238 WebTiledBackingLayer* tiledBackingLayer = static_cast<WebTiledBackingLayer*>(m_layer.get());
 239 TileController* tileController = [tiledBackingLayer createTileController:this];
 240
229241 m_customSublayers = adoptPtr(new PlatformCALayerList(1));
230  CALayer* tileCacheTileContainerLayer = [static_cast<WebTiledBackingLayer *>(m_layer.get()) tileContainerLayer];
231  (*m_customSublayers)[0] = PlatformCALayerMac::create(tileCacheTileContainerLayer, 0);
 242 PlatformCALayer* tileCacheTileContainerLayer = tileController->tileContainerLayer();
 243 (*m_customSublayers)[0] = tileCacheTileContainerLayer;
232244 }
233245
234246 END_BLOCK_OBJC_EXCEPTIONS

@@void PlatformCALayerMac::setContentsScale(float value)
705717 END_BLOCK_OBJC_EXCEPTIONS
706718}
707719
 720void PlatformCALayerMac::setEdgeAntialiasingMask(unsigned mask)
 721{
 722 BEGIN_BLOCK_OBJC_EXCEPTIONS
 723 [m_layer.get() setEdgeAntialiasingMask:mask];
 724 END_BLOCK_OBJC_EXCEPTIONS
 725}
 726
708727TiledBacking* PlatformCALayerMac::tiledBacking()
709728{
710729 if (!usesTiledBackingLayer())

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

2929#include "FloatRect.h"
3030#include "IntPointHash.h"
3131#include "IntRect.h"
 32#include "PlatformCALayer.h"
 33#include "PlatformCALayerClient.h"
3234#include "TiledBacking.h"
3335#include "Timer.h"
3436#include <wtf/Deque.h>

3739#include <wtf/PassOwnPtr.h>
3840#include <wtf/RetainPtr.h>
3941
40 OBJC_CLASS CALayer;
41 OBJC_CLASS WebTiledBackingLayer;
42 OBJC_CLASS WebTileLayer;
43 OBJC_CLASS WebTiledScrollingIndicatorLayer;
44 
4542namespace WebCore {
4643
4744class FloatRect;
4845class IntPoint;
4946class IntRect;
5047
51 typedef Vector<RetainPtr<WebTileLayer>> WebTileLayerList;
 48typedef Vector<RetainPtr<PlatformLayer>> PlatformLayerList;
5249
53 class TileController : public TiledBacking {
 50class TileController : public TiledBacking, public PlatformCALayerClient {
5451 WTF_MAKE_NONCOPYABLE(TileController);
5552
5653public:
57  static PassOwnPtr<TileController> create(WebTiledBackingLayer*);
 54 static PassOwnPtr<TileController> create(PlatformCALayer*);
5855 ~TileController();
5956
6057 void tileCacheLayerBoundsChanged();
6158
6259 void setNeedsDisplay();
6360 void setNeedsDisplayInRect(const IntRect&);
64  void drawLayer(WebTileLayer *, CGContextRef);
6561
6662 void setScale(CGFloat);
6763 CGFloat scale() const { return m_scale; }

@@public:
7268 void setTilesOpaque(bool);
7369 bool tilesAreOpaque() const { return m_tilesAreOpaque; }
7470
75  CALayer *tileContainerLayer() const { return m_tileContainerLayer.get(); }
 71 PlatformCALayer *tileContainerLayer() const { return m_tileContainerLayer.get(); }
7672
7773 void setTileDebugBorderWidth(float);
78  void setTileDebugBorderColor(CGColorRef);
 74 void setTileDebugBorderColor(Color);
7975
8076 virtual FloatRect visibleRect() const OVERRIDE { return m_visibleRect; }
8177
8278 unsigned blankPixelCount() const;
83  static unsigned blankPixelCountForTiles(const WebTileLayerList&, const FloatRect&, const IntPoint&);
84 
85  // Only public for the WebTileCacheMapLayer.
86  void drawTileMapContents(CGContextRef, CGRect);
 79 static unsigned blankPixelCountForTiles(const PlatformLayerList&, const FloatRect&, const IntPoint&);
8780
8881public:
8982 // Only public for inline methods in the implementation file.
9083 typedef IntPoint TileIndex;
9184 typedef unsigned TileCohort;
9285 static const TileCohort VisibleTileCohort = UINT_MAX;
 86 typedef HashMap<PlatformCALayer*, int> RepaintCountMap;
9387
9488 struct TileInfo {
95  RetainPtr<WebTileLayer> layer;
 89 RefPtr<PlatformCALayer> layer;
9690 TileCohort cohort; // VisibleTileCohort is visible.
9791 bool hasStaleContent;
9892

@@public:
10397 };
10498
10599private:
106  TileController(WebTiledBackingLayer*);
 100 TileController(PlatformCALayer*);
107101
108102 // TiledBacking member functions.
109103 virtual void setVisibleRect(const FloatRect&) OVERRIDE;

@@private:
127121 virtual bool unparentsOffscreenTiles() const OVERRIDE { return m_unparentsOffscreenTiles; }
128122 virtual double retainedTileBackingStoreMemory() const OVERRIDE;
129123 virtual IntRect tileCoverageRect() const OVERRIDE;
130  virtual CALayer *tiledScrollingIndicatorLayer() OVERRIDE;
 124 virtual PlatformCALayer* tiledScrollingIndicatorLayer() OVERRIDE;
131125 virtual void setScrollingModeIndication(ScrollingModeIndication) OVERRIDE;
132126
 127 // PlatformCALayerClient
 128 virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) OVERRIDE { }
 129 virtual bool platformCALayerRespondsToLayoutChanges() const OVERRIDE { return false; }
 130 virtual void platformCALayerAnimationStarted(CFTimeInterval) OVERRIDE { }
 131 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const OVERRIDE { return GraphicsLayer::CompositingCoordinatesTopDown; }
 132 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const IntRect&) OVERRIDE;
 133 virtual bool platformCALayerShowDebugBorders() const OVERRIDE;
 134 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const OVERRIDE;
 135 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) OVERRIDE;
 136
 137 virtual bool platformCALayerContentsOpaque() const OVERRIDE { return m_tilesAreOpaque; }
 138 virtual bool platformCALayerDrawsContent() const OVERRIDE { return true; }
 139 virtual void platformCALayerLayerDidDisplay(PlatformLayer*) OVERRIDE { }
 140
 141 virtual void platformCALayerSetNeedsToRevalidateTiles() OVERRIDE { }
 142 virtual float platformCALayerDeviceScaleFactor() OVERRIDE;
 143
133144 IntRect bounds() const;
134145
135146 IntRect rectForTileIndex(const TileIndex&) const;

@@private:
166177
167178 void setTileNeedsDisplayInRect(const TileIndex&, TileInfo&, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords);
168179
169  WebTileLayer* tileLayerAtIndex(const TileIndex&) const;
170  RetainPtr<WebTileLayer> createTileLayer(const IntRect&);
 180 RefPtr<PlatformCALayer> createTileLayer(const IntRect&);
171181
172  bool shouldShowRepaintCounters() const;
173  void drawRepaintCounter(WebTileLayer *, CGContextRef);
 182 void drawTileMapContents(CGContextRef, CGRect);
174183
175  WebTiledBackingLayer* m_tileCacheLayer;
176  RetainPtr<CALayer> m_tileContainerLayer;
177  RetainPtr<WebTiledScrollingIndicatorLayer> m_tiledScrollingIndicatorLayer; // Used for coverage visualization.
 184 PlatformCALayer* m_tileCacheLayer;
 185 RefPtr<PlatformCALayer> m_tileContainerLayer;
 186 RefPtr<PlatformCALayer> m_tiledScrollingIndicatorLayer; // Used for coverage visualization.
 187 RefPtr<PlatformCALayer> m_visibleRectIndicatorLayer;
178188
179189 IntSize m_tileSize;
180190 FloatRect m_visibleRect;

@@private:
189199 Timer<TileController> m_tileRevalidationTimer;
190200 Timer<TileController> m_cohortRemovalTimer;
191201
 202 RepaintCountMap m_tileRepaintCounts;
 203
192204 struct TileCohortInfo {
193205 TileCohort cohort;
194206 double creationTime; // in monotonicallyIncreasingTime().

@@private:
214226 bool m_tilesAreOpaque;
215227 bool m_clipsToExposedRect;
216228
217  RetainPtr<CGColorRef> m_tileDebugBorderColor;
 229 Color m_tileDebugBorderColor;
218230 float m_tileDebugBorderWidth;
219231 ScrollingModeIndication m_indicatorMode;
220232};

Source/WebCore/platform/graphics/ca/mac/TileController.mm

2828
2929#import "IntRect.h"
3030#import "PlatformCALayer.h"
 31#import "PlatformCALayerMac.h"
3132#import "Region.h"
3233#import "LayerPool.h"
3334#import "WebLayer.h"
34 #import "WebTiledBackingLayer.h"
35 #import "WebTileLayer.h"
36 #import <QuartzCore/QuartzCore.h>
3735#import <wtf/MainThread.h>
38 #import <WebCore/BlockExceptions.h>
3936#import <utility>
4037
4138using namespace std;
4239
43 @interface CALayer (WebCALayerDetails)
44 - (void)setAcceleratesDrawing:(BOOL)flag;
45 @end
46 
47 @interface WebTiledScrollingIndicatorLayer : CALayer {
48  WebCore::TileController* _tileController;
49  CALayer *_visibleRectFrameLayer; // Owned by being a sublayer.
50 }
51 @property (assign) WebCore::TileController* tileController;
52 @property (assign) CALayer* visibleRectFrameLayer;
53 @end
54 
55 @implementation WebTiledScrollingIndicatorLayer
56 @synthesize tileController = _tileController;
57 @synthesize visibleRectFrameLayer = _visibleRectFrameLayer;
58 - (id)init
59 {
60  if ((self = [super init])) {
61  [self setStyle:[NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], @"bounds", [NSNull null], @"position", [NSNull null], @"contents", nil] forKey:@"actions"]];
62 
63  _visibleRectFrameLayer = [CALayer layer];
64  [_visibleRectFrameLayer setStyle:[NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], @"bounds", [NSNull null], @"position", [NSNull null], @"borderColor", nil] forKey:@"actions"]];
65  [self addSublayer:_visibleRectFrameLayer];
66  [_visibleRectFrameLayer setBorderColor:WebCore::cachedCGColor(WebCore::Color(255, 0, 0), WebCore::ColorSpaceDeviceRGB)];
67  [_visibleRectFrameLayer setBorderWidth:2];
68  return self;
69  }
70  return nil;
71 }
72 
73 - (void)drawInContext:(CGContextRef)context
74 {
75  if (_tileController)
76  _tileController->drawTileMapContents(context, [self bounds]);
77 }
78 @end
79 
8040namespace WebCore {
8141
8242enum TileValidationPolicyFlag {

@@enum TileValidationPolicyFlag {
8747static const int defaultTileWidth = 512;
8848static const int defaultTileHeight = 512;
8949
90 PassOwnPtr<TileController> TileController::create(WebTiledBackingLayer* tileCacheLayer)
 50PassOwnPtr<TileController> TileController::create(PlatformCALayer* rootPlatformLayer)
9151{
92  return adoptPtr(new TileController(tileCacheLayer));
 52 return adoptPtr(new TileController(rootPlatformLayer));
9353}
9454
95 TileController::TileController(WebTiledBackingLayer* tileCacheLayer)
96  : m_tileCacheLayer(tileCacheLayer)
97  , m_tileContainerLayer(adoptNS([[CALayer alloc] init]))
 55TileController::TileController(PlatformCALayer* rootPlatformLayer)
 56 : m_tileCacheLayer(rootPlatformLayer)
9857 , m_tileSize(defaultTileWidth, defaultTileHeight)
9958 , m_tileRevalidationTimer(this, &TileController::tileRevalidationTimerFired)
10059 , m_cohortRemovalTimer(this, &TileController::cohortRemovalTimerFired)

@@TileController::TileController(WebTiledBackingLayer* tileCacheLayer)
11170 , m_tileDebugBorderWidth(0)
11271 , m_indicatorMode(ThreadedScrollingIndication)
11372{
114  [CATransaction begin];
115  [CATransaction setDisableActions:YES];
116  [m_tileCacheLayer addSublayer:m_tileContainerLayer.get()];
 73 m_tileContainerLayer = PlatformCALayerMac::create(PlatformCALayer::LayerTypeLayer, nullptr);
11774#ifndef NDEBUG
118  [m_tileContainerLayer.get() setName:@"TileController Container Layer"];
 75 m_tileContainerLayer->setName("TileController Container Layer");
11976#endif
120  [CATransaction commit];
 77 rootPlatformLayer->appendSublayer(m_tileContainerLayer.get());
12178}
12279
12380TileController::~TileController()
12481{
12582 ASSERT(isMainThread());
12683
127  for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
128  const TileInfo& tileInfo = it->value;
129  [tileInfo.layer.get() setTileController:0];
130  }
131 
 84 for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
 85 it->value.layer->setOwner(nullptr);
 86
13287 if (m_tiledScrollingIndicatorLayer)
133  [m_tiledScrollingIndicatorLayer.get() setTileController:nil];
 88 m_tiledScrollingIndicatorLayer->setOwner(nullptr);
13489}
13590
13691void TileController::tileCacheLayerBoundsChanged()
13792{
138  ASSERT(PlatformCALayer::platformCALayer(m_tileCacheLayer)->owner()->isCommittingChanges());
 93 ASSERT(m_tileCacheLayer->owner()->isCommittingChanges());
13994 setNeedsRevalidateTiles();
14095}
14196

@@void TileController::setNeedsDisplay()
14398{
14499 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
145100 const TileInfo& tileInfo = it->value;
146  [tileInfo.layer.get() setNeedsDisplay];
 101 tileInfo.layer->setNeedsDisplay();
147102 }
148103}
149104

@@void TileController::setNeedsDisplayInRect(const IntRect& rect)
180135
181136void TileController::setTileNeedsDisplayInRect(const TileIndex& tileIndex, TileInfo& tileInfo, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords)
182137{
183  WebTileLayer* tileLayer = tileInfo.layer.get();
 138 PlatformCALayer* tileLayer = tileInfo.layer.get();
184139
185140 IntRect tileRect = rectForTileIndex(tileIndex);
186  IntRect tileRepaintRect = tileRect;
 141 FloatRect tileRepaintRect = tileRect;
187142 tileRepaintRect.intersect(repaintRectInTileCoords);
188143 if (tileRepaintRect.isEmpty())
189144 return;

@@void TileController::setTileNeedsDisplayInRect(const TileIndex& tileIndex, TileI
193148 // We could test for intersection with the visible rect. This would reduce painting yet more,
194149 // but may make scrolling stale tiles into view more frequent.
195150 if (tileRect.intersects(coverageRectInTileCoords)) {
196  [tileLayer setNeedsDisplayInRect:tileRepaintRect];
 151 tileLayer->setNeedsDisplay(&tileRepaintRect);
197152
198  if (shouldShowRepaintCounters()) {
199  CGRect bounds = [tileLayer bounds];
200  CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 52, 27);
201  [tileLayer setNeedsDisplayInRect:indicatorRect];
 153 if (m_tileCacheLayer->owner()->platformCALayerShowRepaintCounter(0)) {
 154 FloatRect indicatorRect(0, 0, 52, 27);
 155 tileLayer->setNeedsDisplay(&indicatorRect);
202156 }
203157 } else
204158 tileInfo.hasStaleContent = true;
205159}
206160
207 
208 void TileController::drawLayer(WebTileLayer *layer, CGContextRef context)
 161void TileController::platformCALayerPaintContents(PlatformCALayer* platformCALayer, GraphicsContext& context, const IntRect&)
209162{
210  PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
211  if (!platformLayer)
 163 if (platformCALayer == m_tiledScrollingIndicatorLayer.get()) {
 164 drawTileMapContents(context.platformContext(), m_tiledScrollingIndicatorLayer->bounds());
212165 return;
 166 }
 167
 168 {
 169 GraphicsContextStateSaver stateSaver(context);
213170
214  CGContextSaveGState(context);
 171 FloatPoint3D layerOrigin = platformCALayer->position();
 172 context.translate(-layerOrigin.x(), -layerOrigin.y());
 173 context.scale(FloatSize(m_scale, m_scale));
 174
 175 drawLayerContents(context.platformContext(), m_tileCacheLayer);
 176 }
215177
216  CGPoint layerOrigin = [layer frame].origin;
217  CGContextTranslateCTM(context, -layerOrigin.x, -layerOrigin.y);
218  CGContextScaleCTM(context, m_scale, m_scale);
219  drawLayerContents(context, layer, platformLayer);
 178 int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
 179 if (m_tileCacheLayer->owner()->platformCALayerShowRepaintCounter(0))
 180 drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_tileDebugBorderColor, ColorSpaceDeviceRGB));
220181
221  CGContextRestoreGState(context);
 182 if (scrollingPerformanceLoggingEnabled()) {
 183 FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());
 184 visiblePart.intersect(visibleRect());
222185
223  drawRepaintCounter(layer, context);
 186 if (repaintCount == 1 && !visiblePart.isEmpty())
 187 WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), blankPixelCount());
 188 }
 189}
 190
 191float TileController::platformCALayerDeviceScaleFactor()
 192{
 193 return m_tileCacheLayer->owner()->platformCALayerDeviceScaleFactor();
 194}
 195
 196bool TileController::platformCALayerShowDebugBorders() const
 197{
 198 return m_tileCacheLayer->owner()->platformCALayerShowDebugBorders();
 199}
 200
 201bool TileController::platformCALayerShowRepaintCounter(PlatformCALayer*) const
 202{
 203 return m_tileCacheLayer->owner()->platformCALayerShowRepaintCounter(0);
224204}
225205
226206void TileController::setScale(CGFloat scale)
227207{
228  PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
229  ASSERT(platformLayer->owner()->isCommittingChanges());
 208 ASSERT(m_tileCacheLayer->owner()->isCommittingChanges());
230209
231  float deviceScaleFactor = platformLayer->owner()->platformCALayerDeviceScaleFactor();
 210 float deviceScaleFactor = m_tileCacheLayer->owner()->platformCALayerDeviceScaleFactor();
232211
233  // The scale we get is the produce of the page scale factor and device scale factor.
 212 // The scale we get is the product of the page scale factor and device scale factor.
234213 // Divide by the device scale factor so we'll get the page scale factor.
235214 scale /= deviceScaleFactor;
236215
237216 if (m_scale == scale && m_deviceScaleFactor == deviceScaleFactor)
238217 return;
239218
240  Vector<FloatRect> dirtyRects;
241 
242219 m_deviceScaleFactor = deviceScaleFactor;
243220 m_scale = scale;
244  [m_tileContainerLayer.get() setTransform:CATransform3DMakeScale(1 / m_scale, 1 / m_scale, 1)];
 221
 222 TransformationMatrix transform;
 223 transform.scale(1 / m_scale);
 224 m_tileContainerLayer->setTransform(transform);
245225
246226 // FIXME: we may revalidateTiles twice in this commit.
247227 revalidateTiles(PruneSecondaryTiles, PruneSecondaryTiles);
248228
249  for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
250  const TileInfo& tileInfo = it->value;
251  [tileInfo.layer.get() setContentsScale:deviceScaleFactor];
252 
253  IntRect tileRect = rectForTileIndex(it->key);
254  FloatRect scaledTileRect = tileRect;
255 
256  scaledTileRect.scale(1 / m_scale);
257  dirtyRects.append(scaledTileRect);
258  }
 229 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
 230 it->value.layer->setContentsScale(deviceScaleFactor);
259231}
260232
261233void TileController::setAcceleratesDrawing(bool acceleratesDrawing)

@@void TileController::setAcceleratesDrawing(bool acceleratesDrawing)
267239
268240 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
269241 const TileInfo& tileInfo = it->value;
270  [tileInfo.layer.get() setAcceleratesDrawing:m_acceleratesDrawing];
 242 tileInfo.layer->setAcceleratesDrawing(m_acceleratesDrawing);
271243 }
272244}
273245

@@void TileController::setTilesOpaque(bool opaque)
280252
281253 for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
282254 const TileInfo& tileInfo = it->value;
283  [tileInfo.layer.get() setOpaque:opaque];
 255 tileInfo.layer->setOpaque(opaque);
284256 }
285257}
286258
287259void TileController::setVisibleRect(const FloatRect& visibleRect)
288260{
289  ASSERT(PlatformCALayer::platformCALayer(m_tileCacheLayer)->owner()->isCommittingChanges());
 261 ASSERT(m_tileCacheLayer->owner()->isCommittingChanges());
290262 if (m_visibleRect == visibleRect)
291263 return;
292264

@@void TileController::setTileCoverage(TileCoverage coverage)
383355
384356void TileController::revalidateTiles()
385357{
386  ASSERT(PlatformCALayer::platformCALayer(m_tileCacheLayer)->owner()->isCommittingChanges());
 358 ASSERT(m_tileCacheLayer->owner()->isCommittingChanges());
387359 revalidateTiles(0, 0);
388360}
389361

@@void TileController::setTileDebugBorderWidth(float borderWidth)
400372 m_tileDebugBorderWidth = borderWidth;
401373 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
402374 const TileInfo& tileInfo = it->value;
403  [tileInfo.layer.get() setBorderWidth:m_tileDebugBorderWidth];
 375 tileInfo.layer->setBorderWidth(m_tileDebugBorderWidth);
404376 }
405377}
406378
407 void TileController::setTileDebugBorderColor(CGColorRef borderColor)
 379void TileController::setTileDebugBorderColor(Color borderColor)
408380{
409381 if (m_tileDebugBorderColor == borderColor)
410382 return;
411383
412384 m_tileDebugBorderColor = borderColor;
413  for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
414  const TileInfo& tileInfo = it->value;
415  [tileInfo.layer.get() setBorderColor:m_tileDebugBorderColor.get()];
416  }
 385 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
 386 it->value.layer->setBorderColor(borderColor);
417387}
418388
419389IntRect TileController::bounds() const
420390{
421  return IntRect(IntPoint(), IntSize([m_tileCacheLayer bounds].size));
 391 return IntRect(IntPoint(), expandedIntSize(m_tileCacheLayer->bounds().size()));
422392}
423393
424394IntRect TileController::rectForTileIndex(const TileIndex& tileIndex) const

@@void TileController::tileRevalidationTimerFired(Timer<TileController>*)
523493
524494unsigned TileController::blankPixelCount() const
525495{
526  WebTileLayerList tiles(m_tiles.size());
 496 PlatformLayerList tiles(m_tiles.size());
527497
528  for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
529  tiles.append(it->value.layer);
 498 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
 499 if (PlatformLayer *layer = it->value.layer->platformLayer())
 500 tiles.append(layer);
 501 }
530502
531503 return blankPixelCountForTiles(tiles, m_visibleRect, IntPoint(0,0));
532504}
533505
534 unsigned TileController::blankPixelCountForTiles(const WebTileLayerList& tiles, const FloatRect& visibleRect, const IntPoint& tileTranslation)
 506unsigned TileController::blankPixelCountForTiles(const PlatformLayerList& tiles, const FloatRect& visibleRect, const IntPoint& tileTranslation)
535507{
536508 Region paintedVisibleTiles;
537509
538  for (WebTileLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
539  const WebTileLayer* tileLayer = it->get();
 510 for (PlatformLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
 511 const PlatformLayer* tileLayer = it->get();
540512
541513 FloatRect visiblePart(CGRectOffset([tileLayer frame], tileTranslation.x(), tileTranslation.y()));
542514 visiblePart.intersect(visibleRect);

@@unsigned TileController::blankPixelCountForTiles(const WebTileLayerList& tiles,
551523 return uncoveredRegion.totalArea();
552524}
553525
554 static inline void queueTileForRemoval(const TileController::TileIndex& tileIndex, const TileController::TileInfo& tileInfo, Vector<TileController::TileIndex>& tilesToRemove)
 526static inline void queueTileForRemoval(const TileController::TileIndex& tileIndex, const TileController::TileInfo& tileInfo, Vector<TileController::TileIndex>& tilesToRemove, TileController::RepaintCountMap& repaintCounts)
555527{
556  WebTileLayer* tileLayer = tileInfo.layer.get();
557  [tileLayer removeFromSuperlayer];
558  [tileLayer setTileController:0];
 528 tileInfo.layer->removeFromSuperlayer();
 529 repaintCounts.remove(tileInfo.layer.get());
559530 tilesToRemove.append(tileIndex);
560531}
561532

@@void TileController::removeAllTiles()
564535 Vector<TileIndex> tilesToRemove;
565536
566537 for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
567  queueTileForRemoval(it->key, it->value, tilesToRemove);
 538 queueTileForRemoval(it->key, it->value, tilesToRemove, m_tileRepaintCounts);
568539
569540 for (size_t i = 0; i < tilesToRemove.size(); ++i) {
570541 TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);

@@void TileController::removeAllSecondaryTiles()
581552 if (tileInfo.cohort == VisibleTileCohort)
582553 continue;
583554
584  queueTileForRemoval(it->key, it->value, tilesToRemove);
 555 queueTileForRemoval(it->key, it->value, tilesToRemove, m_tileRepaintCounts);
585556 }
586557
587558 for (size_t i = 0; i < tilesToRemove.size(); ++i) {

@@void TileController::removeTilesInCohort(TileCohort cohort)
600571 if (tileInfo.cohort != cohort)
601572 continue;
602573
603  queueTileForRemoval(it->key, it->value, tilesToRemove);
 574 queueTileForRemoval(it->key, it->value, tilesToRemove, m_tileRepaintCounts);
604575 }
605576
606577 for (size_t i = 0; i < tilesToRemove.size(); ++i) {

@@void TileController::removeTilesInCohort(TileCohort cohort)
611582
612583void TileController::setNeedsRevalidateTiles()
613584{
614  PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
615  platformLayer->owner()->platformCALayerSetNeedsToRevalidateTiles();
 585 m_tileCacheLayer->owner()->platformCALayerSetNeedsToRevalidateTiles();
616586}
617587
618588void TileController::revalidateTiles(TileValidationPolicyFlags foregroundValidationPolicy, TileValidationPolicyFlags backgroundValidationPolicy)
619589{
620  // If the underlying PlatformLayer has been destroyed, but the WebTiledBackingLayer hasn't
621  // platformLayer will be null here.
622  PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
623  if (!platformLayer)
624  return;
625 
626590 FloatRect visibleRect = m_visibleRect;
627591 IntRect bounds = this->bounds();
628592

@@void TileController::revalidateTiles(TileValidationPolicyFlags foregroundValidat
655619 TileInfo& tileInfo = it->value;
656620 TileIndex tileIndex = it->key;
657621
658  WebTileLayer* tileLayer = tileInfo.layer.get();
 622 PlatformCALayer* tileLayer = tileInfo.layer.get();
659623 IntRect tileRect = rectForTileIndex(tileIndex);
660624 if (tileRect.intersects(coverageRectInTileCoords)) {
661625 tileInfo.cohort = VisibleTileCohort;
662626 if (tileInfo.hasStaleContent) {
663627 // FIXME: store a dirty region per layer?
664  [tileLayer setNeedsDisplay];
 628 tileLayer->setNeedsDisplay();
665629 tileInfo.hasStaleContent = false;
666630 }
667631 } else {

@@void TileController::revalidateTiles(TileValidationPolicyFlags foregroundValidat
671635 ++tilesInCohort;
672636
673637 if (m_unparentsOffscreenTiles)
674  [tileInfo.layer.get() removeFromSuperlayer];
 638 tileLayer->removeFromSuperlayer();
675639 }
676640 }
677641 }

@@void TileController::revalidateTiles(TileValidationPolicyFlags foregroundValidat
697661
698662 if (m_unparentsOffscreenTiles && (validationPolicy & UnparentAllTiles)) {
699663 for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
700  [it->value.layer.get() removeFromSuperlayer];
 664 it->value.layer->removeFromSuperlayer();
701665 }
702666
703667 if (m_boundsAtLastRevalidate != bounds) {

@@void TileController::revalidateTiles(TileValidationPolicyFlags foregroundValidat
716680 || index.y() > bottomRightForBounds.y()
717681 || index.x() < topLeftForBounds.x()
718682 || index.x() > bottomRightForBounds.x())
719  queueTileForRemoval(index, it->value, tilesToRemove);
 683 queueTileForRemoval(index, it->value, tilesToRemove, m_tileRepaintCounts);
720684 }
721685
722686 for (size_t i = 0, size = tilesToRemove.size(); i < size; ++i) {

@@IntRect TileController::ensureTilesForRect(const FloatRect& rect, CoverageType n
788752 if (m_unparentsOffscreenTiles && !m_isInWindow)
789753 return IntRect();
790754
791  PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
792  if (!platformLayer)
793  return IntRect();
794 
795755 FloatRect scaledRect(rect);
796756 scaledRect.scale(m_scale);
797757 IntRect rectInTileCoords(enclosingIntRect(scaledRect));

@@IntRect TileController::ensureTilesForRect(const FloatRect& rect, CoverageType n
800760 TileIndex bottomRight;
801761 getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight);
802762
803  Vector<FloatRect> dirtyRects;
804763 TileCohort currCohort = nextTileCohort();
805764 unsigned tilesInCohort = 0;
806765

@@IntRect TileController::ensureTilesForRect(const FloatRect& rect, CoverageType n
821780 tileInfo.layer = createTileLayer(tileRect);
822781 else {
823782 // We already have a layer for this tile. Ensure that its size is correct.
824  FloatSize tileLayerSize([tileInfo.layer.get() frame].size);
 783 FloatSize tileLayerSize(tileInfo.layer->bounds().size());
825784 shouldChangeTileLayerFrame = tileLayerSize != FloatSize(tileRect.size());
826785
827  if (shouldChangeTileLayerFrame)
828  [tileInfo.layer.get() setFrame:tileRect];
 786 if (shouldChangeTileLayerFrame) {
 787 tileInfo.layer->setBounds(FloatRect(FloatPoint(), tileRect.size()));
 788 tileInfo.layer->setPosition(tileRect.location());
 789 }
829790 }
830791
831792 if (newTileType == CoverageType::SecondaryTiles && !tileRect.intersects(m_primaryTileCoverageRect)) {

@@IntRect TileController::ensureTilesForRect(const FloatRect& rect, CoverageType n
833794 ++tilesInCohort;
834795 }
835796
836  bool shouldParentTileLayer = (!m_unparentsOffscreenTiles || m_isInWindow) && ![tileInfo.layer.get() superlayer];
 797 bool shouldParentTileLayer = (!m_unparentsOffscreenTiles || m_isInWindow) && !tileInfo.layer->superlayer();
837798
838799 if (shouldParentTileLayer)
839  [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()];
840 
841  if ((shouldParentTileLayer && [tileInfo.layer.get() needsDisplay]) || shouldChangeTileLayerFrame) {
842  FloatRect scaledTileRect = tileRect;
843  scaledTileRect.scale(1 / m_scale);
844  dirtyRects.append(scaledTileRect);
845  }
 800 m_tileContainerLayer->appendSublayer(tileInfo.layer.get());
846801 }
847802 }
848803

@@void TileController::updateTileCoverageMap()
872827 float indicatorScale = scale * m_scale;
873828 FloatRect mapBounds = containerBounds;
874829 mapBounds.scale(indicatorScale, indicatorScale);
875 
876  BEGIN_BLOCK_OBJC_EXCEPTIONS
877 
 830
878831 if (m_clipsToExposedRect)
879  [m_tiledScrollingIndicatorLayer.get() setPosition:m_exposedRect.location() + FloatPoint(2, 2)];
 832 m_tiledScrollingIndicatorLayer->setPosition(m_exposedRect.location() + FloatPoint(2, 2));
880833 else
881  [m_tiledScrollingIndicatorLayer.get() setPosition:CGPointMake(2, 2)];
 834 m_tiledScrollingIndicatorLayer->setPosition(FloatPoint(2, 2));
882835
883  [m_tiledScrollingIndicatorLayer.get() setBounds:mapBounds];
884  [m_tiledScrollingIndicatorLayer.get() setNeedsDisplay];
 836 m_tiledScrollingIndicatorLayer->setBounds(mapBounds);
 837 m_tiledScrollingIndicatorLayer->setNeedsDisplay();
885838
886839 visibleRect.scale(indicatorScale, indicatorScale);
887840 visibleRect.expand(2, 2);
888  [[m_tiledScrollingIndicatorLayer.get() visibleRectFrameLayer] setFrame:visibleRect];
 841 m_visibleRectIndicatorLayer->setPosition(visibleRect.location());
 842 m_visibleRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), visibleRect.size()));
889843
890  Color backgroundColor;
 844 Color visibleRectIndicatorColor;
891845 switch (m_indicatorMode) {
892846 case MainThreadScrollingBecauseOfStyleIndication:
893  backgroundColor = Color(255, 0, 0);
 847 visibleRectIndicatorColor = Color(255, 0, 0);
894848 break;
895849 case MainThreadScrollingBecauseOfEventHandlersIndication:
896  backgroundColor = Color(255, 255, 0);
 850 visibleRectIndicatorColor = Color(255, 255, 0);
897851 break;
898852 case ThreadedScrollingIndication:
899  backgroundColor = Color(0, 200, 0);
 853 visibleRectIndicatorColor = Color(0, 200, 0);
900854 break;
901855 }
902856
903  [[m_tiledScrollingIndicatorLayer.get() visibleRectFrameLayer] setBorderColor:cachedCGColor(backgroundColor, ColorSpaceDeviceRGB)];
904 
905  END_BLOCK_OBJC_EXCEPTIONS
 857 m_visibleRectIndicatorLayer->setBorderColor(visibleRectIndicatorColor);
906858}
907859
908860IntRect TileController::tileGridExtent() const

@@double TileController::retainedTileBackingStoreMemory() const
921873
922874 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
923875 const TileInfo& tileInfo = it->value;
924  if ([tileInfo.layer.get() superlayer]) {
925  CGRect bounds = [tileInfo.layer.get() bounds];
926  double contentsScale = [tileInfo.layer.get() contentsScale];
927  totalBytes += 4 * bounds.size.width * contentsScale * bounds.size.height * contentsScale;
 876 if (tileInfo.layer->superlayer()) {
 877 FloatRect bounds = tileInfo.layer->bounds();
 878 double contentsScale = tileInfo.layer->contentsScale();
 879 totalBytes += 4 * bounds.width() * contentsScale * bounds.height() * contentsScale;
928880 }
929881 }
930882

@@IntRect TileController::tileCoverageRect() const
939891 return coverageRectInLayerCoords;
940892}
941893
942 CALayer *TileController::tiledScrollingIndicatorLayer()
 894PlatformCALayer* TileController::tiledScrollingIndicatorLayer()
943895{
944896 if (!m_tiledScrollingIndicatorLayer) {
945  m_tiledScrollingIndicatorLayer = [WebTiledScrollingIndicatorLayer layer];
946  [m_tiledScrollingIndicatorLayer.get() setTileController:this];
947  [m_tiledScrollingIndicatorLayer.get() setOpacity:0.75];
948  [m_tiledScrollingIndicatorLayer.get() setAnchorPoint:CGPointZero];
949  [m_tiledScrollingIndicatorLayer.get() setBorderColor:cachedCGColor(Color::black, ColorSpaceDeviceRGB)];
950  [m_tiledScrollingIndicatorLayer.get() setBorderWidth:1];
951  [m_tiledScrollingIndicatorLayer.get() setPosition:CGPointMake(2, 2)];
 897 m_tiledScrollingIndicatorLayer = PlatformCALayerMac::create(PlatformCALayer::LayerTypeSimpleLayer, this);
 898 m_tiledScrollingIndicatorLayer->setOpacity(0.75);
 899 m_tiledScrollingIndicatorLayer->setAnchorPoint(FloatPoint3D());
 900 m_tiledScrollingIndicatorLayer->setBorderColor(Color::black);
 901 m_tiledScrollingIndicatorLayer->setBorderWidth(1);
 902 m_tiledScrollingIndicatorLayer->setPosition(FloatPoint(2, 2));
 903
 904 m_visibleRectIndicatorLayer = PlatformCALayerMac::create(PlatformCALayer::LayerTypeLayer, nullptr);
 905 m_visibleRectIndicatorLayer->setBorderWidth(2);
 906 m_visibleRectIndicatorLayer->setAnchorPoint(FloatPoint3D());
 907 m_visibleRectIndicatorLayer->setBorderColor(Color(255, 0, 0));
 908
 909 m_tiledScrollingIndicatorLayer->appendSublayer(m_visibleRectIndicatorLayer.get());
 910
952911 updateTileCoverageMap();
953912 }
954913

@@void TileController::setScrollingModeIndication(ScrollingModeIndication scrollin
966925 updateTileCoverageMap();
967926}
968927
969 WebTileLayer* TileController::tileLayerAtIndex(const TileIndex& index) const
 928RefPtr<PlatformCALayer> TileController::createTileLayer(const IntRect& tileRect)
970929{
971  return m_tiles.get(index).layer.get();
972 }
 930 RefPtr<PlatformCALayer> layer = LayerPool::sharedPool()->takeLayerWithSize(tileRect.size());
973931
974 RetainPtr<WebTileLayer> TileController::createTileLayer(const IntRect& tileRect)
975 {
976  RetainPtr<WebTileLayer> layer = LayerPool::sharedPool()->takeLayerWithSize(tileRect.size());
977  if (layer)
978  [layer resetPaintCount];
979  else
980  layer = adoptNS([[WebTileLayer alloc] init]);
981  [layer.get() setAnchorPoint:CGPointZero];
982  [layer.get() setFrame:tileRect];
983  [layer.get() setTileController:this];
984  [layer.get() setBorderColor:m_tileDebugBorderColor.get()];
985  [layer.get() setBorderWidth:m_tileDebugBorderWidth];
986  [layer.get() setEdgeAntialiasingMask:0];
987  [layer.get() setOpaque:m_tilesAreOpaque];
 932 if (layer) {
 933 m_tileRepaintCounts.remove(layer.get());
 934 layer->setOwner(this);
 935 } else
 936 layer = PlatformCALayerMac::create(PlatformCALayer::LayerTypeTiledBackingTileLayer, this);
 937
 938 layer->setAnchorPoint(FloatPoint3D());
 939 layer->setBounds(FloatRect(FloatPoint(), tileRect.size()));
 940 layer->setPosition(tileRect.location());
 941 layer->setBorderColor(m_tileDebugBorderColor);
 942 layer->setBorderWidth(m_tileDebugBorderWidth);
 943 layer->setEdgeAntialiasingMask(0);
 944 layer->setOpaque(m_tilesAreOpaque);
988945#ifndef NDEBUG
989  [layer.get() setName:@"Tile"];
 946 layer->setName("Tile");
990947#endif
991948
992  [layer.get() setContentsScale:m_deviceScaleFactor];
993  [layer.get() setAcceleratesDrawing:m_acceleratesDrawing];
 949 layer->setContentsScale(m_deviceScaleFactor);
 950 layer->setAcceleratesDrawing(m_acceleratesDrawing);
994951
995  [layer setNeedsDisplay];
 952 layer->setNeedsDisplay();
996953
997954 return layer;
998955}
999956
1000 bool TileController::shouldShowRepaintCounters() const
 957int TileController::platformCALayerIncrementRepaintCount(PlatformCALayer* platformCALayer)
1001958{
1002  PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
1003  if (!platformLayer)
1004  return false;
1005 
1006  WebCore::PlatformCALayerClient* layerContents = platformLayer->owner();
1007  ASSERT(layerContents);
1008  if (!layerContents)
1009  return false;
1010 
1011  return layerContents->platformCALayerShowRepaintCounter(0);
1012 }
 959 int repaintCount = 0;
1013960
1014 void TileController::drawRepaintCounter(WebTileLayer *layer, CGContextRef context)
1015 {
1016  unsigned paintCount = [layer incrementPaintCount];
1017  if (!shouldShowRepaintCounters())
1018  return;
1019 
1020  // FIXME: Some of this code could be shared with WebLayer.
1021  char text[16]; // that's a lot of repaints
1022  snprintf(text, sizeof(text), "%d", paintCount);
1023 
1024  CGRect indicatorBox = [layer bounds];
1025  indicatorBox.size.width = 12 + 10 * strlen(text);
1026  indicatorBox.size.height = 27;
1027  CGContextSaveGState(context);
1028 
1029  CGContextSetAlpha(context, 0.5f);
1030  CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
1031 
1032  CGContextSetFillColorWithColor(context, m_tileDebugBorderColor.get());
1033  CGContextFillRect(context, indicatorBox);
1034 
1035  PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
1036 
1037  if (platformLayer->acceleratesDrawing())
1038  CGContextSetRGBFillColor(context, 1, 0, 0, 1);
1039  else
1040  CGContextSetRGBFillColor(context, 1, 1, 1, 1);
 961 if (m_tileRepaintCounts.contains(platformCALayer))
 962 repaintCount = m_tileRepaintCounts.get(platformCALayer);
1041963
1042 #pragma clang diagnostic push
1043 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
1044  CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
1045  CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
1046  CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
1047 #pragma clang diagnostic pop
 964 m_tileRepaintCounts.set(platformCALayer, ++repaintCount);
1048965
1049  CGContextEndTransparencyLayer(context);
1050  CGContextRestoreGState(context);
 966 return repaintCount;
1051967}
1052968
1053969void TileController::drawTileMapContents(CGContextRef context, CGRect layerBounds)

@@void TileController::drawTileMapContents(CGContextRef context, CGRect layerBound
1062978
1063979 for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
1064980 const TileInfo& tileInfo = it->value;
1065  WebTileLayer* tileLayer = tileInfo.layer.get();
 981 PlatformCALayer* tileLayer = tileInfo.layer.get();
1066982
1067983 CGFloat red = 1;
1068984 CGFloat green = 1;

@@void TileController::drawTileMapContents(CGContextRef context, CGRect layerBound
1082998 } else
1083999 CGContextSetRGBFillColor(context, red, green, blue, 1);
10841000
1085  if ([tileLayer superlayer]) {
 1001 if (tileLayer->superlayer()) {
10861002 CGContextSetLineWidth(context, 0.5 / contextScale);
10871003 CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
10881004 } else {

@@void TileController::drawTileMapContents(CGContextRef context, CGRect layerBound
10901006 CGContextSetRGBStrokeColor(context, 0.2, 0.1, 0.9, 1);
10911007 }
10921008
1093  CGRect frame = [tileLayer frame];
 1009 CGRect frame = CGRectMake(tileLayer->position().x(), tileLayer->position().y(), tileLayer->bounds().size().width(), tileLayer->bounds().size().height());
10941010 CGContextFillRect(context, frame);
10951011 CGContextStrokeRect(context, frame);
10961012 }

Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h

1 /*
2  * Copyright (C) 2011 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef WebTileLayer_h
27 #define WebTileLayer_h
28 
29 namespace WebCore {
30 class TileController;
31 }
32 
33 @interface WebTileLayer : CALayer {
34  WebCore::TileController* _tileController;
35  unsigned _paintCount;
36 }
37 
38 - (void)setTileController:(WebCore::TileController*)tileController;
39 - (void)resetPaintCount;
40 - (unsigned)incrementPaintCount;
41 - (unsigned)paintCount;
42 @end
43 
44 
45 #endif // WebTileLayer_h

Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm

1 /*
2  * Copyright (C) 2011 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #import "config.h"
27 #import "WebTileLayer.h"
28 
29 #import "TileController.h"
30 #import <wtf/CurrentTime.h>
31 
32 using namespace WebCore;
33 
34 @interface WebTileLayer (ScrollingPerformanceLoggingInternal)
35 - (void)logFilledFreshTile;
36 @end
37 
38 @implementation WebTileLayer
39 
40 - (id<CAAction>)actionForKey:(NSString *)key
41 {
42  UNUSED_PARAM(key);
43 
44  // Disable all animations.
45  return nil;
46 }
47 
48 - (void)drawInContext:(CGContextRef)context
49 {
50  if (_tileController) {
51  _tileController->drawLayer(self, context);
52 
53  if (static_cast<TiledBacking*>(_tileController)->scrollingPerformanceLoggingEnabled())
54  [self logFilledFreshTile];
55  }
56 }
57 
58 - (void)setTileController:(WebCore::TileController*)tileController
59 {
60  _tileController = tileController;
61 }
62 
63 - (void)resetPaintCount
64 {
65  _paintCount = 0;
66 }
67 
68 - (unsigned)incrementPaintCount
69 {
70  return ++_paintCount;
71 }
72 
73 - (unsigned)paintCount
74 {
75  return _paintCount;
76 }
77 
78 - (void)logFilledFreshTile
79 {
80  FloatRect visiblePart([self frame]);
81  visiblePart.intersect(_tileController->visibleRect());
82 
83  if ([self paintCount] == 1 && !visiblePart.isEmpty())
84  WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), _tileController->blankPixelCount());
85 }
86 
87 @end
88 

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

3131
3232namespace WebCore {
3333class IntRect;
 34class PlatformCALayer;
3435class TileController;
3536class TiledBacking;
3637}

@@class TiledBacking;
3940 OwnPtr<WebCore::TileController> _tileController;
4041}
4142
42 - (CALayer *)tileContainerLayer;
 43- (WebCore::TileController*)createTileController:(WebCore::PlatformCALayer*)rootLayer;
4344- (WebCore::TiledBacking*)tiledBacking;
4445- (void)invalidate;
4546

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

@@using namespace WebCore;
4040 if (!self)
4141 return nil;
4242
43  _tileController = TileController::create(self);
4443#ifndef NDEBUG
4544 [self setName:@"WebTiledBackingLayer"];
4645#endif

@@using namespace WebCore;
6261 return nil;
6362}
6463
 64- (TileController*)createTileController:(PlatformCALayer*)rootLayer
 65{
 66 ASSERT(!_tileController);
 67 _tileController = TileController::create(rootLayer);
 68 return _tileController.get();
 69}
 70
6571- (id<CAAction>)actionForKey:(NSString *)key
6672{
6773 UNUSED_PARAM(key);

@@using namespace WebCore;
112118 _tileController->setScale(contentsScale);
113119}
114120
115 - (CALayer *)tileContainerLayer
116 {
117  return _tileController->tileContainerLayer();
118 }
119 
120121- (WebCore::TiledBacking*)tiledBacking
121122{
122123 return _tileController.get();

@@using namespace WebCore;
131132
132133- (void)setBorderColor:(CGColorRef)borderColor
133134{
134  _tileController->setTileDebugBorderColor(borderColor);
 135 _tileController->setTileDebugBorderColor(Color(borderColor));
135136}
136137
137138- (void)setBorderWidth:(CGFloat)borderWidth

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

@@public:
126126 virtual float contentsScale() const OVERRIDE;
127127 virtual void setContentsScale(float) OVERRIDE;
128128
 129 virtual void setEdgeAntialiasingMask(unsigned) OVERRIDE { ASSERT_NOT_REACHED(); }
 130
129131 virtual TiledBacking* tiledBacking() OVERRIDE { return nullptr; }
130132
131133 virtual PlatformCALayer* rootLayer() const OVERRIDE;

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

@@void PlatformCALayerWinInternal::displayCallback(CACFLayerRef caLayer, CGContext
8383 // smaller than the layer bounds (e.g. tiled layers)
8484 CGRect clipBounds = CGContextGetClipBoundingBox(context);
8585 IntRect clip(enclosingIntRect(clipBounds));
86  owner()->owner()->platformCALayerPaintContents(graphicsContext, clip);
 86 owner()->owner()->platformCALayerPaintContents(owner(), graphicsContext, clip);
8787 }
8888#ifndef NDEBUG
8989 else {

@@void PlatformCALayerWinInternal::displayCallback(CACFLayerRef caLayer, CGContext
9999 if (owner()->owner()->platformCALayerShowRepaintCounter(owner())) {
100100 FontCachePurgePreventer fontCachePurgePreventer;
101101
102  String text = String::number(owner()->owner()->platformCALayerIncrementRepaintCount());
 102 String text = String::number(owner()->owner()->platformCALayerIncrementRepaintCount(owner()));
103103
104104 CGContextSaveGState(context);
105105

Source/WebCore/platform/graphics/mac/WebLayer.h

3535const unsigned webLayerMaxRectsToPaint = 5;
3636const float webLayerWastedSpaceThreshold = 0.75f;
3737
38 @interface WebLayer : CALayer
 38@interface WebSimpleLayer : CALayer
 39@end
 40
 41@interface WebLayer : WebSimpleLayer
3942@end
4043
4144namespace WebCore {

@@class PlatformCALayer;
4447class PlatformCALayerClient;
4548
4649// Functions allows us to share implementation across WebTiledLayer and WebLayer
47 void drawLayerContents(CGContextRef, CALayer *, WebCore::PlatformCALayer*);
48 void drawLayerContents(CGContextRef, WebCore::PlatformCALayer*, WebCore::FloatRect layerBounds, Vector<WebCore::FloatRect, webLayerMaxRectsToPaint> dirtyRects, bool isTiledLayer);
 50void drawLayerContents(CGContextRef, WebCore::PlatformCALayer*);
 51void drawLayerContents(CGContextRef, WebCore::PlatformCALayer*, Vector<WebCore::FloatRect, webLayerMaxRectsToPaint> dirtyRects);
 52void drawRepaintIndicator(CGContextRef, WebCore::PlatformCALayer*, int repaintCount, CGColorRef customBackgroundColor);
4953}
5054
5155#endif // USE(ACCELERATED_COMPOSITING)

Source/WebCore/platform/graphics/mac/WebLayer.mm

@@using namespace WebCore;
4545
4646namespace WebCore {
4747
48 void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCALayer* platformLayer)
 48void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformCALayer)
4949{
50  CGRect layerBounds = [layer bounds];
51 
5250 __block double totalRectArea = 0;
5351 __block unsigned rectCount = 0;
5452 __block Vector<FloatRect, webLayerMaxRectsToPaint> dirtyRects;
5553
56  wkCALayerEnumerateRectsBeingDrawnWithBlock(layer, context, ^(CGRect rect) {
57  if (++rectCount > webLayerMaxRectsToPaint)
58  return;
 54 if (PlatformLayer *platformLayer = platformCALayer->platformLayer()) {
 55 wkCALayerEnumerateRectsBeingDrawnWithBlock(platformLayer, context, ^(CGRect rect) {
 56 if (++rectCount > webLayerMaxRectsToPaint)
 57 return;
5958
60  totalRectArea += rect.size.width * rect.size.height;
61  dirtyRects.append(rect);
62  });
 59 totalRectArea += rect.size.width * rect.size.height;
 60 dirtyRects.append(rect);
 61 });
 62 }
6363
6464 FloatRect clipBounds = CGContextGetClipBoundingBox(context);
6565 double clipArea = clipBounds.width() * clipBounds.height();

@@void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCA
6767 if (rectCount >= webLayerMaxRectsToPaint || totalRectArea >= clipArea * webLayerWastedSpaceThreshold)
6868 dirtyRects.clear();
6969
70  bool isTiledLayer = [layer isKindOfClass:[CATiledLayer class]];
71  drawLayerContents(context, platformLayer, layerBounds, dirtyRects, isTiledLayer);
 70 drawLayerContents(context, platformCALayer, dirtyRects);
7271}
7372
74 void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformLayer, FloatRect layerBounds, Vector<FloatRect, webLayerMaxRectsToPaint> dirtyRects, bool isTiledLayer)
 73void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformCALayer, Vector<FloatRect, webLayerMaxRectsToPaint> dirtyRects)
7574{
76  WebCore::PlatformCALayerClient* layerContents = platformLayer->owner();
 75 WebCore::PlatformCALayerClient* layerContents = platformCALayer->owner();
7776 if (!layerContents)
7877 return;
7978
8079 CGContextSaveGState(context);
8180
8281 if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) {
 82 FloatRect layerBounds = platformCALayer->bounds();
8383 CGContextScaleCTM(context, 1, -1);
8484 CGContextTranslateCTM(context, 0, -layerBounds.height());
8585 }

@@void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformL
9393
9494 GraphicsContext graphicsContext(context);
9595 graphicsContext.setIsCALayerContext(true);
96  graphicsContext.setIsAcceleratedContext(platformLayer->acceleratesDrawing());
 96 graphicsContext.setIsAcceleratedContext(platformCALayer->acceleratesDrawing());
9797
9898 if (!layerContents->platformCALayerContentsOpaque()) {
9999 // Turn off font smoothing to improve the appearance of text rendered onto a transparent background.

@@void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformL
116116 if (dirtyRects.isEmpty()) {
117117 // CGContextGetClipBoundingBox() gives us the bounds of the dirty region, so clipBounds
118118 // encompasses all the dirty rects.
119  layerContents->platformCALayerPaintContents(graphicsContext, enclosingIntRect(clipBounds));
 119 layerContents->platformCALayerPaintContents(platformCALayer, graphicsContext, enclosingIntRect(clipBounds));
120120 } else {
121121 for (unsigned i = 0; i < dirtyRects.size(); ++i) {
122122 const FloatRect& currentRect = dirtyRects[i];

@@void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformL
124124 GraphicsContextStateSaver stateSaver(graphicsContext);
125125 graphicsContext.clip(currentRect);
126126
127  layerContents->platformCALayerPaintContents(graphicsContext, enclosingIntRect(currentRect));
 127 layerContents->platformCALayerPaintContents(platformCALayer, graphicsContext, enclosingIntRect(currentRect));
128128 }
129129 }
130130

@@void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformL
133133 [NSGraphicsContext restoreGraphicsState];
134134
135135 // Re-fetch the layer owner, since <rdar://problem/9125151> indicates that it might have been destroyed during painting.
136  layerContents = platformLayer->owner();
 136 layerContents = platformCALayer->owner();
137137 ASSERT(layerContents);
138138
139139 CGContextRestoreGState(context);
140140
141141 // Always update the repaint count so that it's accurate even if the count itself is not shown. This will be useful
142  // for the Web Inspector feeding this information through the LayerTreeAgent.
143  int repaintCount = layerContents->platformCALayerIncrementRepaintCount();
144 
145  if (!platformLayer->usesTiledBackingLayer() && layerContents && layerContents->platformCALayerShowRepaintCounter(platformLayer)) {
146  char text[16]; // that's a lot of repaints
147  snprintf(text, sizeof(text), "%d", repaintCount);
148 
149  CGRect indicatorBox = layerBounds;
150  indicatorBox.size.width = 12 + 10 * strlen(text);
151  indicatorBox.size.height = 27;
152  CGContextSaveGState(context);
153 
154  CGContextSetAlpha(context, 0.5f);
155  CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
156 
157  if (isTiledLayer)
158  CGContextSetRGBFillColor(context, 1, 0.5f, 0, 1);
159  else
160  CGContextSetRGBFillColor(context, 0, 0.5f, 0.25f, 1);
161 
162  CGContextFillRect(context, indicatorBox);
163 
164  if (platformLayer->acceleratesDrawing())
165  CGContextSetRGBFillColor(context, 1, 0, 0, 1);
166  else
167  CGContextSetRGBFillColor(context, 1, 1, 1, 1);
 142 // for the Web Inspector feeding this information through the LayerTreeAgent.
 143 int repaintCount = layerContents->platformCALayerIncrementRepaintCount(platformCALayer);
 144
 145 if (!platformCALayer->usesTiledBackingLayer() && layerContents && layerContents->platformCALayerShowRepaintCounter(platformCALayer))
 146 drawRepaintIndicator(context, platformCALayer, repaintCount, nullptr);
 147}
 148
 149void drawRepaintIndicator(CGContextRef context, PlatformCALayer* platformCALayer, int repaintCount, CGColorRef customBackgroundColor)
 150{
 151 char text[16]; // that's a lot of repaints
 152 snprintf(text, sizeof(text), "%d", repaintCount);
 153
 154 CGRect indicatorBox = platformCALayer->bounds();
 155 indicatorBox.size.width = 12 + 10 * strlen(text);
 156 indicatorBox.size.height = 27;
 157 CGContextSaveGState(context);
 158
 159 CGContextSetAlpha(context, 0.5f);
 160 CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
 161
 162 if (customBackgroundColor)
 163 CGContextSetFillColorWithColor(context, customBackgroundColor);
 164 else
 165 CGContextSetRGBFillColor(context, 0, 0.5f, 0.25f, 1);
 166
 167 CGContextFillRect(context, indicatorBox);
 168
 169 if (platformCALayer->acceleratesDrawing())
 170 CGContextSetRGBFillColor(context, 1, 0, 0, 1);
 171 else
 172 CGContextSetRGBFillColor(context, 1, 1, 1, 1);
168173
169174#pragma clang diagnostic push
170175#pragma clang diagnostic ignored "-Wdeprecated-declarations"
171  CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
172  CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
173  CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
 176 CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
 177 CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
 178 CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
174179#pragma clang diagnostic pop
175180
176  CGContextEndTransparencyLayer(context);
177  CGContextRestoreGState(context);
178  }
 181 CGContextEndTransparencyLayer(context);
 182 CGContextRestoreGState(context);
179183}
180184
181185}
182186
183187@implementation WebLayer
184188
 189- (void)drawInContext:(CGContextRef)context
 190{
 191 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
 192 if (layer)
 193 drawLayerContents(context, layer);
 194}
 195
 196@end // implementation WebLayer
 197
 198@implementation WebSimpleLayer
 199
185200- (id<CAAction>)actionForKey:(NSString *)key
186201{
187202 // Fix for <rdar://problem/9015675>: Force the layer content to be updated when the tree is reparented.

@@void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformL
236251- (void)drawInContext:(CGContextRef)context
237252{
238253 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
239  if (layer)
240  drawLayerContents(context, self, layer);
 254 if (layer && layer->owner()) {
 255 GraphicsContext graphicsContext(context);
 256 graphicsContext.setIsCALayerContext(true);
 257 graphicsContext.setIsAcceleratedContext(layer->acceleratesDrawing());
 258
 259 FloatRect clipBounds = CGContextGetClipBoundingBox(context);
 260 layer->owner()->platformCALayerPaintContents(layer, graphicsContext, enclosingIntRect(clipBounds));
 261 }
241262}
242263
243 @end // implementation WebLayer
 264@end // implementation WebSimpleLayer
244265
245266// MARK: -
246267

Source/WebCore/platform/graphics/mac/WebTiledLayer.mm

@@using namespace WebCore;
107107{
108108 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
109109 if (layer)
110  drawLayerContents(context, self, layer);
 110 drawLayerContents(context, layer);
111111}
112112
113113@end // implementation WebTiledLayer

Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp

@@private:
100100
101101 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { }
102102 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
103  virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& inClip) { }
 103 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const IntRect& inClip) { }
104104 virtual bool platformCALayerShowDebugBorders() const { return false; }
105105 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; }
106  virtual int platformCALayerIncrementRepaintCount() { return 0; }
 106 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) { return 0; }
107107
108108 virtual bool platformCALayerContentsOpaque() const { return false; }
109109 virtual bool platformCALayerDrawsContent() const { return false; }

Source/WebKit/win/ChangeLog

 12013-10-25 Tim Horton <timothy_horton@apple.com>
 2
 3 Make TileController manipulate PlatformCALayers instead of CALayers
 4 https://bugs.webkit.org/show_bug.cgi?id=123279
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * FullscreenVideoController.cpp:
 9 (FullscreenVideoController::LayerClient::platformCALayerPaintContents):
 10 (FullscreenVideoController::LayerClient::platformCALayerIncrementRepaintCount):
 11 Adjust for new parameters on PlatformCALayerClient callbacks.
 12
1132013-10-16 Tim Horton <timothy_horton@apple.com>
214
315 Attempt to fix the Windows build after http://trac.webkit.org/changeset/157547.

Source/WebKit/win/FullscreenVideoController.cpp

@@private:
187187
188188 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { }
189189 virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
190  virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& inClip) { }
 190 virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const IntRect& inClip) { }
191191 virtual bool platformCALayerShowDebugBorders() const { return false; }
192192 virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; }
193  virtual int platformCALayerIncrementRepaintCount() { return 0; }
 193 virtual int platformCALayerIncrementRepaintCount(PlatformCALayer*) { return 0; }
194194
195195 virtual bool platformCALayerContentsOpaque() const { return false; }
196196 virtual bool platformCALayerDrawsContent() const { return false; }

Source/WebKit2/ChangeLog

 12013-10-24 Tim Horton <timothy_horton@apple.com>
 2
 3 Make TileController manipulate PlatformCALayers instead of CALayers
 4 https://bugs.webkit.org/show_bug.cgi?id=123279
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * Shared/mac/RemoteLayerTreeTransaction.mm:
 9 (WebKit::RemoteLayerTreeTransaction::dump):
 10 Support the new LayerTypes.
 11
 12 * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
 13 (PlatformCALayerRemote::setEdgeAntialiasingMask):
 14 * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
 15 Add an empty implementation of setEdgeAntialiasingMask.
 16
 17 * WebProcess/WebPage/mac/RemoteLayerBackingStore.mm:
 18 (RemoteLayerBackingStore::display):
 19 Removed a parameter from drawLayerContents.
 20
 21 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
 22 (WebKit::TiledCoreAnimationDrawingArea::updateDebugInfoLayer):
 23 TiledCoreAnimationDrawingArea still operates in terms of CALayers, so
 24 grab the PlatformLayer out from TileController's indicator.
 25
1262013-10-23 Tim Horton <timothy_horton@apple.com>
227
328 Remove the ifdef to exclude remote layer tree transaction logging

Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

@@void RemoteLayerTreeTransaction::dump() const
655655 switch (createdLayer.type) {
656656 case PlatformCALayer::LayerTypeLayer:
657657 case PlatformCALayer::LayerTypeWebLayer:
 658 case PlatformCALayer::LayerTypeSimpleLayer:
658659 ts << "layer";
659660 break;
660661 case PlatformCALayer::LayerTypeTransformLayer:

@@void RemoteLayerTreeTransaction::dump() const
669670 case PlatformCALayer::LayerTypePageTiledBackingLayer:
670671 ts << "page-tiled-backing-layer";
671672 break;
 673 case PlatformCALayer::LayerTypeTiledBackingTileLayer:
 674 ts << "tiled-backing-tile";
 675 break;
672676 case PlatformCALayer::LayerTypeRootLayer:
673677 ts << "root-layer";
674678 break;

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

@@void PlatformCALayerRemote::setContentsScale(float value)
462462 ensureBackingStore();
463463}
464464
 465void PlatformCALayerRemote::setEdgeAntialiasingMask(unsigned)
 466{
 467 ASSERT_NOT_REACHED();
 468}
 469
465470TiledBacking* PlatformCALayerRemote::tiledBacking()
466471{
467472 return nullptr;

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

@@public:
137137 virtual float contentsScale() const OVERRIDE;
138138 virtual void setContentsScale(float) OVERRIDE;
139139
 140 virtual void setEdgeAntialiasingMask(unsigned) OVERRIDE;
 141
140142 virtual WebCore::TiledBacking* tiledBacking() OVERRIDE;
141143
142144 virtual void synchronouslyDisplayTilesInRect(const WebCore::FloatRect&) OVERRIDE;

Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerBackingStore.mm

@@bool RemoteLayerBackingStore::display()
149149 }
150150
151151 context->scale(FloatSize(m_scale, m_scale));
152  drawLayerContents(context->platformContext(), m_layer, FloatRect(FloatPoint(), scaledSize), rectsToPaint, false);
 152 drawLayerContents(context->platformContext(), m_layer, rectsToPaint);
153153 m_dirtyRegion = Region();
154154
155155 m_frontBuffer = m_backBuffer;

Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

@@TiledBacking* TiledCoreAnimationDrawingArea::mainFrameTiledBacking() const
679679void TiledCoreAnimationDrawingArea::updateDebugInfoLayer(bool showLayer)
680680{
681681 if (showLayer) {
682  if (TiledBacking* tiledBacking = mainFrameTiledBacking())
683  m_debugInfoLayer = tiledBacking->tiledScrollingIndicatorLayer();
684 
 682 if (TiledBacking* tiledBacking = mainFrameTiledBacking()) {
 683 if (PlatformCALayer* indicatorLayer = tiledBacking->tiledScrollingIndicatorLayer())
 684 m_debugInfoLayer = indicatorLayer->platformLayer();
 685 }
 686
685687 if (m_debugInfoLayer) {
686688#ifndef NDEBUG
687689 [m_debugInfoLayer.get() setName:@"Debug Info"];