diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-30 23:25:27 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-30 23:25:27 +0000 |
commit | c0dd24c4c6af6280e5c286ccb872f914560598b7 (patch) | |
tree | c5fc9825367e88ae8959cb447b3684f4ab322444 /cc | |
parent | ce71608c071b244cb668e4ee858108d90a00be5e (diff) | |
download | chromium_src-c0dd24c4c6af6280e5c286ccb872f914560598b7.zip chromium_src-c0dd24c4c6af6280e5c286ccb872f914560598b7.tar.gz chromium_src-c0dd24c4c6af6280e5c286ccb872f914560598b7.tar.bz2 |
Enable webkit_compositor_unittests
These are unit tests of the webkit compositor bindings that bind the
WebKit Platform Web*Layer* family of APIs to cc. They currently depend
on some test utilities in cc.
Also updates snapshot to WebKit r127194
BUG=
Review URL: https://chromiumcodereview.appspot.com/10909020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/CCLayerTreeHostImpl.cpp | 2 | ||||
-rw-r--r-- | cc/CCLayerTreeHostImplTest.cpp | 18 | ||||
-rw-r--r-- | cc/CCLayerTreeHostTest.cpp | 62 | ||||
-rw-r--r-- | cc/CCScheduler.cpp | 20 | ||||
-rw-r--r-- | cc/CCScheduler.h | 6 | ||||
-rw-r--r-- | cc/CCSchedulerTest.cpp | 17 | ||||
-rw-r--r-- | cc/CCTextureUpdateController.cpp | 40 | ||||
-rw-r--r-- | cc/CCTextureUpdateController.h | 22 | ||||
-rw-r--r-- | cc/CCTextureUpdateControllerTest.cpp | 71 | ||||
-rw-r--r-- | cc/CCThreadProxy.cpp | 54 | ||||
-rw-r--r-- | cc/CCThreadProxy.h | 13 | ||||
-rw-r--r-- | cc/cc_tests.gyp | 43 | ||||
-rw-r--r-- | cc/copyfiles.py | 11 | ||||
-rw-r--r-- | cc/test/CCAnimationTestCommon.cpp | 45 | ||||
-rw-r--r-- | cc/test/CCAnimationTestCommon.h | 18 | ||||
-rw-r--r-- | cc/test/CCTiledLayerTestCommon.cpp | 34 | ||||
-rw-r--r-- | cc/test/CCTiledLayerTestCommon.h | 20 | ||||
-rw-r--r-- | cc/test/FakeWebCompositorOutputSurface.h | 2 |
18 files changed, 322 insertions, 176 deletions
diff --git a/cc/CCLayerTreeHostImpl.cpp b/cc/CCLayerTreeHostImpl.cpp index 9b11289..a06bff9 100644 --- a/cc/CCLayerTreeHostImpl.cpp +++ b/cc/CCLayerTreeHostImpl.cpp @@ -749,6 +749,8 @@ void CCLayerTreeHostImpl::setDeviceScaleFactor(float deviceScaleFactor) if (deviceScaleFactor == m_deviceScaleFactor) return; m_deviceScaleFactor = deviceScaleFactor; + + updateMaxScrollPosition(); } diff --git a/cc/CCLayerTreeHostImplTest.cpp b/cc/CCLayerTreeHostImplTest.cpp index a8c346a..bad5782 100644 --- a/cc/CCLayerTreeHostImplTest.cpp +++ b/cc/CCLayerTreeHostImplTest.cpp @@ -380,6 +380,24 @@ TEST_F(CCLayerTreeHostImplTest, nonFastScrollableRegionWithOffset) EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(10, 10), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollOnMainThread); } +TEST_F(CCLayerTreeHostImplTest, maxScrollPositionChangedByDeviceScaleFactor) +{ + setupScrollAndContentsLayers(IntSize(100, 100)); + + float deviceScaleFactor = 2; + IntSize layoutViewport(25, 25); + IntSize deviceViewport(layoutViewport); + deviceViewport.scale(deviceScaleFactor); + m_hostImpl->setViewportSize(layoutViewport, deviceViewport); + m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); + EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25)); + + deviceScaleFactor = 1; + m_hostImpl->setViewportSize(layoutViewport, layoutViewport); + m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); + EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75)); +} + TEST_F(CCLayerTreeHostImplTest, pinchGesture) { setupScrollAndContentsLayers(IntSize(100, 100)); diff --git a/cc/CCLayerTreeHostTest.cpp b/cc/CCLayerTreeHostTest.cpp index d03388f..9828f85 100644 --- a/cc/CCLayerTreeHostTest.cpp +++ b/cc/CCLayerTreeHostTest.cpp @@ -497,6 +497,63 @@ TEST_F(CCLayerTreeHostTestAbortFrameWhenInvisible, runMultiThread) runTest(true); } +// Makes sure that setNedsAnimate does not cause the commitRequested() state to be set. +class CCLayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested : public CCLayerTreeHostTest { +public: + CCLayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested() + : m_numCommits(0) + { + } + + virtual void beginTest() OVERRIDE + { + // The tests start up with a commit pending because we give them a root layer. + // We need to wait for the commit to happen before doing anything. + EXPECT_TRUE(m_layerTreeHost->commitRequested()); + } + + virtual void animate(double monotonicTime) OVERRIDE + { + // We skip the first commit becasue its the commit that populates the + // impl thread with a tree. + if (!m_numCommits) + return; + + m_layerTreeHost->setNeedsAnimate(); + // Right now, commitRequested is going to be true, because during + // beginFrame, we force commitRequested to true to prevent requests from + // hitting the impl thread. But, when the next didCommit happens, we should + // verify that commitRequested has gone back to false. + } + virtual void didCommit() OVERRIDE + { + if (!m_numCommits) { + EXPECT_FALSE(m_layerTreeHost->commitRequested()); + m_layerTreeHost->setNeedsAnimate(); + EXPECT_FALSE(m_layerTreeHost->commitRequested()); + m_numCommits++; + } + + // Verifies that the setNeedsAnimate we made in ::animate did not + // trigger commitRequested. + EXPECT_FALSE(m_layerTreeHost->commitRequested()); + endTest(); + } + + virtual void afterTest() OVERRIDE + { + } + +private: + int m_numCommits; +}; + +TEST_F(CCLayerTreeHostTestSetNeedsAnimateShouldNotSetCommitRequested, runMultiThread) +{ + runTest(true); +} + + // Trigger a frame with setNeedsCommit. Then, inside the resulting animate // callback, requet another frame using setNeedsAnimate. End the test when @@ -891,7 +948,7 @@ private: int m_scrolls; }; -TEST_F(CCLayerTreeHostTestScrollSimple, DISABLED_runMultiThread) +TEST_F(CCLayerTreeHostTestScrollSimple, runMultiThread) { runTest(true); } @@ -2218,8 +2275,7 @@ private: RefPtr<LayerChromium> m_rootScrollLayer; }; -// https://bugs.webkit.org/show_bug.cgi?id=95358 -TEST_F(CCLayerTreeHostTestScrollChildLayer, DISABLED_runMultiThread) +TEST_F(CCLayerTreeHostTestScrollChildLayer, runMultiThread) { runTest(true); } diff --git a/cc/CCScheduler.cpp b/cc/CCScheduler.cpp index 5bfad37..1840b4a 100644 --- a/cc/CCScheduler.cpp +++ b/cc/CCScheduler.cpp @@ -13,7 +13,6 @@ namespace WebCore { CCScheduler::CCScheduler(CCSchedulerClient* client, PassOwnPtr<CCFrameRateController> frameRateController) : m_client(client) , m_frameRateController(frameRateController) - , m_hasMoreResourceUpdates(false) , m_updateMoreResourcesPending(false) { ASSERT(m_client); @@ -68,10 +67,9 @@ void CCScheduler::setMainThreadNeedsLayerTextures() processScheduledActions(); } -void CCScheduler::beginFrameComplete(bool hasResourceUpdates) +void CCScheduler::beginFrameComplete() { TRACE_EVENT0("cc", "CCScheduler::beginFrameComplete"); - m_hasMoreResourceUpdates = hasResourceUpdates; m_stateMachine.beginFrameComplete(); processScheduledActions(); } @@ -118,8 +116,7 @@ void CCScheduler::vsyncTick() { if (m_updateMoreResourcesPending) { m_updateMoreResourcesPending = false; - ASSERT(m_hasMoreResourceUpdates); - m_stateMachine.beginUpdateMoreResourcesComplete(true); + m_stateMachine.beginUpdateMoreResourcesComplete(m_client->hasMoreResourceUpdates()); } TRACE_EVENT0("cc", "CCScheduler::vsyncTick"); @@ -128,17 +125,6 @@ void CCScheduler::vsyncTick() m_stateMachine.didLeaveVSync(); } -void CCScheduler::updateResourcesComplete() -{ - TRACE_EVENT0("cc", "CCScheduler::updateResourcesComplete"); - if (m_updateMoreResourcesPending) { - m_updateMoreResourcesPending = false; - m_stateMachine.beginUpdateMoreResourcesComplete(false); - } - m_hasMoreResourceUpdates = false; - processScheduledActions(); -} - CCSchedulerStateMachine::Action CCScheduler::nextAction() { m_stateMachine.setCanDraw(m_client->canDraw()); @@ -168,7 +154,7 @@ void CCScheduler::processScheduledActions() m_client->scheduledActionBeginFrame(); break; case CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES: - if (m_hasMoreResourceUpdates) { + if (m_client->hasMoreResourceUpdates()) { m_client->scheduledActionUpdateMoreResources(m_frameRateController->nextTickTimeIfActivated()); m_updateMoreResourcesPending = true; } else diff --git a/cc/CCScheduler.h b/cc/CCScheduler.h index 3e2614b..10fce73 100644 --- a/cc/CCScheduler.h +++ b/cc/CCScheduler.h @@ -33,6 +33,7 @@ struct CCScheduledActionDrawAndSwapResult { class CCSchedulerClient { public: virtual bool canDraw() = 0; + virtual bool hasMoreResourceUpdates() const = 0; virtual void scheduledActionBeginFrame() = 0; virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossible() = 0; @@ -72,7 +73,7 @@ public: // Like setNeedsRedraw(), but ensures the draw will definitely happen even if we are not visible. void setNeedsForcedRedraw(); - void beginFrameComplete(bool hasResourceUpdates); + void beginFrameComplete(); void beginFrameAborted(); void setMaxFramesPending(int); @@ -89,8 +90,6 @@ public: // CCFrameRateControllerClient implementation virtual void vsyncTick() OVERRIDE; - void updateResourcesComplete(); - private: CCScheduler(CCSchedulerClient*, PassOwnPtr<CCFrameRateController>); @@ -100,7 +99,6 @@ private: CCSchedulerClient* m_client; OwnPtr<CCFrameRateController> m_frameRateController; CCSchedulerStateMachine m_stateMachine; - bool m_hasMoreResourceUpdates; bool m_updateMoreResourcesPending; }; diff --git a/cc/CCSchedulerTest.cpp b/cc/CCSchedulerTest.cpp index 12702bd..ec68c71 100644 --- a/cc/CCSchedulerTest.cpp +++ b/cc/CCSchedulerTest.cpp @@ -23,12 +23,14 @@ public: void reset() { m_actions.clear(); + m_hasMoreResourceUpdates = false; m_canDraw = true; m_drawWillHappen = true; m_swapWillHappenIfDrawHappens = true; m_numDraws = 0; } + void setHasMoreResourceUpdates(bool b) { m_hasMoreResourceUpdates = b; } void setCanDraw(bool b) { m_canDraw = b; } int numDraws() const { return m_numDraws; } @@ -44,6 +46,7 @@ public: } virtual bool canDraw() OVERRIDE { return m_canDraw; } + virtual bool hasMoreResourceUpdates() const OVERRIDE { return m_hasMoreResourceUpdates; } virtual void scheduledActionBeginFrame() OVERRIDE { m_actions.push_back("scheduledActionBeginFrame"); } virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossible() OVERRIDE { @@ -90,9 +93,9 @@ TEST(CCSchedulerTest, RequestCommit) EXPECT_FALSE(timeSource->active()); client.reset(); - // Since, hasResourceUpdates is false, + // Since, hasMoreResourceUpdates is set to false, // beginFrameComplete should commit - scheduler->beginFrameComplete(false); + scheduler->beginFrameComplete(); EXPECT_EQ(1, client.numActions()); EXPECT_STREQ("scheduledActionCommit", client.action(0)); EXPECT_TRUE(timeSource->active()); @@ -126,9 +129,9 @@ TEST(CCSchedulerTest, RequestCommitAfterBeginFrame) // Now setNeedsCommit again. Calling here means we need a second frame. scheduler->setNeedsCommit(); - // Since, hasResourceUpdates is false, and another commit is + // Since, hasMoreResourceUpdates is set to false, and another commit is // needed, beginFrameComplete should commit, then begin another frame. - scheduler->beginFrameComplete(false); + scheduler->beginFrameComplete(); EXPECT_EQ(1, client.numActions()); EXPECT_STREQ("scheduledActionCommit", client.action(0)); client.reset(); @@ -161,7 +164,7 @@ TEST(CCSchedulerTest, TextureAcquisitionCollision) EXPECT_FALSE(timeSource->active()); // Trigger the commit - scheduler->beginFrameComplete(false); + scheduler->beginFrameComplete(); EXPECT_TRUE(timeSource->active()); client.reset(); @@ -189,7 +192,7 @@ TEST(CCSchedulerTest, VisibilitySwitchWithTextureAcquisition) scheduler->setVisible(true); scheduler->setNeedsCommit(); - scheduler->beginFrameComplete(false); + scheduler->beginFrameComplete(); scheduler->setMainThreadNeedsLayerTextures(); client.reset(); // Verify that pending texture acquisition fires when visibility @@ -358,7 +361,7 @@ TEST(CCSchedulerTest, RequestCommitInsideDraw) EXPECT_FALSE(timeSource->active()); EXPECT_EQ(1, client.numDraws()); EXPECT_TRUE(scheduler->commitPending()); - scheduler->beginFrameComplete(false); + scheduler->beginFrameComplete(); timeSource->tick(); EXPECT_EQ(2, client.numDraws()); diff --git a/cc/CCTextureUpdateController.cpp b/cc/CCTextureUpdateController.cpp index 9c448be..25d41cc 100644 --- a/cc/CCTextureUpdateController.cpp +++ b/cc/CCTextureUpdateController.cpp @@ -92,9 +92,8 @@ void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvi copier->flush(); } -CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerClient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) - : m_client(client) - , m_timer(adoptPtr(new CCTimer(thread, this))) +CCTextureUpdateController::CCTextureUpdateController(CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) + : m_timer(adoptPtr(new CCTimer(thread, this))) , m_queue(queue) , m_resourceProvider(resourceProvider) , m_copier(copier) @@ -108,40 +107,34 @@ CCTextureUpdateController::~CCTextureUpdateController() { } +bool CCTextureUpdateController::hasMoreUpdates() const +{ + return m_queue->hasMoreUpdates(); +} + void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit) { - ASSERT(monotonicTimeLimit >= m_monotonicTimeLimit); m_monotonicTimeLimit = monotonicTimeLimit; - // Update already in progress. - if (m_timer->isActive()) + if (!m_queue->hasMoreUpdates()) return; // Call updateMoreTexturesNow() directly unless it's the first update // attempt. This ensures that we empty the update queue in a finite // amount of time. if (m_firstUpdateAttempt) { - // Post a 0-delay task when no updates were left. When it runs, - // updateTexturesCompleted() will be called. - if (!updateMoreTexturesIfEnoughTimeRemaining()) - m_timer->startOneShot(0); - + updateMoreTexturesIfEnoughTimeRemaining(); m_firstUpdateAttempt = false; } else updateMoreTexturesNow(); } -void CCTextureUpdateController::discardUploads() -{ - // CCTextureUpdateControllerClient::updateTexturesCompleted will be - // called when all remaining texture copies are done. - m_queue->clearUploads(); -} - void CCTextureUpdateController::onTimerFired() { - if (!updateMoreTexturesIfEnoughTimeRemaining()) - m_client->updateTexturesCompleted(); + if (!m_queue->hasMoreUpdates()) + return; + + updateMoreTexturesIfEnoughTimeRemaining(); } double CCTextureUpdateController::monotonicTimeNow() const @@ -159,16 +152,11 @@ size_t CCTextureUpdateController::updateMoreTexturesSize() const return textureUpdatesPerTick; } -bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() +void CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() { - if (!m_queue->hasMoreUpdates()) - return false; - bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMoreTexturesTime(); if (hasTimeRemaining) updateMoreTexturesNow(); - - return true; } void CCTextureUpdateController::updateMoreTexturesNow() diff --git a/cc/CCTextureUpdateController.h b/cc/CCTextureUpdateController.h index 72929c4..6fc8db3 100644 --- a/cc/CCTextureUpdateController.h +++ b/cc/CCTextureUpdateController.h @@ -15,31 +15,21 @@ namespace WebCore { class TextureCopier; class TextureUploader; -class CCTextureUpdateControllerClient { -public: - virtual void updateTexturesCompleted() = 0; - -protected: - virtual ~CCTextureUpdateControllerClient() { } -}; - class CCTextureUpdateController : public CCTimerClient { WTF_MAKE_NONCOPYABLE(CCTextureUpdateController); public: - static PassOwnPtr<CCTextureUpdateController> create(CCTextureUpdateControllerClient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) + static PassOwnPtr<CCTextureUpdateController> create(CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) { - return adoptPtr(new CCTextureUpdateController(client, thread, queue, resourceProvider, copier, uploader)); + return adoptPtr(new CCTextureUpdateController(thread, queue, resourceProvider, copier, uploader)); } static size_t maxPartialTextureUpdates(); static void updateTextures(CCResourceProvider*, TextureCopier*, TextureUploader*, CCTextureUpdateQueue*, size_t count); virtual ~CCTextureUpdateController(); + bool hasMoreUpdates() const; void updateMoreTextures(double monotonicTimeLimit); - // Discard all remaining uploads. - void discardUploads(); - // CCTimerClient implementation. virtual void onTimerFired() OVERRIDE; @@ -49,13 +39,11 @@ public: virtual size_t updateMoreTexturesSize() const; protected: - CCTextureUpdateController(CCTextureUpdateControllerClient*, CCThread*, PassOwnPtr<CCTextureUpdateQueue>, CCResourceProvider*, TextureCopier*, TextureUploader*); + CCTextureUpdateController(CCThread*, PassOwnPtr<CCTextureUpdateQueue>, CCResourceProvider*, TextureCopier*, TextureUploader*); - // This returns true when there were textures left to update. - bool updateMoreTexturesIfEnoughTimeRemaining(); + void updateMoreTexturesIfEnoughTimeRemaining(); void updateMoreTexturesNow(); - CCTextureUpdateControllerClient* m_client; OwnPtr<CCTimer> m_timer; OwnPtr<CCTextureUpdateQueue> m_queue; bool m_contentsTexturesPurged; diff --git a/cc/CCTextureUpdateControllerTest.cpp b/cc/CCTextureUpdateControllerTest.cpp index d2a6fcf6..2ed0e59 100644 --- a/cc/CCTextureUpdateControllerTest.cpp +++ b/cc/CCTextureUpdateControllerTest.cpp @@ -521,23 +521,11 @@ TEST_F(CCTextureUpdateControllerTest, TripleUpdateFinalUpdateAllPartial) EXPECT_EQ(kFullUploads + kPartialUploads, m_numTotalUploads); } -class FakeCCTextureUpdateControllerClient : public WebCore::CCTextureUpdateControllerClient { -public: - FakeCCTextureUpdateControllerClient() { reset(); } - void reset() { m_completedCalled = false; } - bool completedCalled() const { return m_completedCalled; } - - virtual void updateTexturesCompleted() OVERRIDE { m_completedCalled = true; } - -protected: - bool m_completedCalled; -}; - class FakeCCTextureUpdateController : public WebCore::CCTextureUpdateController { public: - static PassOwnPtr<FakeCCTextureUpdateController> create(WebCore::CCTextureUpdateControllerClient* client, WebCore::CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) + static PassOwnPtr<FakeCCTextureUpdateController> create(WebCore::CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) { - return adoptPtr(new FakeCCTextureUpdateController(client, thread, queue, resourceProvider, copier, uploader)); + return adoptPtr(new FakeCCTextureUpdateController(thread, queue, resourceProvider, copier, uploader)); } void setMonotonicTimeNow(double time) { m_monotonicTimeNow = time; } @@ -548,8 +536,8 @@ public: virtual size_t updateMoreTexturesSize() const OVERRIDE { return m_updateMoreTexturesSize; } protected: - FakeCCTextureUpdateController(WebCore::CCTextureUpdateControllerClient* client, WebCore::CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) - : WebCore::CCTextureUpdateController(client, thread, queue, resourceProvider, copier, uploader) + FakeCCTextureUpdateController(WebCore::CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) + : WebCore::CCTextureUpdateController(thread, queue, resourceProvider, copier, uploader) , m_monotonicTimeNow(0) , m_updateMoreTexturesTime(0) , m_updateMoreTexturesSize(0) { } @@ -559,17 +547,8 @@ protected: size_t m_updateMoreTexturesSize; }; -static void runPendingTasks(FakeCCThread* thread, FakeCCTextureUpdateController* controller) -{ - while (thread->hasPendingTask()) { - controller->setMonotonicTimeNow(controller->monotonicTimeNow() + thread->pendingDelayMs() / 1000.0); - thread->runPendingTask(); - } -} - TEST_F(CCTextureUpdateControllerTest, UpdateMoreTextures) { - FakeCCTextureUpdateControllerClient client; FakeCCThread thread; setMaxUploadCountPerUpdate(1); @@ -577,34 +556,39 @@ TEST_F(CCTextureUpdateControllerTest, UpdateMoreTextures) appendPartialUploadsToUpdateQueue(0); DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTextureUpdateController> controller(FakeCCTextureUpdateController::create(&client, &thread, m_queue.release(), m_resourceProvider.get(), &m_copier, &m_uploader)); + OwnPtr<FakeCCTextureUpdateController> controller(FakeCCTextureUpdateController::create(&thread, m_queue.release(), m_resourceProvider.get(), &m_copier, &m_uploader)); controller->setMonotonicTimeNow(0); controller->setUpdateMoreTexturesTime(0.1); controller->setUpdateMoreTexturesSize(1); // Not enough time for any updates. controller->updateMoreTextures(0.09); - runPendingTasks(&thread, controller.get()); + EXPECT_FALSE(thread.hasPendingTask()); EXPECT_EQ(0, m_numBeginUploads); EXPECT_EQ(0, m_numEndUploads); + thread.reset(); controller->setMonotonicTimeNow(0); controller->setUpdateMoreTexturesTime(0.1); controller->setUpdateMoreTexturesSize(1); // Only enough time for 1 update. controller->updateMoreTextures(0.12); - runPendingTasks(&thread, controller.get()); + EXPECT_TRUE(thread.hasPendingTask()); + controller->setMonotonicTimeNow(thread.pendingDelayMs() / 1000.0); + thread.runPendingTask(); EXPECT_EQ(1, m_numBeginUploads); EXPECT_EQ(1, m_numEndUploads); EXPECT_EQ(1, m_numTotalUploads); + thread.reset(); controller->setMonotonicTimeNow(0); controller->setUpdateMoreTexturesTime(0.1); controller->setUpdateMoreTexturesSize(1); // Enough time for 2 updates. controller->updateMoreTextures(0.22); - runPendingTasks(&thread, controller.get()); - EXPECT_TRUE(client.completedCalled()); + EXPECT_TRUE(thread.hasPendingTask()); + controller->setMonotonicTimeNow(controller->monotonicTimeNow() + thread.pendingDelayMs() / 1000.0); + thread.runPendingTask(); EXPECT_EQ(3, m_numBeginUploads); EXPECT_EQ(3, m_numEndUploads); EXPECT_EQ(3, m_numTotalUploads); @@ -612,7 +596,6 @@ TEST_F(CCTextureUpdateControllerTest, UpdateMoreTextures) TEST_F(CCTextureUpdateControllerTest, NoMoreUpdates) { - FakeCCTextureUpdateControllerClient client; FakeCCThread thread; setMaxUploadCountPerUpdate(1); @@ -620,26 +603,30 @@ TEST_F(CCTextureUpdateControllerTest, NoMoreUpdates) appendPartialUploadsToUpdateQueue(0); DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTextureUpdateController> controller(FakeCCTextureUpdateController::create(&client, &thread, m_queue.release(), m_resourceProvider.get(), &m_copier, &m_uploader)); + OwnPtr<FakeCCTextureUpdateController> controller(FakeCCTextureUpdateController::create(&thread, m_queue.release(), m_resourceProvider.get(), &m_copier, &m_uploader)); controller->setMonotonicTimeNow(0); controller->setUpdateMoreTexturesTime(0.1); controller->setUpdateMoreTexturesSize(1); // Enough time for 3 updates but only 2 necessary. controller->updateMoreTextures(0.31); - runPendingTasks(&thread, controller.get()); - EXPECT_TRUE(client.completedCalled()); + EXPECT_TRUE(thread.hasPendingTask()); + controller->setMonotonicTimeNow(controller->monotonicTimeNow() + thread.pendingDelayMs() / 1000.0); + thread.runPendingTask(); + EXPECT_TRUE(thread.hasPendingTask()); + controller->setMonotonicTimeNow(controller->monotonicTimeNow() + thread.pendingDelayMs() / 1000.0); + thread.runPendingTask(); EXPECT_EQ(2, m_numBeginUploads); EXPECT_EQ(2, m_numEndUploads); EXPECT_EQ(2, m_numTotalUploads); + thread.reset(); controller->setMonotonicTimeNow(0); controller->setUpdateMoreTexturesTime(0.1); controller->setUpdateMoreTexturesSize(1); // Enough time for updates but no more updates left. controller->updateMoreTextures(0.31); - runPendingTasks(&thread, controller.get()); - EXPECT_TRUE(client.completedCalled()); + EXPECT_FALSE(thread.hasPendingTask()); EXPECT_EQ(2, m_numBeginUploads); EXPECT_EQ(2, m_numEndUploads); EXPECT_EQ(2, m_numTotalUploads); @@ -647,7 +634,6 @@ TEST_F(CCTextureUpdateControllerTest, NoMoreUpdates) TEST_F(CCTextureUpdateControllerTest, UpdatesCompleteInFiniteTime) { - FakeCCTextureUpdateControllerClient client; FakeCCThread thread; setMaxUploadCountPerUpdate(1); @@ -655,22 +641,25 @@ TEST_F(CCTextureUpdateControllerTest, UpdatesCompleteInFiniteTime) appendPartialUploadsToUpdateQueue(0); DebugScopedSetImplThread implThread; - OwnPtr<FakeCCTextureUpdateController> controller(FakeCCTextureUpdateController::create(&client, &thread, m_queue.release(), m_resourceProvider.get(), &m_copier, &m_uploader)); + OwnPtr<FakeCCTextureUpdateController> controller(FakeCCTextureUpdateController::create(&thread, m_queue.release(), m_resourceProvider.get(), &m_copier, &m_uploader)); controller->setMonotonicTimeNow(0); controller->setUpdateMoreTexturesTime(0.5); controller->setUpdateMoreTexturesSize(1); for (int i = 0; i < 100; i++) { - if (client.completedCalled()) + if (!controller->hasMoreUpdates()) break; // Not enough time for any updates. controller->updateMoreTextures(0.4); - runPendingTasks(&thread, controller.get()); + + if (thread.hasPendingTask()) { + controller->setMonotonicTimeNow(controller->monotonicTimeNow() + thread.pendingDelayMs() / 1000.0); + thread.runPendingTask(); + } } - EXPECT_TRUE(client.completedCalled()); EXPECT_EQ(2, m_numBeginUploads); EXPECT_EQ(2, m_numEndUploads); EXPECT_EQ(2, m_numTotalUploads); diff --git a/cc/CCThreadProxy.cpp b/cc/CCThreadProxy.cpp index 0984b3c..394b286 100644 --- a/cc/CCThreadProxy.cpp +++ b/cc/CCThreadProxy.cpp @@ -14,6 +14,7 @@ #include "CCLayerTreeHost.h" #include "CCScheduler.h" #include "CCScopedThreadProxy.h" +#include "CCTextureUpdateController.h" #include "CCThreadTask.h" #include "TraceEvent.h" #include <public/WebSharedGraphicsContext3D.h> @@ -47,6 +48,7 @@ PassOwnPtr<CCProxy> CCThreadProxy::create(CCLayerTreeHost* layerTreeHost) CCThreadProxy::CCThreadProxy(CCLayerTreeHost* layerTreeHost) : m_animateRequested(false) , m_commitRequested(false) + , m_commitRequestSentToImplThread(false) , m_forcedCommitRequested(false) , m_layerTreeHost(layerTreeHost) , m_compositorIdentifier(-1) @@ -275,7 +277,11 @@ void CCThreadProxy::setNeedsAnimate() TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate"); m_animateRequested = true; - setNeedsCommit(); + + if (m_commitRequestSentToImplThread) + return; + m_commitRequestSentToImplThread = true; + CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::setNeedsCommitOnImplThread)); } void CCThreadProxy::setNeedsCommit() @@ -283,9 +289,12 @@ void CCThreadProxy::setNeedsCommit() ASSERT(isMainThread()); if (m_commitRequested) return; - TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit"); m_commitRequested = true; + + if (m_commitRequestSentToImplThread) + return; + m_commitRequestSentToImplThread = true; CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::setNeedsCommitOnImplThread)); } @@ -293,8 +302,7 @@ void CCThreadProxy::didLoseContextOnImplThread() { ASSERT(isImplThread()); TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread"); - if (m_currentTextureUpdateControllerOnImplThread) - m_currentTextureUpdateControllerOnImplThread->discardUploads(); + m_currentTextureUpdateControllerOnImplThread.clear(); m_schedulerOnImplThread->didLoseContext(); } @@ -468,6 +476,7 @@ void CCThreadProxy::beginFrame() // the paint, m_commitRequested will be set to false to allow new commit // requests to be scheduled. m_commitRequested = true; + m_commitRequestSentToImplThread = true; // On the other hand, the animationRequested flag needs to be cleared // here so that any animation requests generated by the apply or animate @@ -480,6 +489,7 @@ void CCThreadProxy::beginFrame() if (!m_inCompositeAndReadback && !m_layerTreeHost->visible()) { m_commitRequested = false; + m_commitRequestSentToImplThread = false; m_forcedCommitRequested = false; TRACE_EVENT0("cc", "EarlyOut_NotVisible"); @@ -496,6 +506,7 @@ void CCThreadProxy::beginFrame() // layout when painted will trigger another setNeedsCommit inside // updateLayers. m_commitRequested = false; + m_commitRequestSentToImplThread = false; m_forcedCommitRequested = false; if (!m_layerTreeHost->initializeRendererIfNeeded()) @@ -512,11 +523,16 @@ void CCThreadProxy::beginFrame() m_texturesAcquired = false; m_layerTreeHost->willCommit(); - // Before applying scrolls and calling animate, we set m_animateRequested to false. - // If it is true now, it means setNeedAnimate was called again. Call setNeedsCommit - // now so that we get begin frame when this one is done. - if (m_animateRequested) - setNeedsCommit(); + // Before applying scrolls and calling animate, we set m_animateRequested to + // false. If it is true now, it means setNeedAnimate was called again, but + // during a state when m_commitRequestSentToImplThread = true. We need to + // force that call to happen again now so that the commit request is sent to + // the impl thread. + if (m_animateRequested) { + // Forces setNeedsAnimate to consider posting a commit task. + m_animateRequested = false; + setNeedsAnimate(); + } // Notify the impl thread that the beginFrame has completed. This will // begin the commit process, which is blocking from the main thread's @@ -558,12 +574,10 @@ void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion } else m_resetContentsTexturesPurgedAfterCommitOnImplThread = true; - bool hasResourceUpdates = queue->hasMoreUpdates(); - if (hasResourceUpdates) - m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->renderer()->textureUploader()); + m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->renderer()->textureUploader()); m_commitCompletionEventOnImplThread = completion; - m_schedulerOnImplThread->beginFrameComplete(hasResourceUpdates); + m_schedulerOnImplThread->beginFrameComplete(); } void CCThreadProxy::beginFrameAbortedOnImplThread() @@ -576,6 +590,13 @@ void CCThreadProxy::beginFrameAbortedOnImplThread() m_schedulerOnImplThread->beginFrameAborted(); } +bool CCThreadProxy::hasMoreResourceUpdates() const +{ + if (!m_currentTextureUpdateControllerOnImplThread) + return false; + return m_currentTextureUpdateControllerOnImplThread->hasMoreUpdates(); +} + bool CCThreadProxy::canDraw() { ASSERT(isImplThread()); @@ -595,6 +616,7 @@ void CCThreadProxy::scheduledActionCommit() { TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); ASSERT(isImplThread()); + ASSERT(!hasMoreResourceUpdates()); ASSERT(m_commitCompletionEventOnImplThread); m_currentTextureUpdateControllerOnImplThread.clear(); @@ -732,12 +754,6 @@ CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc return scheduledActionDrawAndSwapInternal(true); } -void CCThreadProxy::updateTexturesCompleted() -{ - ASSERT(isImplThread()); - m_schedulerOnImplThread->updateResourcesComplete(); -} - void CCThreadProxy::didCommitAndDrawFrame() { ASSERT(isMainThread()); diff --git a/cc/CCThreadProxy.h b/cc/CCThreadProxy.h index 0d5f8d9..c488dcb 100644 --- a/cc/CCThreadProxy.h +++ b/cc/CCThreadProxy.h @@ -10,7 +10,6 @@ #include "CCLayerTreeHostImpl.h" #include "CCProxy.h" #include "CCScheduler.h" -#include "CCTextureUpdateController.h" #include <wtf/OwnPtr.h> namespace WebCore { @@ -20,10 +19,11 @@ class CCLayerTreeHost; class CCScheduler; class CCScopedThreadProxy; class CCTextureUpdateQueue; +class CCTextureUpdateController; class CCThread; class CCThreadProxyContextRecreationTimer; -class CCThreadProxy : public CCProxy, CCLayerTreeHostImplClient, CCSchedulerClient, CCTextureUpdateControllerClient { +class CCThreadProxy : public CCProxy, CCLayerTreeHostImplClient, CCSchedulerClient { public: static PassOwnPtr<CCProxy> create(CCLayerTreeHost*); @@ -64,6 +64,7 @@ public: // CCSchedulerClient implementation virtual bool canDraw() OVERRIDE; + virtual bool hasMoreResourceUpdates() const OVERRIDE; virtual void scheduledActionBeginFrame() OVERRIDE; virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapIfPossible() OVERRIDE; virtual CCScheduledActionDrawAndSwapResult scheduledActionDrawAndSwapForced() OVERRIDE; @@ -72,9 +73,6 @@ public: virtual void scheduledActionBeginContextRecreation() OVERRIDE; virtual void scheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; - // CCTextureUpdateControllerClient implementation - virtual void updateTexturesCompleted() OVERRIDE; - private: explicit CCThreadProxy(CCLayerTreeHost*); friend class CCThreadProxyContextRecreationTimer; @@ -129,8 +127,9 @@ private: void setNeedsForcedCommitOnImplThread(); // Accessed on main thread only. - bool m_animateRequested; - bool m_commitRequested; + bool m_animateRequested; // Set only when setNeedsAnimate is called. + bool m_commitRequested; // Set only when setNeedsCommit is called. + bool m_commitRequestSentToImplThread; // Set by setNeedsCommit and setNeedsAnimate. bool m_forcedCommitRequested; OwnPtr<CCThreadProxyContextRecreationTimer> m_contextRecreationTimer; CCLayerTreeHost* m_layerTreeHost; diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index f4b0334..e24b71d 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -40,6 +40,8 @@ 'CCThreadedTest.h', 'CCTiledLayerImplTest.cpp', 'CCTimerTest.cpp', + ], + 'cc_tests_support_files': [ 'test/CCAnimationTestCommon.cpp', 'test/CCAnimationTestCommon.h', 'test/CCLayerTestCommon.cpp', @@ -60,7 +62,7 @@ 'test/FakeWebGraphicsContext3D.h', 'test/FakeWebScrollbarThemeGeometry.h', 'test/MockCCQuadCuller.h', - ] + ], }, 'conditions': [ ['use_libcc_for_compositor==1 and component!="shared_library"', { @@ -69,15 +71,16 @@ 'target_name': 'cc_unittests', 'type': 'executable', 'dependencies': [ - '<(DEPTH)/base/base.gyp:test_support_base', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(DEPTH)/testing/gmock.gyp:gmock', - '<(DEPTH)/webkit/support/webkit_support.gyp:webkit_support', - '<(DEPTH)/skia/skia.gyp:skia', + '../base/base.gyp:test_support_base', + '../testing/gtest.gyp:gtest', + '../testing/gmock.gyp:gmock', + '../webkit/support/webkit_support.gyp:webkit_support', + '../skia/skia.gyp:skia', # We have to depend on WTF directly to pick up the correct defines for WTF headers - for instance USE_SYSTEM_MALLOC. - '<(DEPTH)/third_party/WebKit/Source/WTF/WTF.gyp/WTF.gyp:wtf', - '<(DEPTH)/third_party/WebKit/Source/Platform/Platform.gyp/Platform.gyp:webkit_platform', + '../third_party/WebKit/Source/WTF/WTF.gyp/WTF.gyp:wtf', + '../third_party/WebKit/Source/Platform/Platform.gyp/Platform.gyp:webkit_platform', 'cc.gyp:cc', + 'cc_test_support', ], 'defines': [ 'WTF_USE_ACCELERATED_COMPOSITING=1', @@ -92,6 +95,30 @@ 'test/run_all_unittests.cc', ], }, + { + 'target_name': 'cc_test_support', + 'type': 'static_library', + 'defines': [ + 'WTF_USE_ACCELERATED_COMPOSITING=1', + ], + 'include_dirs': [ + 'stubs', + 'test', + '.', + '..', + ], + 'dependencies': [ + '../ui/gl/gl.gyp:gl', + '../testing/gtest.gyp:gtest', + '../testing/gmock.gyp:gmock', + '../skia/skia.gyp:skia', + '../third_party/WebKit/Source/WTF/WTF.gyp/WTF.gyp:wtf', + '../third_party/WebKit/Source/Platform/Platform.gyp/Platform.gyp:webkit_platform', + ], + 'sources': [ + '<@(cc_tests_support_files)', + ], + }, ], }, { 'targets': [ diff --git a/cc/copyfiles.py b/cc/copyfiles.py index 8366ccb..00943ae 100644 --- a/cc/copyfiles.py +++ b/cc/copyfiles.py @@ -61,16 +61,15 @@ def Readfile(gypfile): obj = eval(cc_gyp.read()) return obj -def Main(): - files = Readfile("cc.gyp")['variables']['cc_source_files'] +def CopyFiles(files): for f in files: dst = Copy(f) FixCopyrightHeader(dst) - files = Readfile("cc_tests.gyp")['variables']['cc_tests_source_files'] - for f in files: - dst = Copy(f) - FixCopyrightHeader(dst) +def Main(): + CopyFiles(Readfile("cc.gyp")['variables']['cc_source_files']) + CopyFiles(Readfile("cc_tests.gyp")['variables']['cc_tests_source_files']) + CopyFiles(Readfile("cc_tests.gyp")['variables']['cc_tests_support_files']) if __name__ == '__main__': import sys diff --git a/cc/test/CCAnimationTestCommon.cpp b/cc/test/CCAnimationTestCommon.cpp index db09228..9312d77 100644 --- a/cc/test/CCAnimationTestCommon.cpp +++ b/cc/test/CCAnimationTestCommon.cpp @@ -65,6 +65,16 @@ FakeFloatAnimationCurve::~FakeFloatAnimationCurve() { } +double FakeFloatAnimationCurve::duration() const +{ + return 1; +} + +float FakeFloatAnimationCurve::getValue(double now) const +{ + return 0; +} + PassOwnPtr<WebCore::CCAnimationCurve> FakeFloatAnimationCurve::clone() const { return adoptPtr(new FakeFloatAnimationCurve); @@ -79,6 +89,11 @@ FakeTransformTransition::~FakeTransformTransition() { } +double FakeTransformTransition::duration() const +{ + return m_duration; +} + WebKit::WebTransformationMatrix FakeTransformTransition::getValue(double time) const { return WebKit::WebTransformationMatrix(); @@ -101,6 +116,11 @@ FakeFloatTransition::~FakeFloatTransition() { } +double FakeFloatTransition::duration() const +{ + return m_duration; +} + float FakeFloatTransition::getValue(double time) const { time /= m_duration; @@ -118,6 +138,31 @@ FakeLayerAnimationControllerClient::~FakeLayerAnimationControllerClient() { } +int FakeLayerAnimationControllerClient::id() const +{ + return 0; +} + +void FakeLayerAnimationControllerClient::setOpacityFromAnimation(float opacity) +{ + m_opacity = opacity; +} + +float FakeLayerAnimationControllerClient::opacity() const +{ + return m_opacity; +} + +void FakeLayerAnimationControllerClient::setTransformFromAnimation(const WebKit::WebTransformationMatrix& transform) +{ + m_transform = transform; +} + +const WebKit::WebTransformationMatrix& FakeLayerAnimationControllerClient::transform() const +{ + return m_transform; +} + PassOwnPtr<WebCore::CCAnimationCurve> FakeFloatTransition::clone() const { return adoptPtr(new FakeFloatTransition(*this)); diff --git a/cc/test/CCAnimationTestCommon.h b/cc/test/CCAnimationTestCommon.h index 9f13643..51f5a51 100644 --- a/cc/test/CCAnimationTestCommon.h +++ b/cc/test/CCAnimationTestCommon.h @@ -24,8 +24,8 @@ public: FakeFloatAnimationCurve(); virtual ~FakeFloatAnimationCurve(); - virtual double duration() const OVERRIDE { return 1; } - virtual float getValue(double now) const OVERRIDE { return 0; } + virtual double duration() const OVERRIDE; + virtual float getValue(double now) const OVERRIDE; virtual PassOwnPtr<WebCore::CCAnimationCurve> clone() const OVERRIDE; }; @@ -34,7 +34,7 @@ public: FakeTransformTransition(double duration); virtual ~FakeTransformTransition(); - virtual double duration() const OVERRIDE { return m_duration; } + virtual double duration() const OVERRIDE; virtual WebKit::WebTransformationMatrix getValue(double time) const OVERRIDE; virtual PassOwnPtr<WebCore::CCAnimationCurve> clone() const OVERRIDE; @@ -48,7 +48,7 @@ public: FakeFloatTransition(double duration, float from, float to); virtual ~FakeFloatTransition(); - virtual double duration() const OVERRIDE { return m_duration; } + virtual double duration() const OVERRIDE; virtual float getValue(double time) const OVERRIDE; virtual PassOwnPtr<WebCore::CCAnimationCurve> clone() const OVERRIDE; @@ -65,11 +65,11 @@ public: virtual ~FakeLayerAnimationControllerClient(); // CCLayerAnimationControllerClient implementation - virtual int id() const OVERRIDE { return 0; } - virtual void setOpacityFromAnimation(float opacity) OVERRIDE { m_opacity = opacity; } - virtual float opacity() const OVERRIDE { return m_opacity; } - virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix& transform) OVERRIDE { m_transform = transform; } - virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE { return m_transform; } + virtual int id() const OVERRIDE; + virtual void setOpacityFromAnimation(float) OVERRIDE; + virtual float opacity() const OVERRIDE; + virtual void setTransformFromAnimation(const WebKit::WebTransformationMatrix&) OVERRIDE; + virtual const WebKit::WebTransformationMatrix& transform() const OVERRIDE; private: float m_opacity; diff --git a/cc/test/CCTiledLayerTestCommon.cpp b/cc/test/CCTiledLayerTestCommon.cpp index a1ba83c..542d459 100644 --- a/cc/test/CCTiledLayerTestCommon.cpp +++ b/cc/test/CCTiledLayerTestCommon.cpp @@ -65,6 +65,11 @@ PassOwnPtr<LayerTextureUpdater::Texture> FakeLayerTextureUpdater::createTexture( return adoptPtr(new Texture(this, CCPrioritizedTexture::create(manager))); } +LayerTextureUpdater::SampledTexelFormat FakeLayerTextureUpdater::sampledTexelFormat(GC3Denum) +{ + return SampledTexelFormatRGBA; +} + FakeCCTiledLayerImpl::FakeCCTiledLayerImpl(int id) : CCTiledLayerImpl(id) { @@ -85,6 +90,11 @@ FakeTiledLayerChromium::FakeTiledLayerChromium(CCPrioritizedTextureManager* text setIsDrawable(true); // So that we don't get false positives if any of these tests expect to return false from drawsContent() for other reasons. } +FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(CCPrioritizedTextureManager* textureManager) + : FakeTiledLayerChromium(textureManager) +{ +} + FakeTiledLayerChromium::~FakeTiledLayerChromium() { } @@ -112,9 +122,29 @@ void FakeTiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& ca } } -FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(CCPrioritizedTextureManager* textureManager) - : FakeTiledLayerChromium(textureManager) +WebCore::CCPrioritizedTextureManager* FakeTiledLayerChromium::textureManager() const +{ + return m_textureManager; +} + +WebCore::LayerTextureUpdater* FakeTiledLayerChromium::textureUpdater() const +{ + return m_fakeTextureUpdater.get(); +} + +WebCore::IntSize FakeTiledLayerWithScaledBounds::contentBounds() const +{ + return m_forcedContentBounds; +} + +bool FakeTextureUploader::isBusy() +{ + return false; +} + +void FakeTextureUploader::uploadTexture(WebCore::CCResourceProvider* resourceProvider, Parameters upload) { + upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destOffset); } } // namespace diff --git a/cc/test/CCTiledLayerTestCommon.h b/cc/test/CCTiledLayerTestCommon.h index 105a242..c9a38b4 100644 --- a/cc/test/CCTiledLayerTestCommon.h +++ b/cc/test/CCTiledLayerTestCommon.h @@ -40,7 +40,7 @@ public: virtual ~FakeLayerTextureUpdater(); virtual PassOwnPtr<WebCore::LayerTextureUpdater::Texture> createTexture(WebCore::CCPrioritizedTextureManager*) OVERRIDE; - virtual SampledTexelFormat sampledTexelFormat(GC3Denum) OVERRIDE { return SampledTexelFormatRGBA; } + virtual SampledTexelFormat sampledTexelFormat(GC3Denum) OVERRIDE; virtual void prepareToUpdate(const WebCore::IntRect& contentRect, const WebCore::IntSize&, float, float, WebCore::IntRect& resultingOpaqueRect, WebCore::CCRenderingStats&) OVERRIDE; // Sets the rect to invalidate during the next call to prepareToUpdate(). After the next @@ -102,12 +102,12 @@ public: virtual void setTexturePriorities(const WebCore::CCPriorityCalculator&) OVERRIDE; - virtual WebCore::CCPrioritizedTextureManager* textureManager() const OVERRIDE { return m_textureManager; } + virtual WebCore::CCPrioritizedTextureManager* textureManager() const OVERRIDE; FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpdater.get(); } WebCore::FloatRect updateRect() { return m_updateRect; } protected: - virtual WebCore::LayerTextureUpdater* textureUpdater() const OVERRIDE { return m_fakeTextureUpdater.get(); } + virtual WebCore::LayerTextureUpdater* textureUpdater() const OVERRIDE; virtual void createTextureUpdaterIfNeeded() OVERRIDE { } private: @@ -121,7 +121,7 @@ public: explicit FakeTiledLayerWithScaledBounds(WebCore::CCPrioritizedTextureManager*); void setContentBounds(const WebCore::IntSize& contentBounds) { m_forcedContentBounds = contentBounds; } - virtual WebCore::IntSize contentBounds() const OVERRIDE { return m_forcedContentBounds; } + virtual WebCore::IntSize contentBounds() const OVERRIDE; protected: WebCore::IntSize m_forcedContentBounds; @@ -129,16 +129,16 @@ protected: class FakeTextureCopier : public WebCore::TextureCopier { public: - virtual void copyTexture(Parameters) { } - virtual void flush() { } + virtual void copyTexture(Parameters) OVERRIDE { } + virtual void flush() OVERRIDE { } }; class FakeTextureUploader : public WebCore::TextureUploader { public: - virtual bool isBusy() { return false; } - virtual void beginUploads() { } - virtual void endUploads() { } - virtual void uploadTexture(WebCore::CCResourceProvider* resourceProvider, Parameters upload) { upload.texture->updateRect(resourceProvider, upload.sourceRect, upload.destOffset); } + virtual bool isBusy() OVERRIDE; + virtual void beginUploads() OVERRIDE { } + virtual void endUploads() OVERRIDE { } + virtual void uploadTexture(WebCore::CCResourceProvider*, Parameters upload) OVERRIDE; }; } diff --git a/cc/test/FakeWebCompositorOutputSurface.h b/cc/test/FakeWebCompositorOutputSurface.h index 6a728fe..97ebbac 100644 --- a/cc/test/FakeWebCompositorOutputSurface.h +++ b/cc/test/FakeWebCompositorOutputSurface.h @@ -7,6 +7,8 @@ #include <public/WebCompositorOutputSurface.h> #include <public/WebGraphicsContext3D.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> namespace WebKit { |