Changeset 82650 in webkit


Ignore:
Timestamp:
Mar 31, 2011 6:05:06 PM (13 years ago)
Author:
Adam Roben
Message:

Add a new AbstractCACFLayerTreeHost base class

This class exposes the interface that LayerChangesFlusher and PlatformCALayer rely on.
CACFLayerTreeHost now derives from AbstractCACFLayerTreeHost. In the future, WebKit2's
LayerTreeHostCA will also derive from it (on Windows).

This should cause no change in behavior.

Fixes <http://webkit.org/b/57598> Coupling between CACFLayerTreeHost and other CACF-related
code is too high

Reviewed by Anders Carlsson.

  • WebCore.vcproj/WebCore.vcproj: Added AbstractCACFLayerTreeHost, and let VS reorder files.
  • platform/graphics/ca/win/AbstractCACFLayerTreeHost.h: Added.
  • platform/graphics/ca/win/CACFLayerTreeHost.h: Changed to derive from

AbstractCACFLayerTreeHost, and annotated the overrides of its functions.
AbstractCACFLayerTreeHost also allows us to get rid of the friend relationship with
PlatformCALayer.

  • platform/graphics/ca/win/LayerChangesFlusher.cpp:

(WebCore::LayerChangesFlusher::flushPendingLayerChangesSoon):
(WebCore::LayerChangesFlusher::cancelPendingFlush):
(WebCore::LayerChangesFlusher::hookFired):

  • platform/graphics/ca/win/LayerChangesFlusher.h:
  • platform/graphics/ca/win/PlatformCALayerWin.cpp:

(layerTreeHostForLayer):
(PlatformCALayer::rootLayer):
(PlatformCALayer::setNeedsCommit):
(PlatformCALayer::addAnimationForKey):
(PlatformCALayer::removeAnimationForKey):
Changed to use AbstractCACFLayerTreeHost instead of using CACFLayerTreeHost directly.

Location:
trunk/Source/WebCore
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r82646 r82650  
     12011-03-31  Adam Roben  <aroben@apple.com>
     2
     3        Add a new AbstractCACFLayerTreeHost base class
     4
     5        This class exposes the interface that LayerChangesFlusher and PlatformCALayer rely on.
     6        CACFLayerTreeHost now derives from AbstractCACFLayerTreeHost. In the future, WebKit2's
     7        LayerTreeHostCA will also derive from it (on Windows).
     8
     9        This should cause no change in behavior.
     10
     11        Fixes <http://webkit.org/b/57598> Coupling between CACFLayerTreeHost and other CACF-related
     12        code is too high
     13
     14        Reviewed by Anders Carlsson.
     15
     16        * WebCore.vcproj/WebCore.vcproj: Added AbstractCACFLayerTreeHost, and let VS reorder files.
     17
     18        * platform/graphics/ca/win/AbstractCACFLayerTreeHost.h: Added.
     19
     20        * platform/graphics/ca/win/CACFLayerTreeHost.h: Changed to derive from
     21        AbstractCACFLayerTreeHost, and annotated the overrides of its functions.
     22        AbstractCACFLayerTreeHost also allows us to get rid of the friend relationship with
     23        PlatformCALayer.
     24
     25        * platform/graphics/ca/win/LayerChangesFlusher.cpp:
     26        (WebCore::LayerChangesFlusher::flushPendingLayerChangesSoon):
     27        (WebCore::LayerChangesFlusher::cancelPendingFlush):
     28        (WebCore::LayerChangesFlusher::hookFired):
     29        * platform/graphics/ca/win/LayerChangesFlusher.h:
     30        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
     31        (layerTreeHostForLayer):
     32        (PlatformCALayer::rootLayer):
     33        (PlatformCALayer::setNeedsCommit):
     34        (PlatformCALayer::addAnimationForKey):
     35        (PlatformCALayer::removeAnimationForKey):
     36        Changed to use AbstractCACFLayerTreeHost instead of using CACFLayerTreeHost directly.
     37
    1382011-03-31  Andy Estes  <aestes@apple.com>
    239
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r82640 r82650  
    2578725787                        </File>
    2578825788                        <File
     25789                                RelativePath="..\platform\DefaultLocalizationStrategy.cpp"
     25790                                >
     25791                        </File>
     25792                        <File
     25793                                RelativePath="..\platform\DefaultLocalizationStrategy.h"
     25794                                >
     25795                        </File>
     25796                        <File
    2578925797                                RelativePath="..\platform\DragData.cpp"
    2579025798                                >
     
    2579225800                        <File
    2579325801                                RelativePath="..\platform\DragData.h"
    25794                                 >
    25795                         </File>
    25796                         <File
    25797                                 RelativePath="..\platform\DefaultLocalizationStrategy.cpp"
    25798                                 >
    25799                         </File>
    25800                         <File
    25801                                 RelativePath="..\platform\DefaultLocalizationStrategy.h"
    2580225802                                >
    2580325803                        </File>
     
    2914729147                                                Name="win"
    2914829148                                                >
     29149                                                <File
     29150                                                        RelativePath="..\platform\graphics\ca\win\AbstractCACFLayerTreeHost.h"
     29151                                                        >
     29152                                                </File>
    2914929153                                                <File
    2915029154                                                        RelativePath="..\platform\graphics\ca\win\CACFLayerTreeHost.cpp"
     
    6320263206                                </File>
    6320363207                                <File
     63208                                        RelativePath="..\bindings\js\PageScriptDebugServer.h"
     63209                                        >
     63210                                </File>
     63211                                <File
    6320463212                                        RelativePath="..\bindings\js\ScheduledAction.cpp"
    6320563213                                        >
     
    6403264040                                                />
    6403364041                                        </FileConfiguration>
    64034                                 </File>
    64035                                 <File
    64036                                         RelativePath="..\bindings\js\PageScriptDebugServer.h"
    64037                                         >
    6403864042                                </File>
    6403964043                        </Filter>
     
    6649566499                        </File>
    6649666500                        <File
     66501                                RelativePath="..\inspector\InspectorPageAgent.cpp"
     66502                                >
     66503                        </File>
     66504                        <File
     66505                                RelativePath="..\inspector\InspectorPageAgent.h"
     66506                                >
     66507                        </File>
     66508                        <File
    6649766509                                RelativePath="..\inspector\InspectorProfilerAgent.cpp"
    66498                                 >
    66499                         </File>
    66500                         <File
    66501                                 RelativePath="..\inspector\InspectorPageAgent.cpp"
    66502                                 >
    66503                         </File>
    66504                         <File
    66505                                 RelativePath="..\inspector\InspectorPageAgent.h"
    6650666510                                >
    6650766511                        </File>
  • trunk/Source/WebCore/platform/graphics/ca/win/AbstractCACFLayerTreeHost.h

    r82649 r82650  
    11/*
    2  * Copyright (C) 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef LayerChangesFlusher_h
    27 #define LayerChangesFlusher_h
     26#ifndef AbstractCACFLayerTreeHost_h
     27#define AbstractCACFLayerTreeHost_h
    2828
    2929#if USE(ACCELERATED_COMPOSITING)
    3030
    31 #include <windows.h>
    32 #include <wtf/HashSet.h>
    33 #include <wtf/Noncopyable.h>
     31#include <wtf/Forward.h>
    3432
    3533namespace WebCore {
    3634
    37 class CACFLayerTreeHost;
     35class PlatformCALayer;
    3836
    39 class LayerChangesFlusher {
    40     WTF_MAKE_NONCOPYABLE(LayerChangesFlusher);
     37class AbstractCACFLayerTreeHost {
    4138public:
    42     static LayerChangesFlusher& shared();
     39    virtual PlatformCALayer* rootLayer() const = 0;
     40    virtual void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>) = 0;
     41    virtual void layerTreeDidChange() = 0;
     42    virtual void flushPendingLayerChangesNow() = 0;
    4343
    44     void flushPendingLayerChangesSoon(CACFLayerTreeHost*);
    45     void cancelPendingFlush(CACFLayerTreeHost*);
    46 
    47 private:
    48     LayerChangesFlusher();
    49     ~LayerChangesFlusher();
    50 
    51     static LRESULT CALLBACK hookCallback(int code, WPARAM, LPARAM);
    52     LRESULT hookFired(int code, WPARAM, LPARAM);
    53     void setHook();
    54     void removeHook();
    55 
    56     HashSet<CACFLayerTreeHost*> m_hostsWithChangesToFlush;
    57     HHOOK m_hook;
    58     bool m_isCallingHosts;
     44protected:
     45    virtual ~AbstractCACFLayerTreeHost() { }
    5946};
    6047
    61 } // namespace WebCore
     48}
    6249
    6350#endif // USE(ACCELERATED_COMPOSITING)
    6451
    65 #endif // LayerChangesFlusher_h
     52#endif // AbstractCACFLayerTreeHost_h
  • trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h

    r76858 r82650  
    2929#if USE(ACCELERATED_COMPOSITING)
    3030
     31#include "AbstractCACFLayerTreeHost.h"
    3132#include "COMPtr.h"
    3233#include "Timer.h"
     
    5152class PlatformCALayer;
    5253
    53 class CACFLayerTreeHost : public RefCounted<CACFLayerTreeHost> {
    54     friend PlatformCALayer;
    55 
     54class CACFLayerTreeHost : public RefCounted<CACFLayerTreeHost>, private AbstractCACFLayerTreeHost {
    5655public:
    5756    static PassRefPtr<CACFLayerTreeHost> create();
     
    6766    virtual void resize() = 0;
    6867    void flushPendingGraphicsLayerChangesSoon();
    69     void flushPendingLayerChangesNow();
     68
     69    // AbstractCACFLayerTreeHost
     70    virtual void flushPendingLayerChangesNow();
    7071
    7172protected:
     
    7374
    7475    CGRect bounds() const;
    75     PlatformCALayer* rootLayer() const;
    7676    HWND window() const { return m_window; }
    7777    void notifyAnimationsStarted();
     78
     79    // AbstractCACFLayerTreeHost
     80    virtual PlatformCALayer* rootLayer() const;
    7881
    7982    virtual bool createRenderer() = 0;
     
    8386private:
    8487    void initialize();
    85     void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>);
    86     void layerTreeDidChange();
     88
     89    // AbstractCACFLayerTreeHost
     90    virtual void addPendingAnimatedLayer(PassRefPtr<PlatformCALayer>);
     91    virtual void layerTreeDidChange();
     92
    8793
    8894    virtual void flushContext() = 0;
  • trunk/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.cpp

    r82633 r82650  
    2929#if USE(ACCELERATED_COMPOSITING)
    3030
    31 #include "CACFLayerTreeHost.h"
     31#include "AbstractCACFLayerTreeHost.h"
    3232#include "WebCoreInstanceHandle.h"
    3333#include <wtf/StdLibExtras.h>
     
    4848}
    4949
    50 void LayerChangesFlusher::flushPendingLayerChangesSoon(CACFLayerTreeHost* host)
     50void LayerChangesFlusher::flushPendingLayerChangesSoon(AbstractCACFLayerTreeHost* host)
    5151{
    5252    if (!m_hostsWithChangesToFlush.add(host).second || m_hook)
     
    5656}
    5757
    58 void LayerChangesFlusher::cancelPendingFlush(CACFLayerTreeHost* host)
     58void LayerChangesFlusher::cancelPendingFlush(AbstractCACFLayerTreeHost* host)
    5959{
    6060    m_hostsWithChangesToFlush.remove(host);
     
    8282    // Calling out to the hosts can cause m_hostsWithChangesToFlush to be modified, so we copy it
    8383    // into a Vector first.
    84     Vector<CACFLayerTreeHost*> hosts;
     84    Vector<AbstractCACFLayerTreeHost*> hosts;
    8585    copyToVector(m_hostsWithChangesToFlush, hosts);
    8686    m_hostsWithChangesToFlush.clear();
  • trunk/Source/WebCore/platform/graphics/ca/win/LayerChangesFlusher.h

    r76372 r82650  
    3535namespace WebCore {
    3636
    37 class CACFLayerTreeHost;
     37class AbstractCACFLayerTreeHost;
    3838
    3939class LayerChangesFlusher {
     
    4242    static LayerChangesFlusher& shared();
    4343
    44     void flushPendingLayerChangesSoon(CACFLayerTreeHost*);
    45     void cancelPendingFlush(CACFLayerTreeHost*);
     44    void flushPendingLayerChangesSoon(AbstractCACFLayerTreeHost*);
     45    void cancelPendingFlush(AbstractCACFLayerTreeHost*);
    4646
    4747private:
     
    5454    void removeHook();
    5555
    56     HashSet<CACFLayerTreeHost*> m_hostsWithChangesToFlush;
     56    HashSet<AbstractCACFLayerTreeHost*> m_hostsWithChangesToFlush;
    5757    HHOOK m_hook;
    5858    bool m_isCallingHosts;
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp

    r76370 r82650  
    3030#include "PlatformCALayer.h"
    3131
    32 #include "CACFLayerTreeHost.h"
     32#include "AbstractCACFLayerTreeHost.h"
    3333#include "Font.h"
    3434#include "GraphicsContext.h"
     
    6666}
    6767
    68 static CACFLayerTreeHost* layerTreeHostForLayer(const PlatformCALayer* layer)
    69 {
    70     // We need the CACFLayerTreeHost associated with this layer, which is stored in the UserData of the CACFContext
     68static AbstractCACFLayerTreeHost* layerTreeHostForLayer(const PlatformCALayer* layer)
     69{
     70    // We need the AbstractCACFLayerTreeHost associated with this layer, which is stored in the UserData of the CACFContext
    7171    void* userData = wkCACFLayerGetContextUserData(layer->platformLayer());
    7272    if (!userData)
    7373        return 0;
    7474
    75     return static_cast<CACFLayerTreeHost*>(userData);
     75    return static_cast<AbstractCACFLayerTreeHost*>(userData);
    7676}
    7777
     
    157157PlatformCALayer* PlatformCALayer::rootLayer() const
    158158{
    159     CACFLayerTreeHost* host = layerTreeHostForLayer(this);
     159    AbstractCACFLayerTreeHost* host = layerTreeHostForLayer(this);
    160160    return host ? host->rootLayer() : 0;
    161161}
     
    168168void PlatformCALayer::setNeedsCommit()
    169169{
    170     CACFLayerTreeHost* host = layerTreeHostForLayer(this);
     170    AbstractCACFLayerTreeHost* host = layerTreeHostForLayer(this);
    171171    if (host)
    172172        host->layerTreeDidChange();
     
    271271
    272272    // Tell the host about it so we can fire the start animation event
    273     CACFLayerTreeHost* host = layerTreeHostForLayer(this);
     273    AbstractCACFLayerTreeHost* host = layerTreeHostForLayer(this);
    274274    if (host)
    275275        host->addPendingAnimatedLayer(this);
     
    284284    CACFLayerRemoveAnimation(m_layer.get(), s.get());
    285285
    286     // We don't "remove" a layer from CACFLayerTreeHost when it loses an animation.
     286    // We don't "remove" a layer from AbstractCACFLayerTreeHost when it loses an animation.
    287287    // There may be other active animations on the layer and if an animation
    288288    // callback is fired on a layer without any animations no harm is done.
Note: See TracChangeset for help on using the changeset viewer.