Changeset 76858 in webkit


Ignore:
Timestamp:
Jan 27, 2011 3:40:41 PM (13 years ago)
Author:
Adam Roben
Message:

Add WKCACFViewLayerTreeHost

This is a class that derives from CACFLayerTreeHost and uses a WKCACFView to render.

Fixes <http://webkit.org/b/53251> <rdar://problem/8925496> CACFLayerTreeHost should use
WKCACFView for rendering

  • WebCore.vcproj/WebCore.vcproj: Added WKCACFViewLayerTreeHost.{cpp,h}.
  • platform/graphics/ca/win/CACFLayerTreeHost.cpp:

(WebCore::CACFLayerTreeHost::acceleratedCompositingAvailable): Make the test window have a
non-zero size. WKCACFView will always say it can't render if you pass it a 0-sized window,
so we need a non-empty window to perform a valid test.
(WebCore::CACFLayerTreeHost::create): First try to create a WKCACFViewLayerTreeHost, then
fall back to a LegacyCACFLayerTreeHost.
(WebCore::CACFLayerTreeHost::flushPendingLayerChangesNow): Moved code to react to the
context flush from here...
(WebCore::CACFLayerTreeHost::contextDidChange): ...to here. Derived classes are required to
call this function whenever changes are flushed to the context.

  • platform/graphics/ca/win/CACFLayerTreeHost.h: Added contextDidChange.
  • platform/graphics/ca/win/LegacyCACFLayerTreeHost.cpp:

(WebCore::LegacyCACFLayerTreeHost::createRenderer):
(WebCore::LegacyCACFLayerTreeHost::resize):
Changed to use flushContext instead of flushing the context manually so that we will always
notify the base class when the context gets flushed.

(WebCore::LegacyCACFLayerTreeHost::flushContext): Added a call to contextDidChange so the
base class will know what happened. Moved code to schedule a render from here...
(WebCore::LegacyCACFLayerTreeHost::contextDidChange): ...to here.

  • platform/graphics/ca/win/LegacyCACFLayerTreeHost.h: Added contextDidChange.
  • platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp: Added.

(WebCore::WKCACFViewLayerTreeHost::create): If WebKitQuartzCoreAdditions, which provides
WKCACFView, isn't present, bail. Otherwise allocate and return a new host.
(WebCore::WKCACFViewLayerTreeHost::WKCACFViewLayerTreeHost): Initialize members.
(WebCore::WKCACFViewLayerTreeHost::updateViewIfNeeded): Update the view if we previously
marked that we needed to do so, and flush the context if our layer's bounds have changed.
(WebCore::WKCACFViewLayerTreeHost::contextDidChangeCallback): Call through to
contextDidChange.
(WebCore::WKCACFViewLayerTreeHost::contextDidChange): Tell the WKCACFView to start rendering
(if we didn't already), then call up to the base class.
(WebCore::WKCACFViewLayerTreeHost::initializeContext): Set the context's user data, the
view's layer, and hook up our "context did change" callback.
(WebCore::WKCACFViewLayerTreeHost::resize): Mark that the view needs to be updated the next
time we paint.
(WebCore::WKCACFViewLayerTreeHost::createRenderer): Update our view and return whether it is
able to render or not.
(WebCore::WKCACFViewLayerTreeHost::destroyRenderer): Clear out all the info we passed down
to the view.
(WebCore::WKCACFViewLayerTreeHost::lastCommitTime): Call through to the view.
(WebCore::WKCACFViewLayerTreeHost::flushContext): Ditto.
(WebCore::WKCACFViewLayerTreeHost::paint): Update the view so it will draw at the right
size, then call up to the base class.
(WebCore::WKCACFViewLayerTreeHost::render): Invalidate the view using the passed-in dirty
rects, then ask it to draw.

  • platform/graphics/ca/win/WKCACFViewLayerTreeHost.h: Copied from Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h.
Location:
trunk/Source/WebCore
Files:
1 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76856 r76858  
     12011-01-27  Adam Roben  <aroben@apple.com>
     2
     3        Add WKCACFViewLayerTreeHost
     4
     5        This is a class that derives from CACFLayerTreeHost and uses a WKCACFView to render.
     6
     7        Fixes <http://webkit.org/b/53251> <rdar://problem/8925496> CACFLayerTreeHost should use
     8        WKCACFView for rendering
     9
     10        * WebCore.vcproj/WebCore.vcproj: Added WKCACFViewLayerTreeHost.{cpp,h}.
     11
     12        * platform/graphics/ca/win/CACFLayerTreeHost.cpp:
     13        (WebCore::CACFLayerTreeHost::acceleratedCompositingAvailable): Make the test window have a
     14        non-zero size. WKCACFView will always say it can't render if you pass it a 0-sized window,
     15        so we need a non-empty window to perform a valid test.
     16        (WebCore::CACFLayerTreeHost::create): First try to create a WKCACFViewLayerTreeHost, then
     17        fall back to a LegacyCACFLayerTreeHost.
     18        (WebCore::CACFLayerTreeHost::flushPendingLayerChangesNow): Moved code to react to the
     19        context flush from here...
     20        (WebCore::CACFLayerTreeHost::contextDidChange): ...to here. Derived classes are required to
     21        call this function whenever changes are flushed to the context.
     22
     23        * platform/graphics/ca/win/CACFLayerTreeHost.h: Added contextDidChange.
     24
     25        * platform/graphics/ca/win/LegacyCACFLayerTreeHost.cpp:
     26        (WebCore::LegacyCACFLayerTreeHost::createRenderer):
     27        (WebCore::LegacyCACFLayerTreeHost::resize):
     28        Changed to use flushContext instead of flushing the context manually so that we will always
     29        notify the base class when the context gets flushed.
     30
     31        (WebCore::LegacyCACFLayerTreeHost::flushContext): Added a call to contextDidChange so the
     32        base class will know what happened. Moved code to schedule a render from here...
     33        (WebCore::LegacyCACFLayerTreeHost::contextDidChange): ...to here.
     34
     35        * platform/graphics/ca/win/LegacyCACFLayerTreeHost.h: Added contextDidChange.
     36
     37        * platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp: Added.
     38        (WebCore::WKCACFViewLayerTreeHost::create): If WebKitQuartzCoreAdditions, which provides
     39        WKCACFView, isn't present, bail. Otherwise allocate and return a new host.
     40        (WebCore::WKCACFViewLayerTreeHost::WKCACFViewLayerTreeHost): Initialize members.
     41        (WebCore::WKCACFViewLayerTreeHost::updateViewIfNeeded): Update the view if we previously
     42        marked that we needed to do so, and flush the context if our layer's bounds have changed.
     43        (WebCore::WKCACFViewLayerTreeHost::contextDidChangeCallback): Call through to
     44        contextDidChange.
     45        (WebCore::WKCACFViewLayerTreeHost::contextDidChange): Tell the WKCACFView to start rendering
     46        (if we didn't already), then call up to the base class.
     47        (WebCore::WKCACFViewLayerTreeHost::initializeContext): Set the context's user data, the
     48        view's layer, and hook up our "context did change" callback.
     49        (WebCore::WKCACFViewLayerTreeHost::resize): Mark that the view needs to be updated the next
     50        time we paint.
     51        (WebCore::WKCACFViewLayerTreeHost::createRenderer): Update our view and return whether it is
     52        able to render or not.
     53        (WebCore::WKCACFViewLayerTreeHost::destroyRenderer): Clear out all the info we passed down
     54        to the view.
     55        (WebCore::WKCACFViewLayerTreeHost::lastCommitTime): Call through to the view.
     56        (WebCore::WKCACFViewLayerTreeHost::flushContext): Ditto.
     57        (WebCore::WKCACFViewLayerTreeHost::paint): Update the view so it will draw at the right
     58        size, then call up to the base class.
     59        (WebCore::WKCACFViewLayerTreeHost::render): Invalidate the view using the passed-in dirty
     60        rects, then ask it to draw.
     61
     62        * platform/graphics/ca/win/WKCACFViewLayerTreeHost.h: Copied from Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h.
     63
    1642011-01-27  Adam Roben  <aroben@apple.com>
    265
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r76856 r76858  
    2896728967                                                        >
    2896828968                                                </File>
     28969                                                <File
     28970                                                        RelativePath="..\platform\graphics\ca\win\WKCACFViewLayerTreeHost.cpp"
     28971                                                        >
     28972                                                </File>
     28973                                                <File
     28974                                                        RelativePath="..\platform\graphics\ca\win\WKCACFViewLayerTreeHost.h"
     28975                                                        >
     28976                                                </File>
    2896928977                                        </Filter>
    2897028978                                </Filter>
  • trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp

    r76856 r76858  
    3333#include "LegacyCACFLayerTreeHost.h"
    3434#include "PlatformCALayer.h"
     35#include "WKCACFViewLayerTreeHost.h"
    3536#include "WebCoreInstanceHandle.h"
    3637#include <limits.h>
     
    9798    wcex.lpszClassName = L"CoreAnimationTesterWindowClass";
    9899    ::RegisterClassEx(&wcex);
    99     HWND testWindow = ::CreateWindow(L"CoreAnimationTesterWindowClass", L"CoreAnimationTesterWindow", WS_POPUP, -500, -500, 0, 0, 0, 0, 0, 0);
     100    HWND testWindow = ::CreateWindow(L"CoreAnimationTesterWindowClass", L"CoreAnimationTesterWindow", WS_POPUP, -500, -500, 20, 20, 0, 0, 0, 0);
    100101
    101102    if (!testWindow) {
     
    117118    if (!acceleratedCompositingAvailable())
    118119        return 0;
    119     RefPtr<CACFLayerTreeHost> host = LegacyCACFLayerTreeHost::create();
     120    RefPtr<CACFLayerTreeHost> host = WKCACFViewLayerTreeHost::create();
     121    if (!host)
     122        host = LegacyCACFLayerTreeHost::create();
    120123    host->initialize();
    121124    return host.release();
     
    293296    flushContext();
    294297
     298    m_isFlushingLayerChanges = false;
     299}
     300
     301void CACFLayerTreeHost::contextDidChange()
     302{
    295303    // All pending animations will have been started with the flush. Fire the animationStarted calls.
    296304    notifyAnimationsStarted();
    297 
    298     m_isFlushingLayerChanges = false;
    299305}
    300306
  • trunk/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.h

    r76853 r76858  
    7979    virtual bool createRenderer() = 0;
    8080    virtual void destroyRenderer();
     81    virtual void contextDidChange();
    8182
    8283private:
  • trunk/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.cpp

    r76856 r76858  
    190190    if (IsWindow(window())) {
    191191        rootLayer()->setBounds(bounds());
    192         wkCACFContextFlush(m_context);
     192        flushContext();
    193193    }
    194194
     
    222222    if (rootLayer()) {
    223223        rootLayer()->setBounds(bounds());
    224         wkCACFContextFlush(m_context);
     224        flushContext();
    225225    }
    226226}
     
    327327{
    328328    wkCACFContextFlush(m_context);
     329    contextDidChange();
     330}
     331
     332void LegacyCACFLayerTreeHost::contextDidChange()
     333{
    329334    renderSoon();
    330335}
  • trunk/Source/WebCore/platform/graphics/ca/win/LegacyCACFLayerTreeHost.h

    r76856 r76858  
    6161    virtual CFTimeInterval lastCommitTime() const;
    6262    virtual void flushContext();
     63    virtual void contextDidChange();
    6364    virtual void paint();
    6465    virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>());
  • trunk/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.h

    r76856 r76858  
    2424 */
    2525
    26 #ifndef LegacyCACFLayerTreeHost_h
    27 #define LegacyCACFLayerTreeHost_h
     26#ifndef WKCACFViewLayerTreeHost_h
     27#define WKCACFViewLayerTreeHost_h
    2828
    2929#if USE(ACCELERATED_COMPOSITING)
     
    3131#include "CACFLayerTreeHost.h"
    3232
     33typedef struct _WKCACFView* WKCACFViewRef;
     34
    3335namespace WebCore {
    3436
    35 // FIXME: Currently there is a LegacyCACFLayerTreeHost for each WebView and each
    36 // has its own WKCACFContext and Direct3DDevice9, which is inefficient.
    37 // (https://bugs.webkit.org/show_bug.cgi?id=31855)
    38 class LegacyCACFLayerTreeHost : public CACFLayerTreeHost {
     37class WKCACFViewLayerTreeHost : public CACFLayerTreeHost {
    3938public:
    40     static PassRefPtr<LegacyCACFLayerTreeHost> create();
    41     virtual ~LegacyCACFLayerTreeHost();
     39    static PassRefPtr<WKCACFViewLayerTreeHost> create();
    4240
    4341private:
    44     LegacyCACFLayerTreeHost();
     42    WKCACFViewLayerTreeHost();
    4543
    46     void initD3DGeometry();
    47 
    48     // Call this when the device window has changed size or when IDirect3DDevice9::Present returns
    49     // D3DERR_DEVICELOST. Returns true if the device was recovered, false if rendering must be
    50     // aborted and reattempted soon.
    51     enum ResetReason { ChangedWindowSize, LostDevice };
    52     bool resetDevice(ResetReason);
    53 
    54     void renderSoon();
    55     void renderTimerFired(Timer<LegacyCACFLayerTreeHost>*);
     44    void updateViewIfNeeded();
     45    static void contextDidChangeCallback(WKCACFViewRef, void* info);
    5646
    5747    virtual void initializeContext(void* userData, PlatformCALayer*);
     
    5949    virtual bool createRenderer();
    6050    virtual void destroyRenderer();
    61     virtual CFTimeInterval lastCommitTime() const;
    6251    virtual void flushContext();
     52    virtual void contextDidChange();
    6353    virtual void paint();
    6454    virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>());
     55    virtual CFTimeInterval lastCommitTime() const;
    6556
    66     Timer<LegacyCACFLayerTreeHost> m_renderTimer;
    67     COMPtr<IDirect3DDevice9> m_d3dDevice;
    68     WKCACFContext* m_context;
    69     bool m_mightBeAbleToCreateDeviceLater;
    70     bool m_mustResetLostDeviceBeforeRendering;
    71 
    72 #ifndef NDEBUG
    73     bool m_printTree;
    74 #endif
     57    RetainPtr<WKCACFViewRef> m_view;
     58    bool m_viewNeedsUpdate;
    7559};
    7660
     
    7963#endif // USE(ACCELERATED_COMPOSITING)
    8064
    81 #endif // LegacyCACFLayerTreeHost_h
     65#endif // WKCACFViewLayerTreeHost_h
Note: See TracChangeset for help on using the changeset viewer.