Changeset 75199 in webkit
- Timestamp:
- Jan 6, 2011 2:26:35 PM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r75198 r75199 1 2011-01-06 Chris Marrin <cmarrin@apple.com> 2 3 Reviewed by Simon Fraser. 4 5 Share code between Mac (CA) and Windows (CACF) GraphicsLayer implementations 6 https://bugs.webkit.org/show_bug.cgi?id=49388 7 8 Changed PlatformCALayer API. Added PlatformCALayerClient abstract class which is 9 used to communicate from PlatformCALayer to the owner. This replaces passing 10 GraphicsLayerCA pointer when creating PlatformCALayer. It also includes the 11 API that used to be in PlatformCALayerLayout. GraphicsLayerCA now implements 12 the PlatformCALayerClient API. 13 14 This change has little impact on the Mac side but makes the Windows 15 interface simpler, especially when handling video layers on Windows. 16 17 * WebCore.xcodeproj/project.pbxproj: 18 * config.h: 19 * platform/graphics/GraphicsLayer.h: 20 (WebCore::GraphicsLayer::layerDidDisplay): 21 (WebCore::GraphicsLayer::showDebugBorders): 22 (WebCore::GraphicsLayer::showRepaintCounter): 23 * platform/graphics/ca/GraphicsLayerCA.cpp: 24 (WebCore::GraphicsLayerCA::platformCALayerAnimationStarted): 25 (WebCore::GraphicsLayerCA::setContentsToImage): 26 (WebCore::GraphicsLayerCA::setContentsToMedia): 27 (WebCore::GraphicsLayerCA::layerDidDisplay): 28 (WebCore::GraphicsLayerCA::updateSublayerList): 29 * platform/graphics/ca/GraphicsLayerCA.h: 30 (WebCore::GraphicsLayerCA::platformCALayerLayoutSublayersOfLayer): 31 (WebCore::GraphicsLayerCA::platformCALayerRespondsToLayoutChanges): 32 (WebCore::GraphicsLayerCA::platformCALayerContentsOrientation): 33 (WebCore::GraphicsLayerCA::platformCALayerPaintContents): 34 (WebCore::GraphicsLayerCA::platformCALayerShowDebugBorders): 35 (WebCore::GraphicsLayerCA::platformCALayerShowRepaintCounter): 36 (WebCore::GraphicsLayerCA::platformCALayerIncrementRepaintCount): 37 (WebCore::GraphicsLayerCA::platformCALayerContentsOpaque): 38 (WebCore::GraphicsLayerCA::platformCALayerDrawsContent): 39 (WebCore::GraphicsLayerCA::platformCALayerLayerDidDisplay): 40 (WebCore::GraphicsLayerCA::platformCALayer): 41 * platform/graphics/ca/PlatformCALayer.h: 42 (WebCore::PlatformCALayer::owner): 43 (WebCore::PlatformCALayer::animationStarted): 44 * platform/graphics/ca/PlatformCALayerClient.h: Added. 45 (WebCore::PlatformCALayerClient::~PlatformCALayerClient): 46 * platform/graphics/ca/mac/PlatformCALayerMac.mm: 47 (PlatformCALayer::setOwner): 48 (PlatformCALayer::create): 49 (PlatformCALayer::PlatformCALayer): 50 (PlatformCALayer::contents): 51 (PlatformCALayer::setContents): 52 * platform/graphics/mac/WebGLLayer.mm: 53 (-[WebGLLayer display]): 54 * platform/graphics/mac/WebLayer.h: 55 * platform/graphics/mac/WebLayer.mm: 56 (drawLayerContents): 57 (setLayerNeedsDisplayInRect): 58 (-[WebLayer setNeedsDisplay]): 59 (-[WebLayer display]): 60 * platform/graphics/mac/WebTiledLayer.mm: 61 (-[WebTiledLayer setNeedsDisplay]): 62 (-[WebTiledLayer display]): 63 * rendering/RenderLayerBacking.cpp: 64 (WebCore::RenderLayerBacking::showDebugBorders): 65 (WebCore::RenderLayerBacking::showRepaintCounter): 66 * rendering/RenderLayerCompositor.cpp: 67 (WebCore::RenderLayerCompositor::ensureRootPlatformLayer): 68 * rendering/RenderLayerCompositor.h: 69 (WebCore::RenderLayerCompositor::compositorShowDebugBorders): 70 (WebCore::RenderLayerCompositor::compositorShowRepaintCounter): 71 (WebCore::RenderLayerCompositor::notifyAnimationStarted): 72 (WebCore::RenderLayerCompositor::notifySyncRequired): 73 (WebCore::RenderLayerCompositor::paintContents): 74 (WebCore::RenderLayerCompositor::showDebugBorders): 75 (WebCore::RenderLayerCompositor::showRepaintCounter): 76 1 77 2011-01-06 Tony Gentilcore <tonyg@chromium.org> 2 78 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r75169 r75199 1008 1008 490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; }; 1009 1009 492863991253B8FC00F792D6 /* ResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 492863981253B8FC00F792D6 /* ResourceLoadInfo.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1010 493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 493E5E0812D6420500020081 /* PlatformCALayerClient.h */; }; 1010 1011 49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */; }; 1011 1012 49484FC2102CF23C00187DD3 /* CanvasGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 49484FB4102CF23C00187DD3 /* CanvasGradient.h */; }; … … 7334 7335 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = "<group>"; }; 7335 7336 492863981253B8FC00F792D6 /* ResourceLoadInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadInfo.h; sourceTree = "<group>"; }; 7337 493E5E0812D6420500020081 /* PlatformCALayerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCALayerClient.h; path = ca/PlatformCALayerClient.h; sourceTree = "<group>"; }; 7336 7338 49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CanvasGradient.cpp; path = canvas/CanvasGradient.cpp; sourceTree = "<group>"; }; 7337 7339 49484FB4102CF23C00187DD3 /* CanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasGradient.h; path = canvas/CanvasGradient.h; sourceTree = "<group>"; }; … … 13242 13244 499B3EDC128DB50100E726C2 /* PlatformCAAnimation.h */, 13243 13245 499B3EC3128CCC4700E726C2 /* PlatformCALayer.h */, 13246 493E5E0812D6420500020081 /* PlatformCALayerClient.h */, 13244 13247 494BC40C12AEDD9E00743BD2 /* TransformationMatrixCA.cpp */, 13245 13248 ); … … 22273 22276 7EE6846F12D26E3800E79415 /* ResourceRequestCFNet.h in Headers */, 22274 22277 7EE6847012D26E3800E79415 /* ResourceResponse.h in Headers */, 22278 493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */, 22275 22279 ); 22276 22280 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/config.h
r72572 r75199 221 221 #endif 222 222 223 // CoreAnimation is available to IOS, Mac and Windows if using CG 224 #if PLATFORM(MAC) || PLATFORM(IOS) || (PLATFORM(WIN) && PLATFORM(CG)) 225 #define WTF_PLATFORM_CA 1 226 #endif 227 223 228 #if PLATFORM(QT) && USE(V8) && defined(Q_WS_X11) 224 229 /* protect ourselves from evil X11 defines */ -
trunk/WebCore/platform/graphics/GraphicsLayer.h
r73578 r75199 54 54 #endif 55 55 #elif PLATFORM(WIN) 56 namespace WebCore { 57 class WKCACFLayer; 58 typedef WKCACFLayer PlatformLayer; 59 } 56 typedef struct _CACFLayer PlatformLayer; 60 57 #elif PLATFORM(QT) 61 58 #if USE(TEXTURE_MAPPER) … … 315 312 void paintGraphicsLayerContents(GraphicsContext&, const IntRect& clip); 316 313 // Callback from the underlying graphics system when the layer has been displayed 317 virtual void didDisplay(PlatformLayer*) { }314 virtual void layerDidDisplay(PlatformLayer*) { } 318 315 319 316 // For hosting this GraphicsLayer in a native layer hierarchy. … … 331 328 CompositingCoordinatesOrientation contentsOrientation() const { return m_contentsOrientation; } 332 329 333 bool showDebugBorders() { return m_client ? m_client->showDebugBorders() : false; }334 bool showRepaintCounter() { return m_client ? m_client->showRepaintCounter() : false; }330 bool showDebugBorders() const { return m_client ? m_client->showDebugBorders() : false; } 331 bool showRepaintCounter() const { return m_client ? m_client->showRepaintCounter() : false; } 335 332 336 333 void updateDebugIndicators(); -
trunk/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r74579 r75199 641 641 } 642 642 643 void GraphicsLayerCA:: animationStarted(CFTimeInterval startTime)643 void GraphicsLayerCA::platformCALayerAnimationStarted(CFTimeInterval startTime) 644 644 { 645 645 if (m_client) … … 661 661 m_uncorrectedContentsImage = newImage; 662 662 m_pendingContentsImage = newImage; 663 664 #if !PLATFORM(WIN) 663 665 CGColorSpaceRef colorSpace = CGImageGetColorSpace(m_pendingContentsImage.get()); 664 666 … … 670 672 m_pendingContentsImage.adoptCF(CGImageCreateCopyWithColorSpace(m_pendingContentsImage.get(), genericRGB)); 671 673 } 674 #endif 672 675 m_contentsLayerPurpose = ContentsLayerForImage; 673 676 if (!m_contentsLayer) … … 689 692 return; 690 693 691 // Create the PlatformCALayer to wrap the incoming layer 692 m_contentsLayer = mediaLayer ? PlatformCALayer::create(mediaLayer, this) : 0; 693 694 // FIXME: The passed in layer might be a raw layer or an externally created 695 // PlatformCALayer. To determine this we attempt to get the 696 // PlatformCALayer pointer. If this returns a null pointer we assume it's 697 // raw. This test might be invalid if the raw layer is, for instance, the 698 // PlatformCALayer is using a user data pointer in the raw layer, and 699 // the creator of the raw layer is using it for some other purpose. 700 // For now we don't support such a case. 701 PlatformCALayer* platformCALayer = PlatformCALayer::platformCALayer(mediaLayer); 702 m_contentsLayer = mediaLayer ? (platformCALayer ? platformCALayer : PlatformCALayer::create(mediaLayer, this)) : 0; 694 703 m_contentsLayerPurpose = mediaLayer ? ContentsLayerForMedia : NoContentsLayer; 695 704 … … 712 721 } 713 722 714 void GraphicsLayerCA:: didDisplay(PlatformLayer* layer)723 void GraphicsLayerCA::layerDidDisplay(PlatformLayer* layer) 715 724 { 716 725 PlatformCALayer* currentLayer = PlatformCALayer::platformCALayer(layer); … … 904 913 } 905 914 906 for (size_t i = 0; i < newSublayers.size(); ++i)915 for (size_t i = 0; i < newSublayers.size(); --i) 907 916 newSublayers[i]->removeFromSuperlayer(); 908 917 } -
trunk/WebCore/platform/graphics/ca/GraphicsLayerCA.h
r73578 r75199 32 32 #include "Image.h" 33 33 #include "PlatformCAAnimation.h" 34 #include "PlatformCALayerClient.h" 34 35 #include <wtf/HashMap.h> 35 36 #include <wtf/HashSet.h> … … 41 42 class PlatformCALayer; 42 43 43 class GraphicsLayerCA : public GraphicsLayer {44 class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient { 44 45 public: 45 46 // The width and height of a single tile in a tiled layer. Should be large enough to … … 50 51 GraphicsLayerCA(GraphicsLayerClient*); 51 52 virtual ~GraphicsLayerCA(); 52 53 virtual void animationStarted(CFTimeInterval beginTime);54 53 55 54 virtual void setName(const String&); 56 55 57 56 virtual PlatformLayer* platformLayer() const; 57 virtual PlatformCALayer* platformCALayer() const { return primaryLayer(); } 58 58 59 59 virtual bool setChildren(const Vector<GraphicsLayer*>&); … … 113 113 virtual void setDebugBorder(const Color&, float borderWidth); 114 114 115 virtual void didDisplay(PlatformLayer*);115 virtual void layerDidDisplay(PlatformLayer*); 116 116 117 117 void recursiveCommitChanges(); … … 124 124 125 125 private: 126 // PlatformCALayerClient overrides 127 virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) { } 128 virtual bool platformCALayerRespondsToLayoutChanges() const { return false; } 129 130 virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime); 131 virtual CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return contentsOrientation(); } 132 virtual void platformCALayerPaintContents(GraphicsContext& context, const IntRect& clip) { paintGraphicsLayerContents(context, clip); } 133 virtual bool platformCALayerShowDebugBorders() const { return showDebugBorders(); } 134 virtual bool platformCALayerShowRepaintCounter() const { return showRepaintCounter(); } 135 virtual int platformCALayerIncrementRepaintCount() { return incrementRepaintCount(); } 136 137 virtual bool platformCALayerContentsOpaque() const { return contentsOpaque(); } 138 virtual bool platformCALayerDrawsContent() const { return drawsContent(); } 139 virtual void platformCALayerLayerDidDisplay(PlatformLayer* layer) { return layerDidDisplay(layer); } 140 126 141 void updateOpacityOnLayer(); 127 142 -
trunk/WebCore/platform/graphics/ca/PlatformCALayer.h
r73578 r75199 30 30 31 31 #include "GraphicsContext.h" 32 #include "GraphicsLayerCA.h"33 32 #include "PlatformCAAnimation.h" 33 #include "PlatformCALayerClient.h" 34 34 #include "PlatformString.h" 35 35 #include <wtf/HashMap.h> … … 48 48 class PlatformCALayer : public RefCounted<PlatformCALayer> { 49 49 public: 50 // TiledLayer used in GraphicsLayer has constant settings: 51 // cTiledLayerTileSize = 512 52 // setTileSize:(cTiledLayerTileSize, cTiledLayerTileSize) 53 // setLevelsOfDetail:1 54 // setLevelsOfDetailBias:0 55 // setContentsGravity:@"bottomLeft" 56 // 57 // TiledLayer also has drawing functions like WebLayer 58 // 59 // WebLayer is a CALayer with drawing functions specific to WebKit 60 // 61 // Layer and TransformLayer are used as is 62 63 enum LayerType { LayerTypeLayer, LayerTypeWebLayer, LayerTypeTransformLayer, LayerTypeWebTiledLayer, LayerTypeCustom }; 50 // LayerTypeRootLayer is used on some platforms. It has no backing store, so setNeedsDisplay 51 // should not call CACFLayerSetNeedsDisplay, but rather just notify the renderer that it 52 // has changed and should be re-rendered. 53 enum LayerType { LayerTypeLayer, LayerTypeWebLayer, LayerTypeTransformLayer, LayerTypeWebTiledLayer, LayerTypeRootLayer, LayerTypeCustom }; 64 54 enum FilterType { Linear, Nearest, Trilinear }; 65 55 66 static PassRefPtr<PlatformCALayer> create(LayerType, GraphicsLayerCA*);56 static PassRefPtr<PlatformCALayer> create(LayerType, PlatformCALayerClient*); 67 57 68 58 // This function passes the layer as a void* rather than a PlatformLayer because PlatformLayer 69 59 // is defined differently for Obj C and C++. This allows callers from both languages. 70 static PassRefPtr<PlatformCALayer> create(void* platformLayer, GraphicsLayerCA*);60 static PassRefPtr<PlatformCALayer> create(void* platformLayer, PlatformCALayerClient*); 71 61 72 62 ~PlatformCALayer(); … … 77 67 78 68 PlatformLayer* platformLayer() const; 69 70 PlatformCALayer* rootLayer() const; 79 71 80 72 static bool isValueFunctionSupported(); 81 73 82 GraphicsLayerCA* owner() const { return m_owner; }83 void setOwner( GraphicsLayerCA* owner);74 PlatformCALayerClient* owner() const { return m_owner; } 75 void setOwner(PlatformCALayerClient*); 84 76 85 77 void animationStarted(CFTimeInterval beginTime) 86 78 { 87 79 if (m_owner) 88 m_owner-> animationStarted(beginTime);80 m_owner->platformCALayerAnimationStarted(beginTime); 89 81 } 90 82 83 // Layout support 84 void setNeedsLayout(); 85 86 91 87 void setNeedsDisplay(const FloatRect* dirtyRect = 0); 92 88 89 // This tells the layer tree to commit changes and perform a render, without do a setNeedsDisplay on any layer. 90 void setNeedsCommit(); 91 93 92 void setContentsChanged(); 94 93 … … 105 104 106 105 // This method removes the sublayers from the source and reparents them to the current layer. 106 // Any sublayers previously in the current layer are removed. 107 107 void adoptSublayers(PlatformCALayer* source); 108 108 … … 151 151 void setAcceleratesDrawing(bool); 152 152 153 void*contents() const;154 void setContents( void*);153 CFTypeRef contents() const; 154 void setContents(CFTypeRef); 155 155 156 156 FloatRect contentsRect() const; … … 184 184 void setTimeOffset(CFTimeInterval); 185 185 186 #if PLATFORM(WIN) && !defined(NDEBUG) 187 void printTree() const; 188 #endif 189 186 190 protected: 187 PlatformCALayer(LayerType, PlatformLayer*, GraphicsLayerCA*);191 PlatformCALayer(LayerType, PlatformLayer*, PlatformCALayerClient*); 188 192 189 193 private: 190 191 GraphicsLayerCA* m_owner; 194 PlatformCALayerClient* m_owner; 192 195 LayerType m_layerType; 193 196 194 197 #if PLATFORM(MAC) || PLATFORM(WIN) 195 198 RetainPtr<PlatformLayer> m_layer; 199 #endif 200 201 #if PLATFORM(WIN) 202 HashMap<String, RefPtr<PlatformCAAnimation> > m_animations; 196 203 #endif 197 204 -
trunk/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
r74074 r75199 106 106 } 107 107 108 void PlatformCALayer::setOwner( GraphicsLayerCA* owner)108 void PlatformCALayer::setOwner(PlatformCALayerClient* owner) 109 109 { 110 110 m_owner = owner; … … 146 146 #endif 147 147 148 PassRefPtr<PlatformCALayer> PlatformCALayer::create(LayerType layerType, GraphicsLayerCA* owner)148 PassRefPtr<PlatformCALayer> PlatformCALayer::create(LayerType layerType, PlatformCALayerClient* owner) 149 149 { 150 150 return adoptRef(new PlatformCALayer(layerType, 0, owner)); 151 151 } 152 152 153 PassRefPtr<PlatformCALayer> PlatformCALayer::create(void* platformLayer, GraphicsLayerCA* owner)153 PassRefPtr<PlatformCALayer> PlatformCALayer::create(void* platformLayer, PlatformCALayerClient* owner) 154 154 { 155 155 return adoptRef(new PlatformCALayer(LayerTypeCustom, static_cast<PlatformLayer*>(platformLayer), owner)); 156 156 } 157 157 158 PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, GraphicsLayerCA* owner)158 PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, PlatformCALayerClient* owner) 159 159 : m_owner(owner) 160 160 { … … 169 169 switch(layerType) { 170 170 case LayerTypeLayer: 171 case LayerTypeRootLayer: 171 172 layerClass = [CALayer class]; 172 173 break; … … 569 570 } 570 571 571 void*PlatformCALayer::contents() const572 CFTypeRef PlatformCALayer::contents() const 572 573 { 573 574 return [m_layer.get() contents]; 574 575 } 575 576 576 void PlatformCALayer::setContents( void*value)577 { 578 BEGIN_BLOCK_OBJC_EXCEPTIONS 579 [m_layer.get() setContents:static_cast<id>( value)];577 void PlatformCALayer::setContents(CFTypeRef value) 578 { 579 BEGIN_BLOCK_OBJC_EXCEPTIONS 580 [m_layer.get() setContents:static_cast<id>(const_cast<void*>(value))]; 580 581 END_BLOCK_OBJC_EXCEPTIONS 581 582 } -
trunk/WebCore/platform/graphics/mac/WebGLLayer.mm
r61631 r75199 145 145 [super display]; 146 146 if (m_layerOwner) 147 m_layerOwner-> didDisplay(self);147 m_layerOwner->layerDidDisplay(self); 148 148 } 149 149 -
trunk/WebCore/platform/graphics/mac/WebLayer.h
r73380 r75199 33 33 namespace WebCore { 34 34 class GraphicsLayer; 35 class PlatformCALayerClient; 35 36 } 36 37 … … 48 49 49 50 // Functions allows us to share implementation across WebTiledLayer and WebLayer 50 void drawLayerContents(CGContextRef, CALayer *, WebCore:: GraphicsLayer*);51 void setLayerNeedsDisplayInRect(CALayer *, WebCore:: GraphicsLayer*, CGRect);51 void drawLayerContents(CGContextRef, CALayer *, WebCore::PlatformCALayerClient*); 52 void setLayerNeedsDisplayInRect(CALayer *, WebCore::PlatformCALayerClient*, CGRect); 52 53 53 54 #endif // USE(ACCELERATED_COMPOSITING) -
trunk/WebCore/platform/graphics/mac/WebLayer.mm
r74733 r75199 41 41 @implementation WebLayer 42 42 43 void drawLayerContents(CGContextRef context, CALayer *layer, WebCore:: GraphicsLayer* layerContents)43 void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCALayerClient* layerContents) 44 44 { 45 45 if (!layerContents) … … 49 49 50 50 CGRect layerBounds = [layer bounds]; 51 if (layerContents-> contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) {51 if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) { 52 52 CGContextScaleCTM(context, 1, -1); 53 53 CGContextTranslateCTM(context, 0, -layerBounds.size.height); 54 54 } 55 55 56 if (layerContents->client()) { 57 [NSGraphicsContext saveGraphicsState]; 58 59 // Set up an NSGraphicsContext for the context, so that parts of AppKit that rely on 60 // the current NSGraphicsContext (e.g. NSCell drawing) get the right one. 61 NSGraphicsContext* layerContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES]; 62 [NSGraphicsContext setCurrentContext:layerContext]; 63 64 GraphicsContext graphicsContext(context); 65 66 if (!layerContents->contentsOpaque()) { 67 // Turn off font smoothing to improve the appearance of text rendered onto a transparent background. 68 graphicsContext.setShouldSmoothFonts(false); 69 } 70 71 // It's important to get the clip from the context, because it may be significantly 72 // smaller than the layer bounds (e.g. tiled layers) 73 CGRect clipBounds = CGContextGetClipBoundingBox(context); 74 IntRect clip(enclosingIntRect(clipBounds)); 75 layerContents->paintGraphicsLayerContents(graphicsContext, clip); 76 77 [NSGraphicsContext restoreGraphicsState]; 78 } 79 #ifndef NDEBUG 80 else { 81 ASSERT_NOT_REACHED(); 82 83 // FIXME: ideally we'd avoid calling -setNeedsDisplay on a layer that is a plain color, 84 // so CA never makes backing store for it (which is what -setNeedsDisplay will do above). 85 CGContextSetRGBFillColor(context, 0.0f, 1.0f, 0.0f, 1.0f); 86 CGContextFillRect(context, layerBounds); 87 } 88 #endif 89 90 if (layerContents->showRepaintCounter()) { 56 [NSGraphicsContext saveGraphicsState]; 57 58 // Set up an NSGraphicsContext for the context, so that parts of AppKit that rely on 59 // the current NSGraphicsContext (e.g. NSCell drawing) get the right one. 60 NSGraphicsContext* layerContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES]; 61 [NSGraphicsContext setCurrentContext:layerContext]; 62 63 GraphicsContext graphicsContext(context); 64 65 if (!layerContents->platformCALayerContentsOpaque()) { 66 // Turn off font smoothing to improve the appearance of text rendered onto a transparent background. 67 graphicsContext.setShouldSmoothFonts(false); 68 } 69 70 // It's important to get the clip from the context, because it may be significantly 71 // smaller than the layer bounds (e.g. tiled layers) 72 CGRect clipBounds = CGContextGetClipBoundingBox(context); 73 IntRect clip(enclosingIntRect(clipBounds)); 74 layerContents->platformCALayerPaintContents(graphicsContext, clip); 75 76 [NSGraphicsContext restoreGraphicsState]; 77 78 if (layerContents->platformCALayerShowRepaintCounter()) { 91 79 bool isTiledLayer = [layer isKindOfClass:[CATiledLayer class]]; 92 80 93 81 char text[16]; // that's a lot of repaints 94 snprintf(text, sizeof(text), "%d", layerContents-> incrementRepaintCount());82 snprintf(text, sizeof(text), "%d", layerContents->platformCALayerIncrementRepaintCount()); 95 83 96 84 CGContextSaveGState(context); … … 118 106 } 119 107 120 void setLayerNeedsDisplayInRect(CALayer *layer, WebCore:: GraphicsLayer* layerContents, CGRect rect)121 { 122 if (layerContents && layerContents-> client() && layerContents->drawsContent()) {108 void setLayerNeedsDisplayInRect(CALayer *layer, WebCore::PlatformCALayerClient* layerContents, CGRect rect) 109 { 110 if (layerContents && layerContents->platformCALayerDrawsContent()) { 123 111 struct objc_super layerSuper = { layer, class_getSuperclass(object_getClass(layer)) }; 124 112 #if defined(BUILDING_ON_LEOPARD) 125 113 rect = CGRectApplyAffineTransform(rect, [layer contentsTransform]); 126 114 #else 127 if (layerContents-> contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)115 if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) 128 116 rect.origin.y = [layer bounds].size.height - rect.origin.y - rect.size.height; 129 117 #endif … … 131 119 132 120 #ifndef NDEBUG 133 if (layerContents-> showRepaintCounter()) {121 if (layerContents->platformCALayerShowRepaintCounter()) { 134 122 CGRect bounds = [layer bounds]; 135 123 CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 46, 25); … … 137 125 indicatorRect = CGRectApplyAffineTransform(indicatorRect, [layer contentsTransform]); 138 126 #else 139 if (layerContents-> contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)127 if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) 140 128 indicatorRect.origin.y = [layer bounds].size.height - indicatorRect.origin.y - indicatorRect.size.height; 141 129 #endif … … 156 144 { 157 145 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self); 158 if (layer && layer->owner() && layer->owner()-> client() && layer->owner()->drawsContent())146 if (layer && layer->owner() && layer->owner()->platformCALayerDrawsContent()) 159 147 [super setNeedsDisplay]; 160 148 } … … 172 160 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self); 173 161 if (layer && layer->owner()) 174 layer->owner()-> didDisplay(self);162 layer->owner()->platformCALayerLayerDidDisplay(self); 175 163 } 176 164 -
trunk/WebCore/platform/graphics/mac/WebTiledLayer.mm
r73380 r75199 61 61 { 62 62 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self); 63 if (layer && layer->owner() && layer->owner()-> client() && layer->owner()->drawsContent())63 if (layer && layer->owner() && layer->owner()->platformCALayerDrawsContent()) 64 64 [super setNeedsDisplay]; 65 65 } … … 77 77 PlatformCALayer* layer = PlatformCALayer::platformCALayer(self); 78 78 if (layer && layer->owner()) 79 layer->owner()-> didDisplay(self);79 layer->owner()->platformCALayerLayerDidDisplay(self); 80 80 } 81 81 -
trunk/WebCore/rendering/RenderLayerBacking.cpp
r75137 r75199 1102 1102 bool RenderLayerBacking::showDebugBorders() const 1103 1103 { 1104 return compositor() ? compositor()-> showDebugBorders() : false;1104 return compositor() ? compositor()->compositorShowDebugBorders() : false; 1105 1105 } 1106 1106 1107 1107 bool RenderLayerBacking::showRepaintCounter() const 1108 1108 { 1109 return compositor() ? compositor()-> showRepaintCounter() : false;1109 return compositor() ? compositor()->compositorShowRepaintCounter() : false; 1110 1110 } 1111 1111 -
trunk/WebCore/rendering/RenderLayerCompositor.cpp
r74168 r75199 1352 1352 ASSERT(!m_scrollLayer); 1353 1353 // Create a clipping layer if this is an iframe 1354 m_clipLayer = GraphicsLayer::create( 0);1354 m_clipLayer = GraphicsLayer::create(this); 1355 1355 #ifndef NDEBUG 1356 1356 m_clipLayer->setName("iframe Clipping"); … … 1358 1358 m_clipLayer->setMasksToBounds(true); 1359 1359 1360 m_scrollLayer = GraphicsLayer::create( 0);1360 m_scrollLayer = GraphicsLayer::create(this); 1361 1361 #ifndef NDEBUG 1362 1362 m_scrollLayer->setName("iframe scrolling"); -
trunk/WebCore/rendering/RenderLayerCompositor.h
r74085 r75199 55 55 // There is one RenderLayerCompositor per RenderView. 56 56 57 class RenderLayerCompositor {57 class RenderLayerCompositor : public GraphicsLayerClient { 58 58 public: 59 59 RenderLayerCompositor(RenderView*); 60 60 ~RenderLayerCompositor(); 61 61 62 62 // Return true if this RenderView is in "compositing mode" (i.e. has one or more 63 63 // composited RenderLayers) … … 72 72 bool canRender3DTransforms() const; 73 73 74 bool showDebugBorders() const { return m_showDebugBorders; }75 bool showRepaintCounter() const { return m_showRepaintCounter; }76 77 74 // Copy the accelerated compositing related flags from Settings 78 75 void cacheAcceleratedCompositingFlags(); … … 173 170 String layerTreeAsText(); 174 171 172 // These are named to avoid conflicts with the functions in GraphicsLayerClient 173 // These return the actual internal variables. 174 bool compositorShowDebugBorders() const { return m_showDebugBorders; } 175 bool compositorShowRepaintCounter() const { return m_showRepaintCounter; } 176 175 177 private: 178 // GraphicsLayerClient Implementation 179 virtual void notifyAnimationStarted(const GraphicsLayer*, double) { } 180 virtual void notifySyncRequired(const GraphicsLayer*) { scheduleSync(); } 181 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect&) { } 182 183 // These calls return false always. They are saying that the layers associated with this client 184 // (the clipLayer and scrollLayer) should never show debugging info. 185 virtual bool showDebugBorders() const { return false; } 186 virtual bool showRepaintCounter() const { return false; } 187 176 188 // Whether the given RL needs a compositing layer. 177 189 bool needsToBeComposited(const RenderLayer*) const;
Note: See TracChangeset
for help on using the changeset viewer.