Changeset 103293 in webkit


Ignore:
Timestamp:
Dec 19, 2011 6:54:49 PM (12 years ago)
Author:
jamesr@google.com
Message:

[chromium] CCLayerDelegate and WebLayerClient do not need notifySyncRequired
https://bugs.webkit.org/show_bug.cgi?id=74376

Reviewed by Kenneth Russell.

Source/WebCore:

CCLayerDelegate::notifySyncRequired is an odd bit of interface that we originally cargo-culted from the
CoreAnimation compositor implementation. It is a mechanism by which a LayerChromium instance may request a new
frame via its CCLayerDelegate, which in WebCore is always a GraphicsLayerClient. In practice, all
implementations eventually ended up routing to CCLayerTreeHost::setNeedsCommit which then made the proper
scheduling decision.

This patch routes all changes that would have gone through CCLayerDelegate::notifySyncRequired directly to
CCLayerTreeHost::setNeedsCommit, which greatly simplifies the scheduling logic.

There is a large amount of unit test coverage for this change, largely in LayerChromiumTest

  • platform/graphics/chromium/GraphicsLayerChromium.cpp:
  • platform/graphics/chromium/GraphicsLayerChromium.h:
  • platform/graphics/chromium/LayerChromium.cpp:

(WebCore::LayerChromium::setNeedsCommit):
(WebCore::LayerChromium::insertChild):

  • platform/graphics/chromium/LayerChromium.h:
  • platform/graphics/chromium/cc/CCLayerTreeHost.cpp:

(WebCore::CCLayerTreeHost::~CCLayerTreeHost):
(WebCore::CCLayerTreeHost::setRootLayer):

  • platform/graphics/chromium/cc/CCLayerTreeHost.h:
  • platform/graphics/chromium/cc/CCScopedThreadProxy.h:

(WebCore::CCScopedThreadProxy::runTaskIfNotShutdown):

Source/WebKit/chromium:

WebLayerClient::notifyNeedsComposite() is an odd interface for the same reason that
CCLayerDelegate::notifySyncRequired() is - all scheduling decisions should route through the WebLayerTreeView,
not individual layers. In practice, all implementations of WebLayerClient::notifySyncRequired() do the exact
same thing as WebLayerTreeView::scheduleComposite(). This removes that callback, making WebLayerClient an empty
interface, and routes all calls that would go to that interface to WebLayerTreeView::scheduleComposite().

Once downstream implementations of WebLayerClient are removed, WebLayerClient.h and the constructors associated
with it can be deleted.

The bulk of the changes here are to the test harness. Many tests that were designed around notifySyncRequired()
are rewritten to check for CCLayerTreeHost::setNeedsCommit() or WebLayerTreeView::scheduleComposite() instead.
In a few instances, this required changing the setup logic around somewhat so that the layers being manipulated
were in a tree that initialized without errors.

  • WebKit.gypi:
  • public/platform/WebContentLayer.h:
  • public/platform/WebExternalTextureLayer.h:
  • public/platform/WebLayer.h:
  • public/platform/WebLayerClient.h:
  • src/WebContentLayer.cpp:

(WebKit::WebContentLayer::create):

  • src/WebContentLayerImpl.cpp:

(WebKit::WebContentLayerImpl::create):
(WebKit::WebContentLayerImpl::WebContentLayerImpl):

  • src/WebContentLayerImpl.h:
  • src/WebExternalTextureLayer.cpp:

(WebKit::WebExternalTextureLayer::create):

  • src/WebExternalTextureLayerImpl.cpp:

(WebKit::WebExternalTextureLayerImpl::create):
(WebKit::WebExternalTextureLayerImpl::WebExternalTextureLayerImpl):

  • src/WebExternalTextureLayerImpl.h:
  • src/WebLayer.cpp:

(WebKit::WebLayer::create):

  • src/WebLayerImpl.cpp:

(WebKit::WebLayerImpl::create):
(WebKit::WebLayerImpl::WebLayerImpl):

  • src/WebLayerImpl.h:
  • src/WebLayerTreeViewImpl.cpp:

(WebKit::WebLayerTreeViewImpl::create):
(WebKit::WebLayerTreeViewImpl::WebLayerTreeViewImpl):

  • src/WebLayerTreeViewImpl.h:
  • tests/CCLayerTreeHostTest.cpp:

(WTF::MockLayerTreeHost::create):
(WTF::MockLayerTreeHost::MockLayerTreeHost):
(WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D):
(WTF::CCLayerTreeHostTestScrollSimple::animateAndLayout):

  • tests/CompositorMockGraphicsContext3D.h: Added.

(WebCore::createCompositorMockGraphicsContext3D):

  • tests/CompositorMockWebGraphicsContext3D.h: Added.

(WebKit::CompositorMockWebGraphicsContext3D::create):
(WebKit::CompositorMockWebGraphicsContext3D::makeContextCurrent):
(WebKit::CompositorMockWebGraphicsContext3D::createProgram):
(WebKit::CompositorMockWebGraphicsContext3D::createShader):
(WebKit::CompositorMockWebGraphicsContext3D::getShaderiv):
(WebKit::CompositorMockWebGraphicsContext3D::getProgramiv):
(WebKit::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D):

  • tests/LayerChromiumTest.cpp:
  • tests/MockWebGraphicsContext3D.h:

(WebKit::MockWebGraphicsContext3D::getContextAttributes):

  • tests/WebGLLayerChromiumTest.cpp:

(WebKit::TEST):

  • tests/WebLayerTest.cpp:

(testing::MockWebLayerTreeViewClient::animateAndLayout):
(testing::MockWebLayerTreeViewClient::applyScrollAndScale):
(testing::MockWebLayerTreeViewClient::createContext3D):
(testing::MockWebLayerTreeViewClient::didRebindGraphicsContext):
(testing::WebLayerTest::SetUp):
(testing::WebLayerTest::TearDown):
(testing::TEST_F):

Location:
trunk/Source
Files:
2 added
28 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r103291 r103293  
     12011-12-19  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] CCLayerDelegate and WebLayerClient do not need notifySyncRequired
     4        https://bugs.webkit.org/show_bug.cgi?id=74376
     5
     6        Reviewed by Kenneth Russell.
     7
     8        CCLayerDelegate::notifySyncRequired is an odd bit of interface that we originally cargo-culted from the
     9        CoreAnimation compositor implementation. It is a mechanism by which a LayerChromium instance may request a new
     10        frame via its CCLayerDelegate, which in WebCore is always a GraphicsLayerClient. In practice, all
     11        implementations eventually ended up routing to CCLayerTreeHost::setNeedsCommit which then made the proper
     12        scheduling decision.
     13
     14        This patch routes all changes that would have gone through CCLayerDelegate::notifySyncRequired directly to
     15        CCLayerTreeHost::setNeedsCommit, which greatly simplifies the scheduling logic.
     16
     17        There is a large amount of unit test coverage for this change, largely in LayerChromiumTest
     18
     19        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
     20        * platform/graphics/chromium/GraphicsLayerChromium.h:
     21        * platform/graphics/chromium/LayerChromium.cpp:
     22        (WebCore::LayerChromium::setNeedsCommit):
     23        (WebCore::LayerChromium::insertChild):
     24        * platform/graphics/chromium/LayerChromium.h:
     25        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     26        (WebCore::CCLayerTreeHost::~CCLayerTreeHost):
     27        (WebCore::CCLayerTreeHost::setRootLayer):
     28        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     29        * platform/graphics/chromium/cc/CCScopedThreadProxy.h:
     30        (WebCore::CCScopedThreadProxy::runTaskIfNotShutdown):
     31
    1322011-12-19  Sailesh Agrawal <sail@chromium.org>
    233
  • trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp

    r103150 r103293  
    666666}
    667667
    668 void GraphicsLayerChromium::notifySyncRequired()
    669 {
    670     if (m_client)
    671         m_client->notifySyncRequired(this);
    672 }
    673 
    674668} // namespace WebCore
    675669
  • trunk/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h

    r103150 r103293  
    100100    virtual bool drawsContent() const;
    101101    virtual void paintContents(GraphicsContext&, const IntRect& clip);
    102     virtual void notifySyncRequired();
    103102
    104103    // Exposed for tests.
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp

    r103290 r103293  
    130130void LayerChromium::setNeedsCommit()
    131131{
    132     if (m_delegate)
    133         m_delegate->notifySyncRequired();
     132    if (m_layerTreeHost)
     133        m_layerTreeHost->setNeedsCommit();
    134134}
    135135
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r103290 r103293  
    6262    virtual bool drawsContent() const = 0;
    6363    virtual void paintContents(GraphicsContext&, const IntRect& clip) = 0;
    64     virtual void notifySyncRequired() = 0;
    6564};
    6665
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r103290 r103293  
    105105    ASSERT(CCProxy::isMainThread());
    106106    TRACE_EVENT("CCLayerTreeHost::~CCLayerTreeHost", this, 0);
     107    ASSERT(m_proxy);
    107108    m_proxy->stop();
    108109    m_proxy.clear();
     
    249250    if (m_rootLayer)
    250251        m_rootLayer->setLayerTreeHost(this);
     252    setNeedsCommit();
    251253}
    252254
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r103290 r103293  
    164164
    165165    void setNeedsAnimate();
    166     void setNeedsCommit();
     166    // virtual for testing
     167    virtual void setNeedsCommit();
    167168    void setNeedsRedraw();
    168169
  • trunk/Source/WebKit/chromium/ChangeLog

    r103290 r103293  
     12011-12-19  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] CCLayerDelegate and WebLayerClient do not need notifySyncRequired
     4        https://bugs.webkit.org/show_bug.cgi?id=74376
     5
     6        Reviewed by Kenneth Russell.
     7
     8        WebLayerClient::notifyNeedsComposite() is an odd interface for the same reason that
     9        CCLayerDelegate::notifySyncRequired() is - all scheduling decisions should route through the WebLayerTreeView,
     10        not individual layers. In practice, all implementations of WebLayerClient::notifySyncRequired() do the exact
     11        same thing as WebLayerTreeView::scheduleComposite(). This removes that callback, making WebLayerClient an empty
     12        interface, and routes all calls that would go to that interface to WebLayerTreeView::scheduleComposite().
     13
     14        Once downstream implementations of WebLayerClient are removed, WebLayerClient.h and the constructors associated
     15        with it can be deleted.
     16
     17        The bulk of the changes here are to the test harness. Many tests that were designed around notifySyncRequired()
     18        are rewritten to check for CCLayerTreeHost::setNeedsCommit() or WebLayerTreeView::scheduleComposite() instead.
     19        In a few instances, this required changing the setup logic around somewhat so that the layers being manipulated
     20        were in a tree that initialized without errors.
     21
     22        * WebKit.gypi:
     23        * public/platform/WebContentLayer.h:
     24        * public/platform/WebExternalTextureLayer.h:
     25        * public/platform/WebLayer.h:
     26        * public/platform/WebLayerClient.h:
     27        * src/WebContentLayer.cpp:
     28        (WebKit::WebContentLayer::create):
     29        * src/WebContentLayerImpl.cpp:
     30        (WebKit::WebContentLayerImpl::create):
     31        (WebKit::WebContentLayerImpl::WebContentLayerImpl):
     32        * src/WebContentLayerImpl.h:
     33        * src/WebExternalTextureLayer.cpp:
     34        (WebKit::WebExternalTextureLayer::create):
     35        * src/WebExternalTextureLayerImpl.cpp:
     36        (WebKit::WebExternalTextureLayerImpl::create):
     37        (WebKit::WebExternalTextureLayerImpl::WebExternalTextureLayerImpl):
     38        * src/WebExternalTextureLayerImpl.h:
     39        * src/WebLayer.cpp:
     40        (WebKit::WebLayer::create):
     41        * src/WebLayerImpl.cpp:
     42        (WebKit::WebLayerImpl::create):
     43        (WebKit::WebLayerImpl::WebLayerImpl):
     44        * src/WebLayerImpl.h:
     45        * src/WebLayerTreeViewImpl.cpp:
     46        (WebKit::WebLayerTreeViewImpl::create):
     47        (WebKit::WebLayerTreeViewImpl::WebLayerTreeViewImpl):
     48        * src/WebLayerTreeViewImpl.h:
     49        * tests/CCLayerTreeHostTest.cpp:
     50        (WTF::MockLayerTreeHost::create):
     51        (WTF::MockLayerTreeHost::MockLayerTreeHost):
     52        (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D):
     53        (WTF::CCLayerTreeHostTestScrollSimple::animateAndLayout):
     54        * tests/CompositorMockGraphicsContext3D.h: Added.
     55        (WebCore::createCompositorMockGraphicsContext3D):
     56        * tests/CompositorMockWebGraphicsContext3D.h: Added.
     57        (WebKit::CompositorMockWebGraphicsContext3D::create):
     58        (WebKit::CompositorMockWebGraphicsContext3D::makeContextCurrent):
     59        (WebKit::CompositorMockWebGraphicsContext3D::createProgram):
     60        (WebKit::CompositorMockWebGraphicsContext3D::createShader):
     61        (WebKit::CompositorMockWebGraphicsContext3D::getShaderiv):
     62        (WebKit::CompositorMockWebGraphicsContext3D::getProgramiv):
     63        (WebKit::CompositorMockWebGraphicsContext3D::CompositorMockWebGraphicsContext3D):
     64        * tests/LayerChromiumTest.cpp:
     65        * tests/MockWebGraphicsContext3D.h:
     66        (WebKit::MockWebGraphicsContext3D::getContextAttributes):
     67        * tests/WebGLLayerChromiumTest.cpp:
     68        (WebKit::TEST):
     69        * tests/WebLayerTest.cpp:
     70        (testing::MockWebLayerTreeViewClient::animateAndLayout):
     71        (testing::MockWebLayerTreeViewClient::applyScrollAndScale):
     72        (testing::MockWebLayerTreeViewClient::createContext3D):
     73        (testing::MockWebLayerTreeViewClient::didRebindGraphicsContext):
     74        (testing::WebLayerTest::SetUp):
     75        (testing::WebLayerTest::TearDown):
     76        (testing::TEST_F):
     77
    1782011-12-19  James Robinson  <jamesr@chromium.org>
    279
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r103264 r103293  
    6767            'tests/CCLayerTreeTestCommon.h',
    6868            'tests/CCRenderSurfaceTest.cpp',
    69             'tests/CCSchedulerTest.cpp',
    7069            'tests/CCSchedulerStateMachineTest.cpp',
    7170            'tests/CCSchedulerTestCommon.h',
     71            'tests/CCSchedulerTest.cpp',
    7272            'tests/CCThreadTaskTest.cpp',
     73            'tests/CompositorFakeGraphicsContext3D.h',
     74            'tests/CompositorFakeWebGraphicsContext3D.h',
     75            'tests/FakeGraphicsContext3DTest.cpp',
     76            'tests/FakeWebGraphicsContext3D.h',
    7377            'tests/FloatQuadTest.cpp',
    7478            'tests/FrameTestHelpers.cpp',
     
    8185            'tests/KURLTest.cpp',
    8286            'tests/LayerChromiumTest.cpp',
    83             'tests/MockGraphicsContext3DTest.cpp',
    84             'tests/MockWebGraphicsContext3D.h',
    8587            'tests/PODArenaTest.cpp',
    8688            'tests/PODIntervalTreeTest.cpp',
  • trunk/Source/WebKit/chromium/public/platform/WebContentLayer.h

    r103150 r103293  
    3838class WebContentLayer : public WebLayer {
    3939public:
     40    WEBKIT_EXPORT static WebContentLayer create(WebContentLayerClient*);
     41    // FIXME: Remove this as soon as downstream clients are updated.
    4042    WEBKIT_EXPORT static WebContentLayer create(WebLayerClient*, WebContentLayerClient*);
    4143
  • trunk/Source/WebKit/chromium/public/platform/WebExternalTextureLayer.h

    r103150 r103293  
    4343class WebExternalTextureLayer : public WebLayer {
    4444public:
     45    WEBKIT_EXPORT static WebExternalTextureLayer create();
     46    // FIXME: Remove as soon as downstream clients are updated.
    4547    WEBKIT_EXPORT static WebExternalTextureLayer create(WebLayerClient*);
    4648
  • trunk/Source/WebKit/chromium/public/platform/WebLayer.h

    r103150 r103293  
    4141class WebLayer {
    4242public:
     43    WEBKIT_EXPORT static WebLayer create();
     44    // FIXME: Remove this constructor once downstream clients are updated.
    4345    WEBKIT_EXPORT static WebLayer create(WebLayerClient*);
    4446
  • trunk/Source/WebKit/chromium/public/platform/WebLayerClient.h

    r103150 r103293  
    3131class WebLayerClient {
    3232public:
    33     // Notifies the client that the layer has changed in a way that needs a
    34     // compositing pass to visually update. The client should eventually call
    35     // WebLayerTreeView::composite.
    36     // Note: some complex operations (e.g layer reparenting) can cause this to
    37     // be called while the layer tree is in an inconsistent state, so to get
    38     // correct results, WebLayerTreeView::composite should be called after the
    39     // operation has finished (e.g. by posting a task).
    40     virtual void notifyNeedsComposite() = 0;
     33    // This empty interface exists only for legacy reasons - it will be deleted as soon
     34    // as downstream consumers stop depending on this interface existing.
    4135
    4236protected:
  • trunk/Source/WebKit/chromium/src/WebContentLayer.cpp

    r103150 r103293  
    3232namespace WebKit {
    3333
    34 WebContentLayer WebContentLayer::create(WebLayerClient* client, WebContentLayerClient* contentClient)
     34WebContentLayer WebContentLayer::create(WebContentLayerClient* contentClient)
    3535{
    36     return WebContentLayer(WebContentLayerImpl::create(client, contentClient));
     36    return WebContentLayer(WebContentLayerImpl::create(contentClient));
     37}
     38
     39WebContentLayer WebContentLayer::create(WebLayerClient*, WebContentLayerClient* contentClient)
     40{
     41    return WebContentLayer::create(contentClient);
    3742}
    3843
  • trunk/Source/WebKit/chromium/src/WebContentLayerImpl.cpp

    r103150 r103293  
    2828
    2929#include "platform/WebContentLayerClient.h"
    30 #include "platform/WebLayerClient.h"
    3130#include "platform/WebRect.h"
    3231#include "GraphicsContext.h"
     
    4039namespace WebKit {
    4140
    42 PassRefPtr<WebContentLayerImpl> WebContentLayerImpl::create(WebLayerClient* client, WebContentLayerClient* contentClient)
     41PassRefPtr<WebContentLayerImpl> WebContentLayerImpl::create(WebContentLayerClient* contentClient)
    4342{
    44     return adoptRef(new WebContentLayerImpl(client, contentClient));
     43    return adoptRef(new WebContentLayerImpl(contentClient));
    4544}
    4645
    47 WebContentLayerImpl::WebContentLayerImpl(WebLayerClient* client, WebContentLayerClient* contentClient)
     46WebContentLayerImpl::WebContentLayerImpl(WebContentLayerClient* contentClient)
    4847    : ContentLayerChromium(this)
    49     , m_client(client)
    5048    , m_contentClient(contentClient)
    5149    , m_drawsContent(true)
     
    8179}
    8280
    83 void WebContentLayerImpl::notifySyncRequired()
    84 {
    85     if (m_client)
    86         m_client->notifyNeedsComposite();
    87 }
    88 
    8981} // namespace WebKit
  • trunk/Source/WebKit/chromium/src/WebContentLayerImpl.h

    r103150 r103293  
    3131
    3232namespace WebKit {
    33 class WebLayerClient;
    3433class WebContentLayerClient;
    3534
    3635class WebContentLayerImpl : public WebCore::ContentLayerChromium, public WebCore::CCLayerDelegate {
    3736public:
    38     static PassRefPtr<WebContentLayerImpl> create(WebLayerClient*, WebContentLayerClient* contentClient);
     37    static PassRefPtr<WebContentLayerImpl> create(WebContentLayerClient* contentClient);
    3938
    4039    void setDrawsContent(bool);
     
    4241
    4342protected:
    44     WebContentLayerImpl(WebLayerClient*, WebContentLayerClient* contentClient);
     43    explicit WebContentLayerImpl(WebContentLayerClient* contentClient);
    4544    virtual ~WebContentLayerImpl();
    4645    virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip);
    47     virtual void notifySyncRequired();
    4846
    49     WebLayerClient* m_client;
    5047    WebContentLayerClient* m_contentClient;
    5148    bool m_drawsContent;
  • trunk/Source/WebKit/chromium/src/WebExternalTextureLayer.cpp

    r103150 r103293  
    3232namespace WebKit {
    3333
    34 WebExternalTextureLayer WebExternalTextureLayer::create(WebLayerClient* client)
     34WebExternalTextureLayer WebExternalTextureLayer::create(WebLayerClient*)
    3535{
    36     return WebExternalTextureLayer(WebExternalTextureLayerImpl::create(client));
     36    return WebExternalTextureLayer::create();
     37}
     38
     39WebExternalTextureLayer WebExternalTextureLayer::create()
     40{
     41    return WebExternalTextureLayer(WebExternalTextureLayerImpl::create());
    3742}
    3843
  • trunk/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.cpp

    r103150 r103293  
    2727#include "WebExternalTextureLayerImpl.h"
    2828
    29 #include "platform/WebLayerClient.h"
    3029#include "GraphicsContext.h"
    3130#include "platform/WebCanvas.h"
     
    3534namespace WebKit {
    3635
    37 PassRefPtr<WebExternalTextureLayerImpl> WebExternalTextureLayerImpl::create(WebLayerClient* client)
     36PassRefPtr<WebExternalTextureLayerImpl> WebExternalTextureLayerImpl::create()
    3837{
    39     return adoptRef(new WebExternalTextureLayerImpl(client));
     38    return adoptRef(new WebExternalTextureLayerImpl());
    4039}
    4140
    42 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(WebLayerClient* client)
     41WebExternalTextureLayerImpl::WebExternalTextureLayerImpl()
    4342    : PluginLayerChromium(this)
    44     , m_client(client)
    4543{
    4644    setFlipped(false);
     
    6159}
    6260
    63 void WebExternalTextureLayerImpl::notifySyncRequired()
    64 {
    65     if (m_client)
    66         m_client->notifyNeedsComposite();
    67 }
    68 
    6961} // namespace WebKit
  • trunk/Source/WebKit/chromium/src/WebExternalTextureLayerImpl.h

    r103150 r103293  
    3131
    3232namespace WebKit {
    33 class WebLayerClient;
    3433
    3534class WebExternalTextureLayerImpl : public WebCore::PluginLayerChromium, public WebCore::CCLayerDelegate {
    3635public:
    37     static PassRefPtr<WebExternalTextureLayerImpl> create(WebLayerClient*);
     36    static PassRefPtr<WebExternalTextureLayerImpl> create();
    3837
    3938protected:
    40     WebExternalTextureLayerImpl(WebLayerClient*);
     39    WebExternalTextureLayerImpl();
    4140    virtual ~WebExternalTextureLayerImpl();
    4241    virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip);
    43     virtual void notifySyncRequired();
    4442    virtual bool drawsContent() const;
    45 
    46     WebLayerClient* m_client;
    4743};
    4844
  • trunk/Source/WebKit/chromium/src/WebLayer.cpp

    r103150 r103293  
    7575namespace WebKit {
    7676
    77 WebLayer WebLayer::create(WebLayerClient* client)
    78 {
    79     return WebLayer(WebLayerImpl::create(client));
     77WebLayer WebLayer::create(WebLayerClient*)
     78{
     79    return WebLayer::create();
     80}
     81
     82WebLayer WebLayer::create()
     83{
     84    return WebLayer(WebLayerImpl::create());
    8085}
    8186
  • trunk/Source/WebKit/chromium/src/WebLayerImpl.cpp

    r103150 r103293  
    2727#include "WebLayerImpl.h"
    2828
    29 #include "platform/WebLayerClient.h"
    30 
    3129using namespace WebCore;
    3230
    3331namespace WebKit {
    3432
    35 PassRefPtr<WebLayerImpl> WebLayerImpl::create(WebLayerClient* client)
     33PassRefPtr<WebLayerImpl> WebLayerImpl::create()
    3634{
    37     return adoptRef(new WebLayerImpl(client));
     35    return adoptRef(new WebLayerImpl());
    3836}
    3937
    40 WebLayerImpl::WebLayerImpl(WebLayerClient* client) : LayerChromium(this), m_client(client)
     38WebLayerImpl::WebLayerImpl()
     39    : LayerChromium(this)
    4140{
    4241}
     
    5655}
    5756
    58 void WebLayerImpl::notifySyncRequired()
    59 {
    60     if (m_client)
    61         m_client->notifyNeedsComposite();
    62 }
    63 
    6457} // namespace WebKit
  • trunk/Source/WebKit/chromium/src/WebLayerImpl.h

    r103150 r103293  
    3131
    3232namespace WebKit {
    33 class WebLayerClient;
    3433
    3534class WebLayerImpl : public WebCore::LayerChromium, public WebCore::CCLayerDelegate {
    3635public:
    37     static PassRefPtr<WebLayerImpl> create(WebLayerClient*);
     36    static PassRefPtr<WebLayerImpl> create();
    3837
    3938protected:
    40     WebLayerImpl(WebLayerClient*);
     39    WebLayerImpl();
    4140    virtual ~WebLayerImpl();
    4241    virtual bool drawsContent() const;
    4342    virtual void paintContents(WebCore::GraphicsContext&, const WebCore::IntRect& clip);
    44     virtual void notifySyncRequired();
    45 
    46     WebLayerClient* m_client;
    4743};
    4844
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp

    r103150 r103293  
    2727#include "cc/CCLayerTreeHostImpl.h"
    2828
     29#include "FakeWebGraphicsContext3D.h"
    2930#include "GraphicsContext3DPrivate.h"
    3031#include "LayerRendererChromium.h"
    31 #include "MockWebGraphicsContext3D.h"
    3232#include "cc/CCLayerImpl.h"
    3333#include "cc/CCSingleThreadProxy.h"
     
    156156}
    157157
    158 class BlendStateTrackerContext: public MockWebGraphicsContext3D {
     158class BlendStateTrackerContext: public FakeWebGraphicsContext3D {
    159159public:
    160160    BlendStateTrackerContext() : m_blend(false) { }
     
    290290}
    291291
    292 class ReshapeTrackerContext: public MockWebGraphicsContext3D {
     292class ReshapeTrackerContext: public FakeWebGraphicsContext3D {
    293293public:
    294294    ReshapeTrackerContext() : m_reshapeCalled(false) { }
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r103290 r103293  
    2727#include "cc/CCLayerTreeHost.h"
    2828
     29#include "CompositorFakeGraphicsContext3D.h"
    2930#include "ContentLayerChromium.h"
    30 #include "GraphicsContext3DPrivate.h"
     31#include "FakeWebGraphicsContext3D.h"
    3132#include "LayerChromium.h"
    32 #include "MockWebGraphicsContext3D.h"
    3333#include "TextureManager.h"
    3434#include "WebCompositor.h"
     
    105105    {
    106106        RefPtr<MockLayerTreeHost> layerTreeHost = adoptRef(new MockLayerTreeHost(testHooks, client, settings));
    107         layerTreeHost->setRootLayer(rootLayer);
    108107        bool success = layerTreeHost->initialize();
    109108        EXPECT_TRUE(success);
     109        layerTreeHost->setRootLayer(rootLayer);
    110110
    111111        // LayerTreeHostImpl won't draw if it has 1x1 viewport.
     
    130130};
    131131
    132 // Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.
    133 class CompositorMockWebGraphicsContext3D : public MockWebGraphicsContext3D {
    134 public:
    135     static PassOwnPtr<CompositorMockWebGraphicsContext3D> create()
    136     {
    137         return adoptPtr(new CompositorMockWebGraphicsContext3D());
    138     }
    139 
    140     virtual bool makeContextCurrent() { return true; }
    141     virtual WebGLId createProgram() { return 1; }
    142     virtual WebGLId createShader(WGC3Denum) { return 1; }
    143     virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
    144     virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
    145 
    146 private:
    147     CompositorMockWebGraphicsContext3D() { }
    148 };
    149 
    150132// Implementation of CCLayerTreeHost callback interface.
    151133class MockLayerTreeHostClient : public CCLayerTreeHostClient {
     
    168150    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D()
    169151    {
    170         OwnPtr<WebGraphicsContext3D> mock = CompositorMockWebGraphicsContext3D::create();
    171         GraphicsContext3D::Attributes attrs;
    172         RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(mock.release(), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnAnotherThread);
    173         return context;
     152        return createCompositorMockGraphicsContext3D(GraphicsContext3D::Attributes());
    174153    }
    175154
     
    758737    }
    759738
    760     virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl)
     739    virtual void animateAndLayout(double frameBeginTime)
    761740    {
    762741        LayerChromium* root = m_layerTreeHost->rootLayer();
     
    943922    virtual bool drawsContent() const { return true; }
    944923    virtual bool preserves3D() { return false; }
    945     virtual void notifySyncRequired() { }
    946924
    947925private:
  • trunk/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp

    r103273 r103293  
    2727#include "Canvas2DLayerChromium.h"
    2828
     29#include "FakeWebGraphicsContext3D.h"
    2930#include "GraphicsContext3DPrivate.h"
    30 #include "MockWebGraphicsContext3D.h"
    3131#include "TextureManager.h"
    3232#include "cc/CCCanvasLayerImpl.h"
     
    5959namespace {
    6060
    61 class MockCanvasContext : public MockWebGraphicsContext3D {
     61class MockCanvasContext : public FakeWebGraphicsContext3D {
    6262public:
    6363    MOCK_METHOD0(createFramebuffer, WebGLId());
  • trunk/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp

    r103292 r103293  
    2828#include "GraphicsContext3D.h"
    2929
     30#include "FakeWebGraphicsContext3D.h"
    3031#include "GraphicsContext3DPrivate.h"
    31 #include "MockWebGraphicsContext3D.h"
    3232
    3333#include <gmock/gmock.h>
     
    3636using namespace WebCore;
    3737using namespace WebKit;
    38 using testing::Return;
    3938
    40 class FrameCountingContext : public MockWebGraphicsContext3D {
     39class FrameCountingContext : public FakeWebGraphicsContext3D {
    4140public:
    4241    FrameCountingContext() : m_frame(0) { }
     
    5150};
    5251
    53 TEST(MockGraphicsContext3DTest, CanOverrideManually)
     52TEST(FakeGraphicsContext3DTest, CanOverrideManually)
    5453{
    5554    GraphicsContext3D::Attributes attrs;
     
    6766
    6867
    69 class GMockContext : public MockWebGraphicsContext3D {
     68class GMockContext : public FakeWebGraphicsContext3D {
    7069public:
    7170    MOCK_METHOD0(getError, WGC3Denum());
    7271};
    7372
    74 TEST(MockGraphicsContext3DTest, CanUseGMock)
     73TEST(FakeGraphicsContext3DTest, CanUseGMock)
    7574{
    7675    GraphicsContext3D::Attributes attrs;
     
    7978
    8079    EXPECT_CALL(mockContext, getError())
    81             .WillRepeatedly(Return(314));
     80            .WillRepeatedly(testing::Return(314));
    8281
    8382    // It's OK to call methods GMock doesn't know about.
     
    8988}
    9089
    91 class ContextThatCountsMakeCurrents : public MockWebGraphicsContext3D {
     90class ContextThatCountsMakeCurrents : public FakeWebGraphicsContext3D {
    9291public:
    9392    ContextThatCountsMakeCurrents() : m_makeCurrentCount(0) { }
     
    103102
    104103
    105 TEST(MockGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)
     104TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldMakeCurrent)
    106105{
    107106    GraphicsContext3D::Attributes attrs;
     
    112111}
    113112
    114 TEST(MockGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)
     113TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)
    115114{
    116115    GraphicsContext3D::Attributes attrs;
     
    121120}
    122121
    123 class ContextWithMakeCurrentThatFails : public MockWebGraphicsContext3D {
     122class ContextWithMakeCurrentThatFails : public FakeWebGraphicsContext3D {
    124123public:
    125124    ContextWithMakeCurrentThatFails() { }
     
    127126};
    128127
    129 TEST(MockGraphicsContext3DTest, ContextForThisThreadFailsWhenMakeCurrentFails)
     128TEST(FakeGraphicsContext3DTest, ContextForThisThreadFailsWhenMakeCurrentFails)
    130129{
    131130    GraphicsContext3D::Attributes attrs;
  • trunk/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h

    r103292 r103293  
    2424 */
    2525
    26 #ifndef MockWebGraphicsContext3D_h
    27 #define MockWebGraphicsContext3D_h
     26#ifndef FakeWebGraphicsContext3D_h
     27#define FakeWebGraphicsContext3D_h
    2828
    2929#include "GraphicsContext3D.h"
     
    3434// WebGraphicsContext3D base class for use in WebKit unit tests.
    3535// All operations are no-ops (returning 0 if necessary).
    36 class MockWebGraphicsContext3D : public WebGraphicsContext3D {
     36class FakeWebGraphicsContext3D : public WebGraphicsContext3D {
    3737public:
    3838    virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return false; }
     
    129129    virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { }
    130130    virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Dint* value) { }
    131     virtual Attributes getContextAttributes() { return Attributes(); }
     131    virtual Attributes getContextAttributes() { return m_attrs; }
    132132    virtual WGC3Denum getError() { return 0; }
    133133    virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { }
     
    255255    virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
    256256                                 WGC3Dint width, WGC3Dint height) { }
     257
     258protected:
     259    Attributes m_attrs;
    257260};
    258261
    259262} // namespace WebKit
    260263
    261 #endif // MockWebGraphicsContext3D_h
     264#endif // FakeWebGraphicsContext3D_h
  • trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp

    r103290 r103293  
    2727#include "LayerChromium.h"
    2828
     29#include "cc/CCLayerTreeHost.h"
    2930#include "CCLayerTreeTestCommon.h"
    3031#include "LayerPainterChromium.h"
     
    3637
    3738using namespace WebCore;
    38 using namespace WebKit;
    3939using namespace WebKitTests;
    4040using ::testing::Mock;
     
    4343using ::testing::AnyNumber;
    4444
    45 #define EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(delegate, numTimesExpectedNotifySync, codeToTest) \
    46     EXPECT_CALL((delegate), notifySyncRequired()).Times((numTimesExpectedNotifySync)); \
    47     codeToTest;                                                         \
    48     Mock::VerifyAndClearExpectations(&(delegate))
     45#define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCommit, codeToTest) do { \
     46        EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedSetNeedsCommit));      \
     47        codeToTest;                                                                                   \
     48        Mock::VerifyAndClearExpectations(m_layerTreeHost.get());                                      \
     49    } while (0)
    4950
    5051namespace {
    5152
    52 class MockLayerDelegate : public CCLayerDelegate {
     53class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {
    5354public:
    54     MOCK_CONST_METHOD0(drawsContent, bool());
    55     MOCK_CONST_METHOD0(preserves3D, bool());
    56     MOCK_METHOD2(paintContents, void(GraphicsContext&, const IntRect&));
    57     MOCK_METHOD0(notifySyncRequired, void());
     55    virtual void animateAndLayout(double frameBeginTime) { }
     56    virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { }
     57    virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() { return 0; }
     58    virtual void didRecreateGraphicsContext(bool success) { }
     59    virtual void didCommitAndDrawFrame() { }
     60    virtual void didCompleteSwapBuffers() { }
     61
     62    // Used only in the single-threaded path.
     63    virtual void scheduleComposite() { }
     64};
     65
     66class MockCCLayerTreeHost : public CCLayerTreeHost {
     67public:
     68    MockCCLayerTreeHost()
     69        : CCLayerTreeHost(&m_fakeClient, CCSettings())
     70    {
     71        initialize();
     72    }
     73
     74    MOCK_METHOD0(setNeedsCommit, void());
     75
     76private:
     77    FakeCCLayerTreeHostClient m_fakeClient;
    5878};
    5979
     
    6383};
    6484
    65 class MockNonCompositedContentHost : public NonCompositedContentHost {
    66 public:
    67     static PassOwnPtr<MockNonCompositedContentHost> create()
    68     {
    69         return adoptPtr(new MockNonCompositedContentHost);
    70     }
    71 
    72     MOCK_METHOD1(notifySyncRequired, void(const GraphicsLayer*));
    73 
    74 private:
    75     MockNonCompositedContentHost()
    76         : NonCompositedContentHost(adoptPtr(new MockLayerPainterChromium()))
    77     {
    78         m_scrollLayer = GraphicsLayer::create(0);
    79         setScrollLayer(m_scrollLayer.get());
    80     }
    81     OwnPtr<GraphicsLayer> m_scrollLayer;
    82 };
    83 
    84 class LayerChromiumWithInstrumentedDestructor : public LayerChromium {
    85 public:
    86     explicit LayerChromiumWithInstrumentedDestructor(CCLayerDelegate* delegate)
    87         : LayerChromium(delegate)
    88     {
    89     }
    90 
    91     virtual ~LayerChromiumWithInstrumentedDestructor()
    92     {
    93         s_numInstancesDestroyed++;
    94     }
    95 
    96     static int getNumInstancesDestroyed() { return s_numInstancesDestroyed; }
    97     static void resetNumInstancesDestroyed() { s_numInstancesDestroyed = 0; }
    98 
    99 private:
    100     static int s_numInstancesDestroyed;
    101 };
    102 
    103 int LayerChromiumWithInstrumentedDestructor::s_numInstancesDestroyed = 0;
    10485
    10586class LayerChromiumTest : public testing::Test {
     
    10788    virtual void SetUp()
    10889    {
    109         // m_silentDelegate is initialized to be just a stub and will
    110         // not print any warnings. It is used when we are not worried
    111         // about testing how the delegate is called.
    112         EXPECT_CALL(m_silentDelegate, drawsContent()).Times(AnyNumber());
    113         EXPECT_CALL(m_silentDelegate, preserves3D()).Times(AnyNumber());
    114         EXPECT_CALL(m_silentDelegate, paintContents(_, _)).Times(AnyNumber());
    115         EXPECT_CALL(m_silentDelegate, notifySyncRequired()).Times(AnyNumber());
    116 
    117         // Static variables need to be reset for every new test case
    118         LayerChromiumWithInstrumentedDestructor::resetNumInstancesDestroyed();
     90        // Initialize without threading support.
     91        WebKit::WebCompositor::initialize(0);
     92        m_layerTreeHost = adoptRef(new MockCCLayerTreeHost);
     93    }
     94
     95    virtual void TearDown()
     96    {
     97        Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
     98        EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber());
     99        m_parent.clear();
     100        m_child1.clear();
     101        m_child2.clear();
     102        m_child3.clear();
     103        m_grandChild1.clear();
     104        m_grandChild2.clear();
     105        m_grandChild3.clear();
     106
     107        m_layerTreeHost->setRootLayer(0);
     108        m_layerTreeHost.clear();
     109        WebKit::WebCompositor::shutdown();
    119110    }
    120111
     
    144135    void createSimpleTestTree()
    145136    {
    146         m_parent = LayerChromium::create(&m_parentDelegate);
    147         m_child1 = LayerChromium::create(&m_silentDelegate);
    148         m_child2 = LayerChromium::create(&m_silentDelegate);
    149         m_child3 = LayerChromium::create(&m_silentDelegate);
    150         m_grandChild1 = LayerChromium::create(&m_silentDelegate);
    151         m_grandChild2 = LayerChromium::create(&m_silentDelegate);
    152         m_grandChild3 = LayerChromium::create(&m_silentDelegate);
    153 
    154         EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(3);
     137        m_parent = LayerChromium::create(0);
     138        m_child1 = LayerChromium::create(0);
     139        m_child2 = LayerChromium::create(0);
     140        m_child3 = LayerChromium::create(0);
     141        m_grandChild1 = LayerChromium::create(0);
     142        m_grandChild2 = LayerChromium::create(0);
     143        m_grandChild3 = LayerChromium::create(0);
     144
     145        EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber());
     146        m_layerTreeHost->setRootLayer(m_parent);
     147
    155148        m_parent->addChild(m_child1);
    156149        m_parent->addChild(m_child2);
    157150        m_parent->addChild(m_child3);
    158         Mock::VerifyAndClearExpectations(&m_parentDelegate);
    159151        m_child1->addChild(m_grandChild1);
    160152        m_child1->addChild(m_grandChild2);
    161153        m_child2->addChild(m_grandChild3);
    162154
     155        Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
     156
    163157        verifyTestTreeInitialState();
    164158    }
    165159
    166     MockLayerDelegate m_silentDelegate, m_parentDelegate;
     160    RefPtr<MockCCLayerTreeHost> m_layerTreeHost;
    167161    RefPtr<LayerChromium> m_parent, m_child1, m_child2, m_child3, m_grandChild1, m_grandChild2, m_grandChild3;
    168162};
     
    170164TEST_F(LayerChromiumTest, basicCreateAndDestroy)
    171165{
    172     MockLayerDelegate mockDelegate;
    173 
    174     // notifySyncRequired should not be called just because the layer is created or destroyed.
    175     EXPECT_CALL(mockDelegate, notifySyncRequired()).Times(0);
    176 
    177     RefPtr<LayerChromiumWithInstrumentedDestructor> testLayer = adoptRef(new LayerChromiumWithInstrumentedDestructor(&mockDelegate));
    178     ASSERT_TRUE(testLayer.get());
    179 
    180     // notifySyncRequired should also not be called on the destructor when the layer has no children.
    181     // so we need to make sure the layer is destroyed before the mock delegate.
    182     ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
    183     testLayer.release();
    184     ASSERT_EQ(1, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
     166    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
     167    ASSERT_TRUE(testLayer);
     168
     169    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0);
     170    testLayer->setLayerTreeHost(m_layerTreeHost.get());
    185171}
    186172
    187173TEST_F(LayerChromiumTest, addAndRemoveChild)
    188174{
    189     MockLayerDelegate parentDelegate;
    190     MockLayerDelegate childDelegate;
    191     RefPtr<LayerChromium> parent = LayerChromium::create(&parentDelegate);
    192     RefPtr<LayerChromium> child = LayerChromium::create(&childDelegate);
     175    RefPtr<LayerChromium> parent = LayerChromium::create(0);
     176    RefPtr<LayerChromium> child = LayerChromium::create(0);
    193177
    194178    // Upon creation, layers should not have children or parent.
     
    196180    EXPECT_FALSE(child->parent());
    197181
    198     // Parent calls notifySyncRequired exactly once when adding child.
    199     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->addChild(child));
     182    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, m_layerTreeHost->setRootLayer(parent));
     183
     184    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->addChild(child));
    200185
    201186    ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
     
    204189    EXPECT_EQ(parent.get(), child->rootLayer());
    205190
    206     // removeFromParent should cause the parent's notifySyncRequired to be called exactly once.
    207     // The childDelegate notifySyncRequired should remain un-used.
    208     EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0);
    209     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, child->removeFromParent());
    210 }
    211 
    212 TEST_F(LayerChromiumTest, verifyDestructorSemantics)
    213 {
    214     MockLayerDelegate parentDelegate;
    215     MockLayerDelegate childDelegate;
    216     RefPtr<LayerChromiumWithInstrumentedDestructor> parent = adoptRef(new LayerChromiumWithInstrumentedDestructor(&parentDelegate));
    217     RefPtr<LayerChromium> child = LayerChromium::create(&childDelegate);
    218 
    219     // Set up initial test conditions
    220     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->addChild(child));
    221     EXPECT_TRUE(child->parent());
    222 
    223     // When being destroyed, notifySyncRequired is called once for the parent, because it has one child,
    224     // but should not be called for the child which has no children.
    225     EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(1);
    226     EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0);
    227 
    228     ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
    229     parent.release();
    230     ASSERT_EQ(1, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
    231 
    232     // Child should have been un-parented correctly, but not yet destroyed since we have a reference to it.
    233     EXPECT_FALSE(child->parent());
    234 }
    235 
    236 TEST_F(LayerChromiumTest, verifyDestructorDoesNotLeak)
    237 {
    238     // In this test we explicitly instantiate a special subclass of
    239     // LayerChromium so we can track the number of destructors called.
    240 
    241     RefPtr<LayerChromiumWithInstrumentedDestructor> parent, child1, child2, child3, grandChild1, grandChild2, grandChild3;
    242     parent = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
    243     child1 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
    244     child2 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
    245     child3 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
    246     grandChild1 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
    247     grandChild2 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
    248     grandChild3 = adoptRef(new LayerChromiumWithInstrumentedDestructor(&m_silentDelegate));
    249 
    250     // set up a simple tree.
    251     parent->addChild(child1);
    252     parent->addChild(child2);
    253     parent->addChild(child3);
    254     child1->addChild(grandChild1);
    255     child1->addChild(grandChild2);
    256     child2->addChild(grandChild3);
    257 
    258     // Clear all the children RefPtrs here. But since they are attached to the tree, no destructors should be called yet.
    259     child1.clear();
    260     child2.clear();
    261     child3.clear();
    262     grandChild1.clear();
    263     grandChild2.clear();
    264     grandChild3.clear();
    265 
    266     // releasing the parent should cause all destructors to be invoked.
    267     ASSERT_EQ(0, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
    268     parent.release();
    269     ASSERT_EQ(7, LayerChromiumWithInstrumentedDestructor::getNumInstancesDestroyed());
     191    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), child->removeFromParent());
    270192}
    271193
    272194TEST_F(LayerChromiumTest, insertChild)
    273195{
    274     MockLayerDelegate parentDelegate;
    275     MockLayerDelegate childDelegate;
    276     RefPtr<LayerChromium>parent = LayerChromium::create(&parentDelegate);
    277     RefPtr<LayerChromium>child1 = LayerChromium::create(&childDelegate);
    278     RefPtr<LayerChromium>child2 = LayerChromium::create(&childDelegate);
    279     RefPtr<LayerChromium>child3 = LayerChromium::create(&childDelegate);
    280     RefPtr<LayerChromium>child4 = LayerChromium::create(&childDelegate);
     196    RefPtr<LayerChromium> parent = LayerChromium::create(0);
     197    RefPtr<LayerChromium> child1 = LayerChromium::create(0);
     198    RefPtr<LayerChromium> child2 = LayerChromium::create(0);
     199    RefPtr<LayerChromium> child3 = LayerChromium::create(0);
     200    RefPtr<LayerChromium> child4 = LayerChromium::create(0);
     201
     202    parent->setLayerTreeHost(m_layerTreeHost.get());
    281203
    282204    ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
    283205
    284     // The child delegate notifySyncRequired should not be called when inserting.
    285     EXPECT_CALL(childDelegate, notifySyncRequired()).Times(0);
    286 
    287206    // Case 1: inserting to empty list.
    288     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child3, 0));
     207    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child3, 0));
    289208    ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
    290209    EXPECT_EQ(child3, parent->children()[0]);
     
    292211
    293212    // Case 2: inserting to beginning of list
    294     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child1, 0));
     213    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child1, 0));
    295214    ASSERT_EQ(static_cast<size_t>(2), parent->children().size());
    296215    EXPECT_EQ(child1, parent->children()[0]);
     
    299218
    300219    // Case 3: inserting to middle of list
    301     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child2, 1));
     220    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child2, 1));
    302221    ASSERT_EQ(static_cast<size_t>(3), parent->children().size());
    303222    EXPECT_EQ(child1, parent->children()[0]);
     
    307226
    308227    // Case 4: inserting to end of list
    309     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child4, 3));
     228    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child4, 3));
    310229
    311230    ASSERT_EQ(static_cast<size_t>(4), parent->children().size());
     
    316235    EXPECT_EQ(parent.get(), child4->parent());
    317236
    318     // parent's destructor will invoke notifySyncRequired as it removes its children.
    319     EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(AtLeast(1));
     237    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
    320238}
    321239
    322240TEST_F(LayerChromiumTest, insertChildPastEndOfList)
    323241{
    324     RefPtr<LayerChromium> parent = LayerChromium::create(&m_silentDelegate);
    325     RefPtr<LayerChromium> child1 = LayerChromium::create(&m_silentDelegate);
    326     RefPtr<LayerChromium> child2 = LayerChromium::create(&m_silentDelegate);
     242    RefPtr<LayerChromium> parent = LayerChromium::create(0);
     243    RefPtr<LayerChromium> child1 = LayerChromium::create(0);
     244    RefPtr<LayerChromium> child2 = LayerChromium::create(0);
    327245
    328246    ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
     
    344262TEST_F(LayerChromiumTest, insertSameChildTwice)
    345263{
    346     MockLayerDelegate parentDelegate;
    347     RefPtr<LayerChromium> parent = LayerChromium::create(&parentDelegate);
    348     RefPtr<LayerChromium> child1 = LayerChromium::create(&m_silentDelegate);
    349     RefPtr<LayerChromium> child2 = LayerChromium::create(&m_silentDelegate);
     264    RefPtr<LayerChromium> parent = LayerChromium::create(0);
     265    RefPtr<LayerChromium> child1 = LayerChromium::create(0);
     266    RefPtr<LayerChromium> child2 = LayerChromium::create(0);
     267
     268    parent->setLayerTreeHost(m_layerTreeHost.get());
    350269
    351270    ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
    352271
    353     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child1, 0));
    354     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, 1, parent->insertChild(child2, 1));
     272    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child1, 0));
     273    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child2, 1));
    355274
    356275    ASSERT_EQ(static_cast<size_t>(2), parent->children().size());
     
    359278
    360279    // Inserting the same child again should cause the child to be removed and re-inserted at the new location.
    361     // So the parent's notifySyncRequired would be called one or more times.
    362     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(parentDelegate, AtLeast(1), parent->insertChild(child1, 1));
     280    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), parent->insertChild(child1, 1));
    363281
    364282    // child1 should now be at the end of the list.
     
    367285    EXPECT_EQ(child1, parent->children()[1]);
    368286
    369     // parent's destructor will invoke notifySyncRequired as it removes leftover children
    370     EXPECT_CALL(parentDelegate, notifySyncRequired()).Times(AtLeast(1));
    371 }
    372 
    373 TEST_F(LayerChromiumTest, insertChildThatAlreadyHadParent)
    374 {
    375     MockLayerDelegate oldParentDelegate;
    376     RefPtr<LayerChromium> oldParent = LayerChromium::create(&oldParentDelegate);
    377     RefPtr<LayerChromium> parent = LayerChromium::create(&m_silentDelegate);
    378     RefPtr<LayerChromium> child = LayerChromium::create(&m_silentDelegate);
    379 
    380     // set up and sanity-check initial test conditions
    381     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(oldParentDelegate, 1, oldParent->addChild(child));
    382     ASSERT_EQ(static_cast<size_t>(1), oldParent->children().size());
    383     ASSERT_EQ(static_cast<size_t>(0), parent->children().size());
    384     EXPECT_EQ(child, oldParent->children()[0]);
    385     EXPECT_EQ(oldParent.get(), child->parent());
    386 
    387     // Inserting to new parent causes old parent's notifySyncRequired to be called.
    388     // Note that it also causes parent's notifySyncRequired to be called, but that is tested elsewhere.
    389     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(oldParentDelegate, 1, parent->insertChild(child, 0));
    390 
    391     ASSERT_EQ(static_cast<size_t>(0), oldParent->children().size());
    392     ASSERT_EQ(static_cast<size_t>(1), parent->children().size());
    393     EXPECT_EQ(child, parent->children()[0]);
    394     EXPECT_EQ(parent.get(), child->parent());
     287    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
    395288}
    396289
     
    398291{
    399292    createSimpleTestTree();
    400     RefPtr<LayerChromium> child4 = LayerChromium::create(&m_silentDelegate);
     293    RefPtr<LayerChromium> child4 = LayerChromium::create(0);
    401294
    402295    EXPECT_FALSE(child4->parent());
    403296
    404     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));
     297    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));
    405298
    406299    ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size());
     
    411304
    412305    EXPECT_FALSE(m_child2->parent());
    413 
    414     // parent's destructor will invoke notifySyncRequired as it removes leftover children
    415     EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));
    416306}
    417307
     
    421311
    422312    // create another simple tree with testLayer and child4.
    423     RefPtr<LayerChromium> testLayer = LayerChromium::create(&m_silentDelegate);
    424     RefPtr<LayerChromium> child4 = LayerChromium::create(&m_silentDelegate);
     313    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
     314    RefPtr<LayerChromium> child4 = LayerChromium::create(0);
    425315    testLayer->addChild(child4);
    426316    ASSERT_EQ(static_cast<size_t>(1), testLayer->children().size());
     
    428318    EXPECT_EQ(testLayer.get(), child4->parent());
    429319
    430     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));
     320    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceChild(m_child2.get(), child4));
    431321
    432322    ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size());
     
    440330    ASSERT_EQ(static_cast<size_t>(0), testLayer->children().size());
    441331    EXPECT_FALSE(m_child2->parent());
    442 
    443     // parent's destructor will invoke notifySyncRequired as it removes leftover children
    444     EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));
    445332}
    446333
     
    449336    createSimpleTestTree();
    450337
    451     // notifySyncRequired should not be called because its the same child
    452     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, 0, m_parent->replaceChild(m_child2.get(), m_child2));
     338    // setNeedsCommit should not be called because its the same child
     339    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, m_parent->replaceChild(m_child2.get(), m_child2));
    453340
    454341    verifyTestTreeInitialState();
    455 
    456     // parent's destructor will invoke notifySyncRequired as it removes leftover children
    457     EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AtLeast(1));
    458342}
    459343
     
    462346    createSimpleTestTree();
    463347
    464     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, AtLeast(1), m_parent->removeAllChildren());
     348    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(3), m_parent->removeAllChildren());
    465349
    466350    ASSERT_EQ(static_cast<size_t>(0), m_parent->children().size());
     
    468352    EXPECT_FALSE(m_child2->parent());
    469353    EXPECT_FALSE(m_child3->parent());
    470 
    471     // notifySyncRequired should not be called if trying to removeAllChildren when there are no children.
    472     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(m_parentDelegate, 0, m_parent->removeAllChildren());
    473354}
    474355
    475356TEST_F(LayerChromiumTest, setChildren)
    476357{
    477     MockLayerDelegate newParentDelegate;
    478     RefPtr<LayerChromium> oldParent = LayerChromium::create(&m_silentDelegate);
    479     RefPtr<LayerChromium> newParent = LayerChromium::create(&newParentDelegate);
    480 
    481     RefPtr<LayerChromium> child1 = LayerChromium::create(&m_silentDelegate);
    482     RefPtr<LayerChromium> child2 = LayerChromium::create(&m_silentDelegate);
     358    RefPtr<LayerChromium> oldParent = LayerChromium::create(0);
     359    RefPtr<LayerChromium> newParent = LayerChromium::create(0);
     360
     361    RefPtr<LayerChromium> child1 = LayerChromium::create(0);
     362    RefPtr<LayerChromium> child2 = LayerChromium::create(0);
    483363
    484364    Vector<RefPtr<LayerChromium> > newChildren;
     
    492372    EXPECT_FALSE(child2->parent());
    493373
    494     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(newParentDelegate, AtLeast(1), newParent->setChildren(newChildren));
     374    newParent->setLayerTreeHost(m_layerTreeHost.get());
     375
     376    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), newParent->setChildren(newChildren));
    495377
    496378    ASSERT_EQ(static_cast<size_t>(2), newParent->children().size());
     
    498380    EXPECT_EQ(newParent.get(), child2->parent());
    499381
    500     // parent's destructor will invoke notifySyncRequired as it removes its children.
    501     EXPECT_CALL(newParentDelegate, notifySyncRequired()).Times(AtLeast(1));
     382    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
    502383}
    503384
     
    505386{
    506387    createSimpleTestTree();
    507     RefPtr<LayerChromium> child4 = LayerChromium::create(&m_silentDelegate);
    508 
    509     // In this test case, we don't care about how the parent's notifySyncRequired is called.
    510     EXPECT_CALL(m_parentDelegate, notifySyncRequired()).Times(AnyNumber());
     388
     389    // For this test we don't care about setNeedsCommit calls.
     390    EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1));
     391
     392    RefPtr<LayerChromium> child4 = LayerChromium::create(0);
    511393
    512394    EXPECT_EQ(m_parent.get(), m_parent->rootLayer());
     
    563445    // The semantics for setNeedsDisplay which are tested here:
    564446    //   1. sets needsDisplay flag appropriately.
    565     //   2. indirectly calls notifySyncRequired, exactly once for each call to setNeedsDisplay.
    566 
    567     MockLayerDelegate mockDelegate;
    568     RefPtr<LayerChromium> testLayer = LayerChromium::create(&mockDelegate);
     447    //   2. indirectly calls setNeedsCommit, exactly once for each call to setNeedsDisplay.
     448
     449    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
     450    testLayer->setLayerTreeHost(m_layerTreeHost.get());
     451
    569452    IntSize testBounds = IntSize(501, 508);
    570453
     
    577460    EXPECT_FALSE(testLayer->needsDisplay());
    578461
    579     // This is just initialization, but notifySyncRequired behavior is verified anyway to avoid warnings.
    580     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
    581     testLayer = LayerChromium::create(&mockDelegate);
     462    // This is just initialization, but setNeedsCommit behavior is verified anyway to avoid warnings.
     463    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
     464    testLayer = LayerChromium::create(0);
     465    testLayer->setLayerTreeHost(m_layerTreeHost.get());
    582466    EXPECT_FALSE(testLayer->needsDisplay());
    583467
     
    585469
    586470    // Case 1: needsDisplay flag should not change because of an empty dirty rect.
    587     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(emptyDirtyRect));
     471    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(emptyDirtyRect));
    588472    EXPECT_FALSE(testLayer->needsDisplay());
    589473
    590474    // Case 2: basic.
    591     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(dirty1));
     475    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(dirty1));
    592476    EXPECT_TRUE(testLayer->needsDisplay());
    593477
    594478    // Case 3: a second dirty rect.
    595     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(dirty2));
     479    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(dirty2));
    596480    EXPECT_TRUE(testLayer->needsDisplay());
    597481
    598482    // Case 4: LayerChromium should accept dirty rects that go beyond its bounds.
    599     testLayer = LayerChromium::create(&mockDelegate);
    600     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
    601     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplayRect(outOfBoundsDirtyRect));
     483    testLayer = LayerChromium::create(0);
     484    testLayer->setLayerTreeHost(m_layerTreeHost.get());
     485    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
     486    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRect(outOfBoundsDirtyRect));
    602487    EXPECT_TRUE(testLayer->needsDisplay());
    603488
    604489    // Case 5: setNeedsDisplay() without the dirty rect arg.
    605     testLayer = LayerChromium::create(&mockDelegate);
    606     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
    607     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay());
     490    testLayer = LayerChromium::create(0);
     491    testLayer->setLayerTreeHost(m_layerTreeHost.get());
     492    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
     493    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplay());
    608494    EXPECT_TRUE(testLayer->needsDisplay());
    609 
    610     // Case 6: setNeedsDisplay() without the dirty rect arg should not cause
    611     // needsDisplay flag to change for LayerChromium with empty bounds.
    612     testLayer = LayerChromium::create(&mockDelegate);
    613     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setNeedsDisplay());
    614     EXPECT_FALSE(testLayer->needsDisplay());
    615495}
    616496
    617497TEST_F(LayerChromiumTest, checkSetNeedsDisplayWithNullDelegate)
    618498{
    619     // Without a delegate, the layer should still mark itself dirty as appropriate,
    620     // and it should not crash trying to use a non-existing delegate.
    621499    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
    622500    IntSize testBounds = IntSize(501, 508);
     
    636514TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior)
    637515{
    638     MockLayerDelegate initialDelegate;
    639     MockLayerDelegate mockDelegate;
    640     RefPtr<LayerChromium> testLayer = LayerChromium::create(&initialDelegate);
    641     RefPtr<LayerChromium> dummyLayer = LayerChromium::create(&m_silentDelegate); // just a dummy layer for this test case.
     516    RefPtr<LayerChromium> testLayer = LayerChromium::create(0);
     517    testLayer->setLayerTreeHost(m_layerTreeHost.get());
     518
     519    RefPtr<LayerChromium> dummyLayer = LayerChromium::create(0); // just a dummy layer for this test case.
    642520
    643521    // sanity check of initial test condition
     
    645523
    646524    // Test properties that should not call needsDisplay and needsCommit when changed.
    647     // notifySyncRequired should not be called, and the needsDisplay flag should remain false.
    648     EXPECT_CALL(initialDelegate, notifySyncRequired()).Times(0); // old delegate should not be used when setDelegate gives a new delegate.
    649     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDelegate(&mockDelegate));
    650     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setName("Test Layer"));
    651     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setVisibleLayerRect(IntRect(0, 0, 40, 50)));
    652     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setUsesLayerClipping(true));
    653     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setIsNonCompositedContent(true));
    654     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawOpacity(0.5f));
    655     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setClipRect(IntRect(3, 3, 8, 8)));
    656     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setTargetRenderSurface(0));
    657     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawTransform(TransformationMatrix()));
    658     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setScreenSpaceTransform(TransformationMatrix()));
    659     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7)));
     525    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setName("Test Layer"));
     526    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleLayerRect(IntRect(0, 0, 40, 50)));
     527    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUsesLayerClipping(true));
     528    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setIsNonCompositedContent(true));
     529    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5f));
     530    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setClipRect(IntRect(3, 3, 8, 8)));
     531    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setTargetRenderSurface(0));
     532    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(TransformationMatrix()));
     533    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(TransformationMatrix()));
     534    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7)));
    660535    EXPECT_FALSE(testLayer->needsDisplay());
    661536
    662537    // Next, test properties that should call setNeedsCommit (but not setNeedsDisplay)
    663     // These properties should indirectly call notifySyncRequired, but the needsDisplay flag should not change.
    664     // All properties need to be set to new values in order for setNeedsCommit
    665     // to be called.
    666     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f)));
    667     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setAnchorPointZ(0.7f));
    668     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f)));
    669     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setMasksToBounds(true));
    670     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setMaskLayer(dummyLayer.get()));
    671     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setOpacity(0.5f));
    672     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setOpaque(true));
    673     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setPosition(FloatPoint(4.0f, 9.0f)));
    674     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setReplicaLayer(dummyLayer.get()));
    675     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
    676     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setScrollable(true));
    677     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setScrollPosition(IntPoint(10, 10)));
    678     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
    679     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setDoubleSided(false));
     538    // All properties need to be set to new values in order for setNeedsCommit to be called.
     539    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPoint(FloatPoint(1.23f, 4.56f)));
     540    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setAnchorPointZ(0.7f));
     541    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBackgroundColor(Color(0.4f, 0.4f, 0.4f)));
     542    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMasksToBounds(true));
     543    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setMaskLayer(dummyLayer.get()));
     544    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpacity(0.5f));
     545    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setOpaque(true));
     546    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setPosition(FloatPoint(4.0f, 9.0f)));
     547    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get()));
     548    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
     549    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true));
     550    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10)));
     551    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0)));
     552    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false));
    680553
    681554    // The above tests should not have caused a change to the needsDisplay flag.
    682555    EXPECT_FALSE(testLayer->needsDisplay());
    683556
    684     // Test properties that should call setNeedsDisplay
    685     // These properties will call notifySyncRequired and change the needsDisplay flag.
    686     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(IntSize(5, 10)));
     557    // Test properties that should call setNeedsDisplay and setNeedsCommit
     558    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(IntSize(5, 10)));
    687559    EXPECT_TRUE(testLayer->needsDisplay());
    688 
    689     // FIXME: need to add a test for setLayerTreeHost with a non-null stubbed CCLayerTreeHost.
    690 }
    691 
    692 TEST_F(LayerChromiumTest, checkNonCompositedContentPropertyChangeCausesCommit)
    693 {
    694     OwnPtr<MockNonCompositedContentHost> nonCompositedContentHost(MockNonCompositedContentHost::create());
    695 
    696     GraphicsLayer* rootLayer = nonCompositedContentHost->topLevelRootLayer();
    697 
    698     EXPECT_CALL(*nonCompositedContentHost, notifySyncRequired(_)).Times(1);
    699     rootLayer->platformLayer()->setScrollPosition(IntPoint(1, 1));
    700     Mock::VerifyAndClearExpectations(nonCompositedContentHost.get());
    701 
    702     EXPECT_CALL(*nonCompositedContentHost, notifySyncRequired(_)).Times(AtLeast(1));
    703     nonCompositedContentHost->setViewport(IntSize(30, 30), IntSize(20, 20), IntPoint(10, 10), 1);
    704560}
    705561
     
    724580TEST_F(LayerChromiumTest, checkContentsScaleChangeTriggersNeedsDisplay)
    725581{
    726     MockLayerDelegate mockDelegate;
    727     RefPtr<LayerChromiumWithContentScaling> testLayer = adoptRef(new LayerChromiumWithContentScaling(&mockDelegate));
     582    RefPtr<LayerChromiumWithContentScaling> testLayer = adoptRef(new LayerChromiumWithContentScaling(0));
     583    testLayer->setLayerTreeHost(m_layerTreeHost.get());
    728584
    729585    IntSize testBounds = IntSize(320, 240);
    730     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setBounds(testBounds));
     586    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBounds));
    731587
    732588    testLayer->resetNeedsDisplay();
    733589    EXPECT_FALSE(testLayer->needsDisplay());
    734590
    735     EXECUTE_AND_VERIFY_NOTIFY_SYNC_BEHAVIOR(mockDelegate, 1, testLayer->setContentsScale(testLayer->contentsScale() + 1.f));
     591    EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsScale(testLayer->contentsScale() + 1.f));
    736592    EXPECT_TRUE(testLayer->needsDisplay());
    737593}
    738 
    739 class FakeCCLayerTreeHostClient : public CCLayerTreeHostClient {
    740 public:
    741     virtual void animateAndLayout(double frameBeginTime) { }
    742     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) { }
    743     virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() { return 0; }
    744     virtual void didRecreateGraphicsContext(bool success) { }
    745     virtual void didCommitAndDrawFrame() { }
    746     virtual void didCompleteSwapBuffers() { }
    747     virtual void scheduleComposite() { }
    748 };
    749594
    750595class FakeCCLayerTreeHost : public CCLayerTreeHost {
     
    784629TEST(LayerChromiumLayerTreeHostTest, enteringTree)
    785630{
    786     WebCompositor::initialize(0);
     631    WebKit::WebCompositor::initialize(0);
    787632    RefPtr<LayerChromium> parent = LayerChromium::create(0);
    788633    RefPtr<LayerChromium> child = LayerChromium::create(0);
     
    811656
    812657    layerTreeHost.clear();
    813     WebCompositor::shutdown();
     658    WebKit::WebCompositor::shutdown();
    814659}
    815660
    816661TEST(LayerChromiumLayerTreeHostTest, addingLayerSubtree)
    817662{
    818     WebCompositor::initialize(0);
     663    WebKit::WebCompositor::initialize(0);
    819664    RefPtr<LayerChromium> parent = LayerChromium::create(0);
    820665    RefPtr<FakeCCLayerTreeHost> layerTreeHost = FakeCCLayerTreeHost::create();
     
    842687    layerTreeHost->setRootLayer(0);
    843688    layerTreeHost.clear();
    844     WebCompositor::shutdown();
     689    WebKit::WebCompositor::shutdown();
    845690}
    846691
    847692TEST(LayerChromiumLayerTreeHostTest, changeHost)
    848693{
    849     WebCompositor::initialize(0);
     694    WebKit::WebCompositor::initialize(0);
    850695    RefPtr<LayerChromium> parent = LayerChromium::create(0);
    851696    RefPtr<LayerChromium> child = LayerChromium::create(0);
     
    875720    firstLayerTreeHost.clear();
    876721    secondLayerTreeHost.clear();
    877     WebCompositor::shutdown();
     722    WebKit::WebCompositor::shutdown();
    878723}
    879724
    880725TEST(LayerChromiumLayerTreeHostTest, changeHostInSubtree)
    881726{
    882     WebCompositor::initialize(0);
     727    WebKit::WebCompositor::initialize(0);
    883728    RefPtr<LayerChromium> firstParent = LayerChromium::create(0);
    884729    RefPtr<LayerChromium> firstChild = LayerChromium::create(0);
     
    912757    firstLayerTreeHost.clear();
    913758    secondLayerTreeHost.clear();
    914     WebCompositor::shutdown();
     759    WebKit::WebCompositor::shutdown();
    915760}
    916761
    917762TEST(LayerChromiumLayerTreeHostTest, replaceMaskAndReplicaLayer)
    918763{
    919     WebCompositor::initialize(0);
     764    WebKit::WebCompositor::initialize(0);
    920765    RefPtr<LayerChromium> parent = LayerChromium::create(0);
    921766    RefPtr<LayerChromium> mask = LayerChromium::create(0);
     
    949794    layerTreeHost->setRootLayer(0);
    950795    layerTreeHost.clear();
    951     WebCompositor::shutdown();
     796    WebKit::WebCompositor::shutdown();
    952797}
    953798
  • trunk/Source/WebKit/chromium/tests/WebGLLayerChromiumTest.cpp

    r103150 r103293  
    2727#include "WebGLLayerChromium.h"
    2828
     29#include "CompositorFakeGraphicsContext3D.h"
    2930#include "DrawingBuffer.h"
    30 #include "GraphicsContext3DPrivate.h"
    31 #include "MockWebGraphicsContext3D.h"
    3231#include <gmock/gmock.h>
    3332#include <gtest/gtest.h>
     
    3736
    3837namespace {
    39 
    40 // Test stub for WebGraphicsContext3D. Returns canned values needed for compositor initialization.
    41 class CompositorMockWebGraphicsContext3D : public MockWebGraphicsContext3D {
    42 public:
    43     static PassOwnPtr<CompositorMockWebGraphicsContext3D> create(GraphicsContext3D::Attributes attrs) { return adoptPtr(new CompositorMockWebGraphicsContext3D(attrs)); }
    44     virtual bool makeContextCurrent() { return true; }
    45     virtual WebGLId createProgram() { return 1; }
    46     virtual WebGLId createShader(WGC3Denum) { return 1; }
    47     virtual void getShaderiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
    48     virtual void getProgramiv(WebGLId, WGC3Denum, WGC3Dint* value) { *value = 1; }
    49     virtual WebGraphicsContext3D::Attributes getContextAttributes() { return m_attrs; }
    50 
    51 private:
    52     CompositorMockWebGraphicsContext3D(GraphicsContext3D::Attributes attrs) { m_attrs.alpha = attrs.alpha; }
    53 
    54     WebGraphicsContext3D::Attributes m_attrs;
    55 };
    56 
    57 static PassRefPtr<GraphicsContext3D> createGraphicsContext(GraphicsContext3D::Attributes attrs)
    58 {
    59     OwnPtr<WebGraphicsContext3D> webContext = CompositorMockWebGraphicsContext3D::create(attrs);
    60     return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(
    61         webContext.release(), attrs, 0,
    62         GraphicsContext3D::RenderDirectlyToHostWindow,
    63         GraphicsContext3DPrivate::ForUseOnAnotherThread);
    64 }
    6538
    6639TEST(WebGLLayerChromiumTest, opaqueFormats)
     
    7346    opaqueAttrs.alpha = false;
    7447
    75     RefPtr<GraphicsContext3D> alphaContext = createGraphicsContext(alphaAttrs);
     48    RefPtr<GraphicsContext3D> alphaContext = createCompositorMockGraphicsContext3D(alphaAttrs);
    7649    EXPECT_TRUE(alphaContext);
    77     RefPtr<GraphicsContext3D> opaqueContext = createGraphicsContext(opaqueAttrs);
     50    RefPtr<GraphicsContext3D> opaqueContext = createCompositorMockGraphicsContext3D(opaqueAttrs);
    7851    EXPECT_TRUE(opaqueContext);
    7952
  • trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp

    r103150 r103293  
    2626#include "platform/WebLayer.h"
    2727
    28 #include "platform/WebFloatPoint.h"
    29 #include "platform/WebFloatRect.h"
    30 #include "platform/WebRect.h"
    31 #include "platform/WebSize.h"
     28#include "CompositorFakeWebGraphicsContext3D.h"
     29#include "WebCompositor.h"
    3230#include "platform/WebContentLayer.h"
    3331#include "platform/WebContentLayerClient.h"
    3432#include "platform/WebExternalTextureLayer.h"
    35 #include "platform/WebLayerClient.h"
     33#include "platform/WebFloatPoint.h"
     34#include "platform/WebFloatRect.h"
     35#include "platform/WebLayerTreeView.h"
     36#include "platform/WebLayerTreeViewClient.h"
     37#include "platform/WebRect.h"
     38#include "platform/WebSize.h"
    3639
    3740#include <gmock/gmock.h>
     
    4245namespace {
    4346
    44 class MockWebLayerClient : public WebLayerClient {
     47class MockWebLayerTreeViewClient : public WebLayerTreeViewClient {
    4548public:
    46     MOCK_METHOD0(notifyNeedsComposite, void());
     49    MOCK_METHOD0(scheduleComposite, void());
     50
     51    virtual void animateAndLayout(double frameBeginTime) { }
     52    virtual void applyScrollAndScale(const WebSize& scrollDelta, float scaleFactor) { }
     53    virtual WebGraphicsContext3D* createContext3D() { return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes()).leakPtr(); }
     54    virtual void didRebindGraphicsContext(bool success) { }
    4755};
    4856
     
    5462class WebLayerTest : public Test {
    5563public:
    56     WebLayerTest() { }
     64    virtual void SetUp()
     65    {
     66        // Initialize without threading support.
     67        WebKit::WebCompositor::initialize(0);
     68        m_rootLayer = WebLayer::create();
     69        EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
     70        m_view = WebLayerTreeView::create(&m_client, m_rootLayer, WebLayerTreeView::Settings());
     71        Mock::VerifyAndClearExpectations(&m_client);
     72    }
     73
     74    virtual void TearDown()
     75    {
     76        // We may get any number of scheduleComposite calls during shutdown.
     77        EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
     78        m_view.setRootLayer(0);
     79        m_rootLayer.reset();
     80        m_view.reset();
     81        WebKit::WebCompositor::shutdown();
     82    }
     83
     84protected:
     85    MockWebLayerTreeViewClient m_client;
     86    WebLayer m_rootLayer;
     87    WebLayerTreeView m_view;
    5788};
    5889
     
    6293{
    6394    // Base layer.
    64     MockWebLayerClient client;
    65     EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
    66     WebLayer layer = WebLayer::create(&client);
    67     Mock::VerifyAndClearExpectations(&client);
     95    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
     96    WebLayer layer = WebLayer::create();
     97    m_rootLayer.addChild(layer);
     98    Mock::VerifyAndClearExpectations(&m_client);
    6899
    69100    WebFloatPoint point(3, 4);
    70     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     101    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    71102    layer.setAnchorPoint(point);
    72     Mock::VerifyAndClearExpectations(&client);
     103    Mock::VerifyAndClearExpectations(&m_client);
    73104    EXPECT_EQ(point, layer.anchorPoint());
    74105
    75     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     106    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    76107    float anchorZ = 5;
    77108    layer.setAnchorPointZ(anchorZ);
    78     Mock::VerifyAndClearExpectations(&client);
     109    Mock::VerifyAndClearExpectations(&m_client);
    79110    EXPECT_EQ(anchorZ, layer.anchorPointZ());
    80111
    81112    WebSize size(7, 8);
    82     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     113    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    83114    layer.setBounds(size);
    84     Mock::VerifyAndClearExpectations(&client);
     115    Mock::VerifyAndClearExpectations(&m_client);
    85116    EXPECT_EQ(size, layer.bounds());
    86117
    87     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     118    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    88119    layer.setMasksToBounds(true);
    89     Mock::VerifyAndClearExpectations(&client);
     120    Mock::VerifyAndClearExpectations(&m_client);
    90121    EXPECT_TRUE(layer.masksToBounds());
    91122
    92     MockWebLayerClient otherClient;
    93     EXPECT_CALL(otherClient, notifyNeedsComposite()).Times(AnyNumber());
    94     WebLayer otherLayer = WebLayer::create(&otherClient);
    95     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     123    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
     124    WebLayer otherLayer = WebLayer::create();
     125    m_rootLayer.addChild(otherLayer);
     126    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    96127    layer.setMaskLayer(otherLayer);
    97     Mock::VerifyAndClearExpectations(&client);
     128    Mock::VerifyAndClearExpectations(&m_client);
    98129    EXPECT_EQ(otherLayer, layer.maskLayer());
    99130
    100     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     131    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    101132    float opacity = 0.123;
    102133    layer.setOpacity(opacity);
    103     Mock::VerifyAndClearExpectations(&client);
     134    Mock::VerifyAndClearExpectations(&m_client);
    104135    EXPECT_EQ(opacity, layer.opacity());
    105136
    106     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     137    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    107138    layer.setOpaque(true);
    108     Mock::VerifyAndClearExpectations(&client);
     139    Mock::VerifyAndClearExpectations(&m_client);
    109140    EXPECT_TRUE(layer.opaque());
    110141
    111     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     142    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    112143    layer.setPosition(point);
    113     Mock::VerifyAndClearExpectations(&client);
     144    Mock::VerifyAndClearExpectations(&m_client);
    114145    EXPECT_EQ(point, layer.position());
    115146
    116147    // Texture layer.
    117     EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
    118     WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(&client);
    119     Mock::VerifyAndClearExpectations(&client);
    120 
    121     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     148    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
     149    WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create();
     150    m_rootLayer.addChild(textureLayer);
     151    Mock::VerifyAndClearExpectations(&m_client);
     152
     153    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    122154    textureLayer.setTextureId(3);
    123     Mock::VerifyAndClearExpectations(&client);
     155    Mock::VerifyAndClearExpectations(&m_client);
    124156    EXPECT_EQ(3u, textureLayer.textureId());
    125157
    126     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     158    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    127159    textureLayer.setFlipped(true);
    128     Mock::VerifyAndClearExpectations(&client);
     160    Mock::VerifyAndClearExpectations(&m_client);
    129161    EXPECT_TRUE(textureLayer.flipped());
    130162
    131     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     163    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    132164    WebFloatRect uvRect(0.1, 0.1, 0.9, 0.9);
    133165    textureLayer.setUVRect(uvRect);
    134     Mock::VerifyAndClearExpectations(&client);
     166    Mock::VerifyAndClearExpectations(&m_client);
    135167    EXPECT_TRUE(textureLayer.flipped());
    136168
     
    139171    MockWebContentLayerClient contentClient;
    140172    EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber());
    141     EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
    142     WebContentLayer contentLayer = WebContentLayer::create(&client, &contentClient);
    143     Mock::VerifyAndClearExpectations(&client);
    144 
    145     EXPECT_CALL(client, notifyNeedsComposite()).Times(AtLeast(1));
     173    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
     174    WebContentLayer contentLayer = WebContentLayer::create(&contentClient);
     175    m_rootLayer.addChild(contentLayer);
     176    Mock::VerifyAndClearExpectations(&m_client);
     177
     178    EXPECT_CALL(m_client, scheduleComposite()).Times(AtLeast(1));
    146179    contentLayer.setDrawsContent(false);
    147     Mock::VerifyAndClearExpectations(&client);
     180    Mock::VerifyAndClearExpectations(&m_client);
    148181    EXPECT_FALSE(contentLayer.drawsContent());
    149182}
     
    151184TEST_F(WebLayerTest, Hierarchy)
    152185{
    153     MockWebLayerClient client;
    154     EXPECT_CALL(client, notifyNeedsComposite()).Times(AnyNumber());
    155     WebLayer layer1 = WebLayer::create(&client);
    156     WebLayer layer2 = WebLayer::create(&client);
     186    EXPECT_CALL(m_client, scheduleComposite()).Times(AnyNumber());
     187    WebLayer layer1 = WebLayer::create();
     188    WebLayer layer2 = WebLayer::create();
    157189
    158190    EXPECT_TRUE(layer1.parent().isNull());
     
    173205    MockWebContentLayerClient contentClient;
    174206    EXPECT_CALL(contentClient, paintContents(_, _)).Times(AnyNumber());
    175     WebContentLayer contentLayer = WebContentLayer::create(&client, &contentClient);
    176     WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create(&client);
     207    WebContentLayer contentLayer = WebContentLayer::create(&contentClient);
     208    WebExternalTextureLayer textureLayer = WebExternalTextureLayer::create();
    177209
    178210    textureLayer.addChild(contentLayer);
Note: See TracChangeset for help on using the changeset viewer.