| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCTextureUpdateController.h" | 7 #include "CCTextureUpdateController.h" |
| 8 | 8 |
| 9 #include "CCSchedulerTestCommon.h" | 9 #include "CCSchedulerTestCommon.h" |
| 10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread | 10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread |
| 11 #include "CCTiledLayerTestCommon.h" | 11 #include "CCTiledLayerTestCommon.h" |
| 12 #include "FakeWebCompositorOutputSurface.h" | 12 #include "FakeWebCompositorOutputSurface.h" |
| 13 #include "FakeWebGraphicsContext3D.h" | 13 #include "FakeWebGraphicsContext3D.h" |
| 14 #include "WebCompositorInitializer.h" | 14 #include "WebCompositorInitializer.h" |
| 15 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
| 16 #include <public/WebThread.h> | 16 #include <public/WebThread.h> |
| 17 #include <wtf/RefPtr.h> | 17 #include <wtf/RefPtr.h> |
| 18 | 18 |
| 19 using namespace WebCore; | 19 using namespace cc; |
| 20 using namespace WebKit; | 20 using namespace WebKit; |
| 21 using namespace WebKitTests; | 21 using namespace WebKitTests; |
| 22 using testing::Test; | 22 using testing::Test; |
| 23 | 23 |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 const int kFlushPeriodFull = 4; | 27 const int kFlushPeriodFull = 4; |
| 28 const int kFlushPeriodPartial = kFlushPeriodFull; | 28 const int kFlushPeriodPartial = kFlushPeriodFull; |
| 29 | 29 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 52 bool m_supportShallowFlush; | 52 bool m_supportShallowFlush; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 | 55 |
| 56 class TextureUploaderForUploadTest : public FakeTextureUploader { | 56 class TextureUploaderForUploadTest : public FakeTextureUploader { |
| 57 public: | 57 public: |
| 58 TextureUploaderForUploadTest(CCTextureUpdateControllerTest *test) : m_test(t
est) { } | 58 TextureUploaderForUploadTest(CCTextureUpdateControllerTest *test) : m_test(t
est) { } |
| 59 | 59 |
| 60 virtual void beginUploads() OVERRIDE; | 60 virtual void beginUploads() OVERRIDE; |
| 61 virtual void endUploads() OVERRIDE; | 61 virtual void endUploads() OVERRIDE; |
| 62 virtual void uploadTexture(WebCore::CCResourceProvider*, Parameters) OVERRID
E; | 62 virtual void uploadTexture(cc::CCResourceProvider*, Parameters) OVERRIDE; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 CCTextureUpdateControllerTest* m_test; | 65 CCTextureUpdateControllerTest* m_test; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class TextureForUploadTest : public LayerTextureUpdater::Texture { | 68 class TextureForUploadTest : public LayerTextureUpdater::Texture { |
| 69 public: | 69 public: |
| 70 TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritized
Texture>(0)) { } | 70 TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritized
Texture>(0)) { } |
| 71 virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, cons
t IntSize& destOffset) { } | 71 virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, cons
t IntSize& destOffset) { } |
| 72 }; | 72 }; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 void TextureUploaderForUploadTest::beginUploads() | 226 void TextureUploaderForUploadTest::beginUploads() |
| 227 { | 227 { |
| 228 m_test->onBeginUploads(); | 228 m_test->onBeginUploads(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void TextureUploaderForUploadTest::endUploads() | 231 void TextureUploaderForUploadTest::endUploads() |
| 232 { | 232 { |
| 233 m_test->onEndUploads(); | 233 m_test->onEndUploads(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void TextureUploaderForUploadTest::uploadTexture(WebCore::CCResourceProvider*, P
arameters) | 236 void TextureUploaderForUploadTest::uploadTexture(cc::CCResourceProvider*, Parame
ters) |
| 237 { | 237 { |
| 238 m_test->onUpload(); | 238 m_test->onUpload(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 | 241 |
| 242 // ZERO UPLOADS TESTS | 242 // ZERO UPLOADS TESTS |
| 243 TEST_F(CCTextureUpdateControllerTest, ZeroUploads) | 243 TEST_F(CCTextureUpdateControllerTest, ZeroUploads) |
| 244 { | 244 { |
| 245 appendFullUploadsToUpdateQueue(0); | 245 appendFullUploadsToUpdateQueue(0); |
| 246 appendPartialUploadsToUpdateQueue(0); | 246 appendPartialUploadsToUpdateQueue(0); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 | 511 |
| 512 EXPECT_EQ(3, m_numBeginUploads); | 512 EXPECT_EQ(3, m_numBeginUploads); |
| 513 EXPECT_EQ(3, m_numEndUploads); | 513 EXPECT_EQ(3, m_numEndUploads); |
| 514 EXPECT_LE(m_numPreviousUploads, kMaxUploadsPerUpdate); | 514 EXPECT_LE(m_numPreviousUploads, kMaxUploadsPerUpdate); |
| 515 // Be lenient on the exact number of flushes here as well. | 515 // Be lenient on the exact number of flushes here as well. |
| 516 | 516 |
| 517 // Final sanity checks | 517 // Final sanity checks |
| 518 EXPECT_EQ(kFullUploads + kPartialUploads, m_numTotalUploads); | 518 EXPECT_EQ(kFullUploads + kPartialUploads, m_numTotalUploads); |
| 519 } | 519 } |
| 520 | 520 |
| 521 class FakeCCTextureUpdateControllerClient : public WebCore::CCTextureUpdateContr
ollerClient { | 521 class FakeCCTextureUpdateControllerClient : public cc::CCTextureUpdateController
Client { |
| 522 public: | 522 public: |
| 523 FakeCCTextureUpdateControllerClient() { reset(); } | 523 FakeCCTextureUpdateControllerClient() { reset(); } |
| 524 void reset() { m_completedCalled = false; } | 524 void reset() { m_completedCalled = false; } |
| 525 bool completedCalled() const { return m_completedCalled; } | 525 bool completedCalled() const { return m_completedCalled; } |
| 526 | 526 |
| 527 virtual void updateTexturesCompleted() OVERRIDE { m_completedCalled = true;
} | 527 virtual void updateTexturesCompleted() OVERRIDE { m_completedCalled = true;
} |
| 528 | 528 |
| 529 protected: | 529 protected: |
| 530 bool m_completedCalled; | 530 bool m_completedCalled; |
| 531 }; | 531 }; |
| 532 | 532 |
| 533 class FakeCCTextureUpdateController : public WebCore::CCTextureUpdateController
{ | 533 class FakeCCTextureUpdateController : public cc::CCTextureUpdateController { |
| 534 public: | 534 public: |
| 535 static PassOwnPtr<FakeCCTextureUpdateController> create(WebCore::CCTextureUp
dateControllerClient* client, WebCore::CCThread* thread, PassOwnPtr<CCTextureUpd
ateQueue> queue, CCResourceProvider* resourceProvider, TextureCopier* copier, Te
xtureUploader* uploader) | 535 static PassOwnPtr<FakeCCTextureUpdateController> create(cc::CCTextureUpdateC
ontrollerClient* client, cc::CCThread* thread, PassOwnPtr<CCTextureUpdateQueue>
queue, CCResourceProvider* resourceProvider, TextureCopier* copier, TextureUploa
der* uploader) |
| 536 { | 536 { |
| 537 return adoptPtr(new FakeCCTextureUpdateController(client, thread, queue,
resourceProvider, copier, uploader)); | 537 return adoptPtr(new FakeCCTextureUpdateController(client, thread, queue,
resourceProvider, copier, uploader)); |
| 538 } | 538 } |
| 539 | 539 |
| 540 void setMonotonicTimeNow(double time) { m_monotonicTimeNow = time; } | 540 void setMonotonicTimeNow(double time) { m_monotonicTimeNow = time; } |
| 541 virtual double monotonicTimeNow() const OVERRIDE { return m_monotonicTimeNow
; } | 541 virtual double monotonicTimeNow() const OVERRIDE { return m_monotonicTimeNow
; } |
| 542 void setUpdateMoreTexturesTime(double time) { m_updateMoreTexturesTime = tim
e; } | 542 void setUpdateMoreTexturesTime(double time) { m_updateMoreTexturesTime = tim
e; } |
| 543 virtual double updateMoreTexturesTime() const OVERRIDE { return m_updateMore
TexturesTime; } | 543 virtual double updateMoreTexturesTime() const OVERRIDE { return m_updateMore
TexturesTime; } |
| 544 void setUpdateMoreTexturesSize(size_t size) { m_updateMoreTexturesSize = siz
e; } | 544 void setUpdateMoreTexturesSize(size_t size) { m_updateMoreTexturesSize = siz
e; } |
| 545 virtual size_t updateMoreTexturesSize() const OVERRIDE { return m_updateMore
TexturesSize; } | 545 virtual size_t updateMoreTexturesSize() const OVERRIDE { return m_updateMore
TexturesSize; } |
| 546 | 546 |
| 547 protected: | 547 protected: |
| 548 FakeCCTextureUpdateController(WebCore::CCTextureUpdateControllerClient* clie
nt, WebCore::CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourc
eProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) | 548 FakeCCTextureUpdateController(cc::CCTextureUpdateControllerClient* client, c
c::CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResourceProvider*
resourceProvider, TextureCopier* copier, TextureUploader* uploader) |
| 549 : WebCore::CCTextureUpdateController(client, thread, queue, resourceProv
ider, copier, uploader) | 549 : cc::CCTextureUpdateController(client, thread, queue, resourceProvider,
copier, uploader) |
| 550 , m_monotonicTimeNow(0) | 550 , m_monotonicTimeNow(0) |
| 551 , m_updateMoreTexturesTime(0) | 551 , m_updateMoreTexturesTime(0) |
| 552 , m_updateMoreTexturesSize(0) { } | 552 , m_updateMoreTexturesSize(0) { } |
| 553 | 553 |
| 554 double m_monotonicTimeNow; | 554 double m_monotonicTimeNow; |
| 555 double m_updateMoreTexturesTime; | 555 double m_updateMoreTexturesTime; |
| 556 size_t m_updateMoreTexturesSize; | 556 size_t m_updateMoreTexturesSize; |
| 557 }; | 557 }; |
| 558 | 558 |
| 559 static void runPendingTask(FakeCCThread* thread, FakeCCTextureUpdateController*
controller) | 559 static void runPendingTask(FakeCCThread* thread, FakeCCTextureUpdateController*
controller) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 676 } |
| 677 | 677 |
| 678 EXPECT_FALSE(thread.hasPendingTask()); | 678 EXPECT_FALSE(thread.hasPendingTask()); |
| 679 EXPECT_TRUE(client.completedCalled()); | 679 EXPECT_TRUE(client.completedCalled()); |
| 680 EXPECT_EQ(2, m_numBeginUploads); | 680 EXPECT_EQ(2, m_numBeginUploads); |
| 681 EXPECT_EQ(2, m_numEndUploads); | 681 EXPECT_EQ(2, m_numEndUploads); |
| 682 EXPECT_EQ(2, m_numTotalUploads); | 682 EXPECT_EQ(2, m_numTotalUploads); |
| 683 } | 683 } |
| 684 | 684 |
| 685 } // namespace | 685 } // namespace |
| OLD | NEW |