diff options
author | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-19 23:59:01 +0000 |
---|---|---|
committer | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-19 23:59:01 +0000 |
commit | 77a60b9b04457ab552e05751a0b863d6be875cc5 (patch) | |
tree | d5fbb5d77182954c12b81ae820637a34301f35e2 /cc/CCTextureUpdateControllerTest.cpp | |
parent | 3196e42a57b359527039fff8873c5f6674d0d9a9 (diff) | |
download | chromium_src-77a60b9b04457ab552e05751a0b863d6be875cc5.zip chromium_src-77a60b9b04457ab552e05751a0b863d6be875cc5.tar.gz chromium_src-77a60b9b04457ab552e05751a0b863d6be875cc5.tar.bz2 |
Allow deletion of some (as opposed to all) textures on the impl thread.
Enable removing uploads to evicted textures from texture upload queues. Track whether not a CCPrioritizedTexture::Backing has been evicted in the structure itself. Purge texture upload queues of evicted backings instead of clearing the entire queue.
Added CCTextureUpdateControllerTest.ClearUploadsToEvictedResources to test the new eviction logic.
BUG=134750
Review URL: https://chromiumcodereview.appspot.com/10947017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/CCTextureUpdateControllerTest.cpp')
-rw-r--r-- | cc/CCTextureUpdateControllerTest.cpp | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/cc/CCTextureUpdateControllerTest.cpp b/cc/CCTextureUpdateControllerTest.cpp index 2eeaa9d..eb6792e 100644 --- a/cc/CCTextureUpdateControllerTest.cpp +++ b/cc/CCTextureUpdateControllerTest.cpp @@ -67,8 +67,16 @@ private: class TextureForUploadTest : public LayerTextureUpdater::Texture { public: - TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritizedTexture>(0)) { } + TextureForUploadTest() + : LayerTextureUpdater::Texture(nullptr) + , m_evicted(false) + { + } virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, const IntSize& destOffset) { } + virtual bool backingResourceWasEvicted() const { return m_evicted; } + void evictBackingResource() { m_evicted = true; } +private: + bool m_evicted; }; @@ -157,28 +165,39 @@ protected: m_resourceProvider = CCResourceProvider::create(m_context.get(), UnthrottledUploader); } - void appendFullUploadsToUpdateQueue(int count) + + void appendFullUploadsOfIndexedTextureToUpdateQueue(int count, int textureIndex) { m_fullUploadCountExpected += count; m_totalUploadCountExpected += count; const IntRect rect(0, 0, 300, 150); - const TextureUploader::Parameters upload = { &m_texture, rect, IntSize() }; + const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() }; for (int i = 0; i < count; i++) m_queue->appendFullUpload(upload); } - void appendPartialUploadsToUpdateQueue(int count) + void appendFullUploadsToUpdateQueue(int count) + { + appendFullUploadsOfIndexedTextureToUpdateQueue(count, 0); + } + + void appendPartialUploadsOfIndexedTextureToUpdateQueue(int count, int textureIndex) { m_partialCountExpected += count; m_totalUploadCountExpected += count; const IntRect rect(0, 0, 100, 100); - const TextureUploader::Parameters upload = { &m_texture, rect, IntSize() }; + const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() }; for (int i = 0; i < count; i++) m_queue->appendPartialUpload(upload); } + void appendPartialUploadsToUpdateQueue(int count) + { + appendPartialUploadsOfIndexedTextureToUpdateQueue(count, 0); + } + void setMaxUploadCountPerUpdate(int count) { m_maxUploadCountPerUpdate = count; @@ -189,7 +208,7 @@ protected: OwnPtr<CCGraphicsContext> m_context; OwnPtr<CCResourceProvider> m_resourceProvider; OwnPtr<CCTextureUpdateQueue> m_queue; - TextureForUploadTest m_texture; + TextureForUploadTest m_textures[4]; TextureUploaderForUploadTest m_uploader; OwnPtr<WebThread> m_thread; WebCompositorInitializer m_compositorInitializer; @@ -496,4 +515,37 @@ TEST_F(CCTextureUpdateControllerTest, UpdatesCompleteInFiniteTime) EXPECT_EQ(2, m_numTotalUploads); } +TEST_F(CCTextureUpdateControllerTest, ClearUploadsToEvictedResources) +{ + appendFullUploadsOfIndexedTextureToUpdateQueue(1, 0); + appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 1); + appendFullUploadsOfIndexedTextureToUpdateQueue(1, 2); + appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 3); + DebugScopedSetImplThread implThread; + + m_queue->clearUploadsToEvictedResources(); + EXPECT_EQ(2u, m_queue->fullUploadSize()); + EXPECT_EQ(2u, m_queue->partialUploadSize()); + + m_textures[0].evictBackingResource(); + m_queue->clearUploadsToEvictedResources(); + EXPECT_EQ(1u, m_queue->fullUploadSize()); + EXPECT_EQ(2u, m_queue->partialUploadSize()); + + m_textures[3].evictBackingResource(); + m_queue->clearUploadsToEvictedResources(); + EXPECT_EQ(1u, m_queue->fullUploadSize()); + EXPECT_EQ(1u, m_queue->partialUploadSize()); + + m_textures[2].evictBackingResource(); + m_queue->clearUploadsToEvictedResources(); + EXPECT_EQ(0u, m_queue->fullUploadSize()); + EXPECT_EQ(1u, m_queue->partialUploadSize()); + + m_textures[1].evictBackingResource(); + m_queue->clearUploadsToEvictedResources(); + EXPECT_EQ(0u, m_queue->fullUploadSize()); + EXPECT_EQ(0u, m_queue->partialUploadSize()); +} + } // namespace |