Changeset 75199 in webkit


Ignore:
Timestamp:
Jan 6, 2011 2:26:35 PM (13 years ago)
Author:
cmarrin@apple.com
Message:

2011-01-06 Chris Marrin <cmarrin@apple.com>

Reviewed by Simon Fraser.

Share code between Mac (CA) and Windows (CACF) GraphicsLayer implementations
https://bugs.webkit.org/show_bug.cgi?id=49388

Changed PlatformCALayer API. Added PlatformCALayerClient abstract class which is
used to communicate from PlatformCALayer to the owner. This replaces passing
GraphicsLayerCA pointer when creating PlatformCALayer. It also includes the
API that used to be in PlatformCALayerLayout. GraphicsLayerCA now implements
the PlatformCALayerClient API.

This change has little impact on the Mac side but makes the Windows
interface simpler, especially when handling video layers on Windows.

  • WebCore.xcodeproj/project.pbxproj:
  • config.h:
  • platform/graphics/GraphicsLayer.h: (WebCore::GraphicsLayer::layerDidDisplay): (WebCore::GraphicsLayer::showDebugBorders): (WebCore::GraphicsLayer::showRepaintCounter):
  • platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::platformCALayerAnimationStarted): (WebCore::GraphicsLayerCA::setContentsToImage): (WebCore::GraphicsLayerCA::setContentsToMedia): (WebCore::GraphicsLayerCA::layerDidDisplay): (WebCore::GraphicsLayerCA::updateSublayerList):
  • platform/graphics/ca/GraphicsLayerCA.h: (WebCore::GraphicsLayerCA::platformCALayerLayoutSublayersOfLayer): (WebCore::GraphicsLayerCA::platformCALayerRespondsToLayoutChanges): (WebCore::GraphicsLayerCA::platformCALayerContentsOrientation): (WebCore::GraphicsLayerCA::platformCALayerPaintContents): (WebCore::GraphicsLayerCA::platformCALayerShowDebugBorders): (WebCore::GraphicsLayerCA::platformCALayerShowRepaintCounter): (WebCore::GraphicsLayerCA::platformCALayerIncrementRepaintCount): (WebCore::GraphicsLayerCA::platformCALayerContentsOpaque): (WebCore::GraphicsLayerCA::platformCALayerDrawsContent): (WebCore::GraphicsLayerCA::platformCALayerLayerDidDisplay): (WebCore::GraphicsLayerCA::platformCALayer):
  • platform/graphics/ca/PlatformCALayer.h: (WebCore::PlatformCALayer::owner): (WebCore::PlatformCALayer::animationStarted):
  • platform/graphics/ca/PlatformCALayerClient.h: Added. (WebCore::PlatformCALayerClient::~PlatformCALayerClient):
  • platform/graphics/ca/mac/PlatformCALayerMac.mm: (PlatformCALayer::setOwner): (PlatformCALayer::create): (PlatformCALayer::PlatformCALayer): (PlatformCALayer::contents): (PlatformCALayer::setContents):
  • platform/graphics/mac/WebGLLayer.mm: (-[WebGLLayer display]):
  • platform/graphics/mac/WebLayer.h:
  • platform/graphics/mac/WebLayer.mm: (drawLayerContents): (setLayerNeedsDisplayInRect): (-[WebLayer setNeedsDisplay]): (-[WebLayer display]):
  • platform/graphics/mac/WebTiledLayer.mm: (-[WebTiledLayer setNeedsDisplay]): (-[WebTiledLayer display]):
  • rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::showDebugBorders): (WebCore::RenderLayerBacking::showRepaintCounter):
  • rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::ensureRootPlatformLayer):
  • rendering/RenderLayerCompositor.h: (WebCore::RenderLayerCompositor::compositorShowDebugBorders): (WebCore::RenderLayerCompositor::compositorShowRepaintCounter): (WebCore::RenderLayerCompositor::notifyAnimationStarted): (WebCore::RenderLayerCompositor::notifySyncRequired): (WebCore::RenderLayerCompositor::paintContents): (WebCore::RenderLayerCompositor::showDebugBorders): (WebCore::RenderLayerCompositor::showRepaintCounter):
Location:
trunk/WebCore
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r75198 r75199  
     12011-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
    1772011-01-06  Tony Gentilcore  <tonyg@chromium.org>
    278
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r75169 r75199  
    10081008                490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; };
    10091009                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 */; };
    10101011                49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */; };
    10111012                49484FC2102CF23C00187DD3 /* CanvasGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 49484FB4102CF23C00187DD3 /* CanvasGradient.h */; };
     
    73347335                490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = "<group>"; };
    73357336                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>"; };
    73367338                49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CanvasGradient.cpp; path = canvas/CanvasGradient.cpp; sourceTree = "<group>"; };
    73377339                49484FB4102CF23C00187DD3 /* CanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasGradient.h; path = canvas/CanvasGradient.h; sourceTree = "<group>"; };
     
    1324213244                                499B3EDC128DB50100E726C2 /* PlatformCAAnimation.h */,
    1324313245                                499B3EC3128CCC4700E726C2 /* PlatformCALayer.h */,
     13246                                493E5E0812D6420500020081 /* PlatformCALayerClient.h */,
    1324413247                                494BC40C12AEDD9E00743BD2 /* TransformationMatrixCA.cpp */,
    1324513248                        );
     
    2227322276                                7EE6846F12D26E3800E79415 /* ResourceRequestCFNet.h in Headers */,
    2227422277                                7EE6847012D26E3800E79415 /* ResourceResponse.h in Headers */,
     22278                                493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */,
    2227522279                        );
    2227622280                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/config.h

    r72572 r75199  
    221221#endif
    222222
     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
    223228#if PLATFORM(QT) && USE(V8) && defined(Q_WS_X11)
    224229/* protect ourselves from evil X11 defines */
  • trunk/WebCore/platform/graphics/GraphicsLayer.h

    r73578 r75199  
    5454#endif
    5555#elif PLATFORM(WIN)
    56 namespace WebCore {
    57 class WKCACFLayer;
    58 typedef WKCACFLayer PlatformLayer;
    59 }
     56typedef struct _CACFLayer PlatformLayer;
    6057#elif PLATFORM(QT)
    6158#if USE(TEXTURE_MAPPER)
     
    315312    void paintGraphicsLayerContents(GraphicsContext&, const IntRect& clip);
    316313    // Callback from the underlying graphics system when the layer has been displayed
    317     virtual void didDisplay(PlatformLayer*) { }
     314    virtual void layerDidDisplay(PlatformLayer*) { }
    318315   
    319316    // For hosting this GraphicsLayer in a native layer hierarchy.
     
    331328    CompositingCoordinatesOrientation contentsOrientation() const { return m_contentsOrientation; }
    332329
    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; }
    335332   
    336333    void updateDebugIndicators();
  • trunk/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r74579 r75199  
    641641}
    642642
    643 void GraphicsLayerCA::animationStarted(CFTimeInterval startTime)
     643void GraphicsLayerCA::platformCALayerAnimationStarted(CFTimeInterval startTime)
    644644{
    645645    if (m_client)
     
    661661        m_uncorrectedContentsImage = newImage;
    662662        m_pendingContentsImage = newImage;
     663
     664#if !PLATFORM(WIN)
    663665        CGColorSpaceRef colorSpace = CGImageGetColorSpace(m_pendingContentsImage.get());
    664666
     
    670672            m_pendingContentsImage.adoptCF(CGImageCreateCopyWithColorSpace(m_pendingContentsImage.get(), genericRGB));
    671673        }
     674#endif
    672675        m_contentsLayerPurpose = ContentsLayerForImage;
    673676        if (!m_contentsLayer)
     
    689692        return;
    690693       
    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;
    694703    m_contentsLayerPurpose = mediaLayer ? ContentsLayerForMedia : NoContentsLayer;
    695704
     
    712721}
    713722   
    714 void GraphicsLayerCA::didDisplay(PlatformLayer* layer)
     723void GraphicsLayerCA::layerDidDisplay(PlatformLayer* layer)
    715724{
    716725    PlatformCALayer* currentLayer = PlatformCALayer::platformCALayer(layer);
     
    904913        }
    905914
    906         for (size_t i = 0; i < newSublayers.size(); ++i)
     915        for (size_t i = 0; i < newSublayers.size(); --i)
    907916            newSublayers[i]->removeFromSuperlayer();
    908917    }
  • trunk/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r73578 r75199  
    3232#include "Image.h"
    3333#include "PlatformCAAnimation.h"
     34#include "PlatformCALayerClient.h"
    3435#include <wtf/HashMap.h>
    3536#include <wtf/HashSet.h>
     
    4142class PlatformCALayer;
    4243
    43 class GraphicsLayerCA : public GraphicsLayer {
     44class GraphicsLayerCA : public GraphicsLayer, public PlatformCALayerClient {
    4445public:
    4546    // The width and height of a single tile in a tiled layer. Should be large enough to
     
    5051    GraphicsLayerCA(GraphicsLayerClient*);
    5152    virtual ~GraphicsLayerCA();
    52    
    53     virtual void animationStarted(CFTimeInterval beginTime);
    5453
    5554    virtual void setName(const String&);
    5655
    5756    virtual PlatformLayer* platformLayer() const;
     57    virtual PlatformCALayer* platformCALayer() const { return primaryLayer(); }
    5858
    5959    virtual bool setChildren(const Vector<GraphicsLayer*>&);
     
    113113    virtual void setDebugBorder(const Color&, float borderWidth);
    114114
    115     virtual void didDisplay(PlatformLayer*);
     115    virtual void layerDidDisplay(PlatformLayer*);
    116116
    117117    void recursiveCommitChanges();
     
    124124
    125125private:
     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
    126141    void updateOpacityOnLayer();
    127142
  • trunk/WebCore/platform/graphics/ca/PlatformCALayer.h

    r73578 r75199  
    3030
    3131#include "GraphicsContext.h"
    32 #include "GraphicsLayerCA.h"
    3332#include "PlatformCAAnimation.h"
     33#include "PlatformCALayerClient.h"
    3434#include "PlatformString.h"
    3535#include <wtf/HashMap.h>
     
    4848class PlatformCALayer : public RefCounted<PlatformCALayer> {
    4949public:
    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 };
    6454    enum FilterType { Linear, Nearest, Trilinear };
    6555
    66     static PassRefPtr<PlatformCALayer> create(LayerType, GraphicsLayerCA*);
     56    static PassRefPtr<PlatformCALayer> create(LayerType, PlatformCALayerClient*);
    6757   
    6858    // This function passes the layer as a void* rather than a PlatformLayer because PlatformLayer
    6959    // 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*);
    7161
    7262    ~PlatformCALayer();
     
    7767   
    7868    PlatformLayer* platformLayer() const;
     69
     70    PlatformCALayer* rootLayer() const;
    7971   
    8072    static bool isValueFunctionSupported();
    8173   
    82     GraphicsLayerCA* owner() const { return m_owner; }
    83     void setOwner(GraphicsLayerCA* owner);
     74    PlatformCALayerClient* owner() const { return m_owner; }
     75    void setOwner(PlatformCALayerClient*);
    8476
    8577    void animationStarted(CFTimeInterval beginTime)
    8678    {
    8779        if (m_owner)
    88             m_owner->animationStarted(beginTime);
     80            m_owner->platformCALayerAnimationStarted(beginTime);
    8981    }
    9082
     83    // Layout support
     84    void setNeedsLayout();
     85
     86
    9187    void setNeedsDisplay(const FloatRect* dirtyRect = 0);
    9288   
     89    // This tells the layer tree to commit changes and perform a render, without do a setNeedsDisplay on any layer.
     90    void setNeedsCommit();
     91
    9392    void setContentsChanged();
    9493   
     
    105104
    106105    // 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.
    107107    void adoptSublayers(PlatformCALayer* source);
    108108   
     
    151151    void setAcceleratesDrawing(bool);
    152152
    153     void* contents() const;
    154     void setContents(void*);
     153    CFTypeRef contents() const;
     154    void setContents(CFTypeRef);
    155155
    156156    FloatRect contentsRect() const;
     
    184184    void setTimeOffset(CFTimeInterval);
    185185
     186#if PLATFORM(WIN) && !defined(NDEBUG)
     187    void printTree() const;
     188#endif
     189
    186190protected:
    187     PlatformCALayer(LayerType, PlatformLayer*, GraphicsLayerCA*);
     191    PlatformCALayer(LayerType, PlatformLayer*, PlatformCALayerClient*);
    188192   
    189193private:
    190    
    191     GraphicsLayerCA* m_owner;
     194    PlatformCALayerClient* m_owner;
    192195    LayerType m_layerType;
    193196   
    194197#if PLATFORM(MAC) || PLATFORM(WIN)
    195198    RetainPtr<PlatformLayer> m_layer;
     199#endif
     200
     201#if PLATFORM(WIN)
     202    HashMap<String, RefPtr<PlatformCAAnimation> > m_animations;
    196203#endif
    197204
  • trunk/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r74074 r75199  
    106106}
    107107
    108 void PlatformCALayer::setOwner(GraphicsLayerCA* owner)
     108void PlatformCALayer::setOwner(PlatformCALayerClient* owner)
    109109{
    110110    m_owner = owner;
     
    146146#endif
    147147
    148 PassRefPtr<PlatformCALayer> PlatformCALayer::create(LayerType layerType, GraphicsLayerCA* owner)
     148PassRefPtr<PlatformCALayer> PlatformCALayer::create(LayerType layerType, PlatformCALayerClient* owner)
    149149{
    150150    return adoptRef(new PlatformCALayer(layerType, 0, owner));
    151151}
    152152
    153 PassRefPtr<PlatformCALayer> PlatformCALayer::create(void* platformLayer, GraphicsLayerCA* owner)
     153PassRefPtr<PlatformCALayer> PlatformCALayer::create(void* platformLayer, PlatformCALayerClient* owner)
    154154{
    155155    return adoptRef(new PlatformCALayer(LayerTypeCustom, static_cast<PlatformLayer*>(platformLayer), owner));
    156156}
    157157
    158 PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, GraphicsLayerCA* owner)
     158PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, PlatformCALayerClient* owner)
    159159    : m_owner(owner)
    160160{
     
    169169        switch(layerType) {
    170170            case LayerTypeLayer:
     171            case LayerTypeRootLayer:
    171172                layerClass = [CALayer class];
    172173                break;
     
    569570}
    570571
    571 void* PlatformCALayer::contents() const
     572CFTypeRef PlatformCALayer::contents() const
    572573{
    573574    return [m_layer.get() contents];
    574575}
    575576
    576 void PlatformCALayer::setContents(void* value)
    577 {
    578     BEGIN_BLOCK_OBJC_EXCEPTIONS
    579     [m_layer.get() setContents:static_cast<id>(value)];
     577void PlatformCALayer::setContents(CFTypeRef value)
     578{
     579    BEGIN_BLOCK_OBJC_EXCEPTIONS
     580    [m_layer.get() setContents:static_cast<id>(const_cast<void*>(value))];
    580581    END_BLOCK_OBJC_EXCEPTIONS
    581582}
  • trunk/WebCore/platform/graphics/mac/WebGLLayer.mm

    r61631 r75199  
    145145    [super display];
    146146    if (m_layerOwner)
    147         m_layerOwner->didDisplay(self);
     147        m_layerOwner->layerDidDisplay(self);
    148148}
    149149
  • trunk/WebCore/platform/graphics/mac/WebLayer.h

    r73380 r75199  
    3333namespace WebCore {
    3434    class GraphicsLayer;
     35    class PlatformCALayerClient;
    3536}
    3637
     
    4849
    4950// Functions allows us to share implementation across WebTiledLayer and WebLayer
    50 void drawLayerContents(CGContextRef, CALayer *, WebCore::GraphicsLayer*);
    51 void setLayerNeedsDisplayInRect(CALayer *, WebCore::GraphicsLayer*, CGRect);
     51void drawLayerContents(CGContextRef, CALayer *, WebCore::PlatformCALayerClient*);
     52void setLayerNeedsDisplayInRect(CALayer *, WebCore::PlatformCALayerClient*, CGRect);
    5253
    5354#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/WebCore/platform/graphics/mac/WebLayer.mm

    r74733 r75199  
    4141@implementation WebLayer
    4242
    43 void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::GraphicsLayer* layerContents)
     43void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCALayerClient* layerContents)
    4444{
    4545    if (!layerContents)
     
    4949
    5050    CGRect layerBounds = [layer bounds];
    51     if (layerContents->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) {
     51    if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp) {
    5252        CGContextScaleCTM(context, 1, -1);
    5353        CGContextTranslateCTM(context, 0, -layerBounds.size.height);
    5454    }
    5555
    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()) {
    9179        bool isTiledLayer = [layer isKindOfClass:[CATiledLayer class]];
    9280
    9381        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());
    9583
    9684        CGContextSaveGState(context);
     
    118106}
    119107
    120 void setLayerNeedsDisplayInRect(CALayer *layer, WebCore::GraphicsLayer* layerContents, CGRect rect)
    121 {
    122     if (layerContents && layerContents->client() && layerContents->drawsContent()) {
     108void setLayerNeedsDisplayInRect(CALayer *layer, WebCore::PlatformCALayerClient* layerContents, CGRect rect)
     109{
     110    if (layerContents && layerContents->platformCALayerDrawsContent()) {
    123111        struct objc_super layerSuper = { layer, class_getSuperclass(object_getClass(layer)) };
    124112#if defined(BUILDING_ON_LEOPARD)
    125113        rect = CGRectApplyAffineTransform(rect, [layer contentsTransform]);
    126114#else
    127         if (layerContents->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)
     115        if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)
    128116            rect.origin.y = [layer bounds].size.height - rect.origin.y - rect.size.height;
    129117#endif
     
    131119
    132120#ifndef NDEBUG
    133         if (layerContents->showRepaintCounter()) {
     121        if (layerContents->platformCALayerShowRepaintCounter()) {
    134122            CGRect bounds = [layer bounds];
    135123            CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 46, 25);
     
    137125            indicatorRect = CGRectApplyAffineTransform(indicatorRect, [layer contentsTransform]);
    138126#else
    139             if (layerContents->contentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)
     127            if (layerContents->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesBottomUp)
    140128                indicatorRect.origin.y = [layer bounds].size.height - indicatorRect.origin.y - indicatorRect.size.height;
    141129#endif
     
    156144{
    157145    PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
    158     if (layer && layer->owner() && layer->owner()->client() && layer->owner()->drawsContent())
     146    if (layer && layer->owner() && layer->owner()->platformCALayerDrawsContent())
    159147        [super setNeedsDisplay];
    160148}
     
    172160    PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
    173161    if (layer && layer->owner())
    174         layer->owner()->didDisplay(self);
     162        layer->owner()->platformCALayerLayerDidDisplay(self);
    175163}
    176164
  • trunk/WebCore/platform/graphics/mac/WebTiledLayer.mm

    r73380 r75199  
    6161{
    6262    PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
    63     if (layer && layer->owner() && layer->owner()->client() && layer->owner()->drawsContent())
     63    if (layer && layer->owner() && layer->owner()->platformCALayerDrawsContent())
    6464        [super setNeedsDisplay];
    6565}
     
    7777    PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
    7878    if (layer && layer->owner())
    79         layer->owner()->didDisplay(self);
     79        layer->owner()->platformCALayerLayerDidDisplay(self);
    8080}
    8181
  • trunk/WebCore/rendering/RenderLayerBacking.cpp

    r75137 r75199  
    11021102bool RenderLayerBacking::showDebugBorders() const
    11031103{
    1104     return compositor() ? compositor()->showDebugBorders() : false;
     1104    return compositor() ? compositor()->compositorShowDebugBorders() : false;
    11051105}
    11061106
    11071107bool RenderLayerBacking::showRepaintCounter() const
    11081108{
    1109     return compositor() ? compositor()->showRepaintCounter() : false;
     1109    return compositor() ? compositor()->compositorShowRepaintCounter() : false;
    11101110}
    11111111
  • trunk/WebCore/rendering/RenderLayerCompositor.cpp

    r74168 r75199  
    13521352            ASSERT(!m_scrollLayer);
    13531353            // Create a clipping layer if this is an iframe
    1354             m_clipLayer = GraphicsLayer::create(0);
     1354            m_clipLayer = GraphicsLayer::create(this);
    13551355#ifndef NDEBUG
    13561356            m_clipLayer->setName("iframe Clipping");
     
    13581358            m_clipLayer->setMasksToBounds(true);
    13591359           
    1360             m_scrollLayer = GraphicsLayer::create(0);
     1360            m_scrollLayer = GraphicsLayer::create(this);
    13611361#ifndef NDEBUG
    13621362            m_scrollLayer->setName("iframe scrolling");
  • trunk/WebCore/rendering/RenderLayerCompositor.h

    r74085 r75199  
    5555// There is one RenderLayerCompositor per RenderView.
    5656
    57 class RenderLayerCompositor {
     57class RenderLayerCompositor : public GraphicsLayerClient {
    5858public:
    5959    RenderLayerCompositor(RenderView*);
    6060    ~RenderLayerCompositor();
    61    
     61
    6262    // Return true if this RenderView is in "compositing mode" (i.e. has one or more
    6363    // composited RenderLayers)
     
    7272    bool canRender3DTransforms() const;
    7373
    74     bool showDebugBorders() const { return m_showDebugBorders; }
    75     bool showRepaintCounter() const { return m_showRepaintCounter; }
    76    
    7774    // Copy the accelerated compositing related flags from Settings
    7875    void cacheAcceleratedCompositingFlags();
     
    173170    String layerTreeAsText();
    174171
     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
    175177private:
     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   
    176188    // Whether the given RL needs a compositing layer.
    177189    bool needsToBeComposited(const RenderLayer*) const;
Note: See TracChangeset for help on using the changeset viewer.