Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: cc/CCTextureUpdateControllerTest.cpp

Issue 10947017: Enable removing uploads to evicted textures from texture upload queues. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 virtual void beginUploads() OVERRIDE; 60 virtual void beginUploads() OVERRIDE;
61 virtual void endUploads() OVERRIDE; 61 virtual void endUploads() OVERRIDE;
62 virtual void uploadTexture(cc::CCResourceProvider*, Parameters) OVERRIDE; 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)), m_evicted(false) { }
jamesr 2012/09/19 18:56:37 one initialization per line, please. I think this
ccameron 2012/09/19 20:52:02 Fixed.
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 virtual bool backingResourceWasEvicted() const { return m_evicted; }
73 void evictBackingResource() { m_evicted = true; }
74 private:
75 bool m_evicted;
72 }; 76 };
73 77
74 78
75 class CCTextureUpdateControllerTest : public Test { 79 class CCTextureUpdateControllerTest : public Test {
76 public: 80 public:
77 CCTextureUpdateControllerTest() 81 CCTextureUpdateControllerTest()
78 : m_queue(adoptPtr(new CCTextureUpdateQueue)) 82 : m_queue(adoptPtr(new CCTextureUpdateQueue))
79 , m_uploader(this) 83 , m_uploader(this)
80 , m_compositorInitializer(m_thread.get()) 84 , m_compositorInitializer(m_thread.get())
81 , m_fullUploadCountExpected(0) 85 , m_fullUploadCountExpected(0)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 154 }
151 155
152 protected: 156 protected:
153 virtual void SetUp() 157 virtual void SetUp()
154 { 158 {
155 m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraph icsContext3DForUploadTest(this))); 159 m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraph icsContext3DForUploadTest(this)));
156 DebugScopedSetImplThread implThread; 160 DebugScopedSetImplThread implThread;
157 m_resourceProvider = CCResourceProvider::create(m_context.get(), Unthrot tledUploader); 161 m_resourceProvider = CCResourceProvider::create(m_context.get(), Unthrot tledUploader);
158 } 162 }
159 163
160 void appendFullUploadsToUpdateQueue(int count) 164
165 void appendFullUploadsOfIndexedTextureToUpdateQueue(int count, int textureIn dex)
161 { 166 {
162 m_fullUploadCountExpected += count; 167 m_fullUploadCountExpected += count;
163 m_totalUploadCountExpected += count; 168 m_totalUploadCountExpected += count;
164 169
165 const IntRect rect(0, 0, 300, 150); 170 const IntRect rect(0, 0, 300, 150);
166 const TextureUploader::Parameters upload = { &m_texture, rect, IntSize() }; 171 const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() };
167 for (int i = 0; i < count; i++) 172 for (int i = 0; i < count; i++)
168 m_queue->appendFullUpload(upload); 173 m_queue->appendFullUpload(upload);
169 } 174 }
170 175
171 void appendPartialUploadsToUpdateQueue(int count) 176 void appendFullUploadsToUpdateQueue(int count)
177 {
178 appendFullUploadsOfIndexedTextureToUpdateQueue(count, 0);
179 }
180
181 void appendPartialUploadsOfIndexedTextureToUpdateQueue(int count, int textur eIndex)
172 { 182 {
173 m_partialCountExpected += count; 183 m_partialCountExpected += count;
174 m_totalUploadCountExpected += count; 184 m_totalUploadCountExpected += count;
175 185
176 const IntRect rect(0, 0, 100, 100); 186 const IntRect rect(0, 0, 100, 100);
177 const TextureUploader::Parameters upload = { &m_texture, rect, IntSize() }; 187 const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() };
178 for (int i = 0; i < count; i++) 188 for (int i = 0; i < count; i++)
179 m_queue->appendPartialUpload(upload); 189 m_queue->appendPartialUpload(upload);
180 } 190 }
181 191
192 void appendPartialUploadsToUpdateQueue(int count)
193 {
194 appendPartialUploadsOfIndexedTextureToUpdateQueue(count, 0);
195 }
196
182 void setMaxUploadCountPerUpdate(int count) 197 void setMaxUploadCountPerUpdate(int count)
183 { 198 {
184 m_maxUploadCountPerUpdate = count; 199 m_maxUploadCountPerUpdate = count;
185 } 200 }
186 201
187 protected: 202 protected:
188 // Classes required to interact and test the CCTextureUpdateController 203 // Classes required to interact and test the CCTextureUpdateController
189 OwnPtr<CCGraphicsContext> m_context; 204 OwnPtr<CCGraphicsContext> m_context;
190 OwnPtr<CCResourceProvider> m_resourceProvider; 205 OwnPtr<CCResourceProvider> m_resourceProvider;
191 OwnPtr<CCTextureUpdateQueue> m_queue; 206 OwnPtr<CCTextureUpdateQueue> m_queue;
192 TextureForUploadTest m_texture; 207 TextureForUploadTest m_textures[4];
193 TextureUploaderForUploadTest m_uploader; 208 TextureUploaderForUploadTest m_uploader;
194 OwnPtr<WebThread> m_thread; 209 OwnPtr<WebThread> m_thread;
195 WebCompositorInitializer m_compositorInitializer; 210 WebCompositorInitializer m_compositorInitializer;
196 211
197 212
198 // Properties / expectations of this test 213 // Properties / expectations of this test
199 int m_fullUploadCountExpected; 214 int m_fullUploadCountExpected;
200 int m_partialCountExpected; 215 int m_partialCountExpected;
201 int m_totalUploadCountExpected; 216 int m_totalUploadCountExpected;
202 int m_maxUploadCountPerUpdate; 217 int m_maxUploadCountPerUpdate;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 runPendingTask(&thread, controller.get()); 498 runPendingTask(&thread, controller.get());
484 } 499 }
485 500
486 EXPECT_FALSE(thread.hasPendingTask()); 501 EXPECT_FALSE(thread.hasPendingTask());
487 EXPECT_TRUE(client.readyToFinalizeCalled()); 502 EXPECT_TRUE(client.readyToFinalizeCalled());
488 EXPECT_EQ(2, m_numBeginUploads); 503 EXPECT_EQ(2, m_numBeginUploads);
489 EXPECT_EQ(2, m_numEndUploads); 504 EXPECT_EQ(2, m_numEndUploads);
490 EXPECT_EQ(2, m_numTotalUploads); 505 EXPECT_EQ(2, m_numTotalUploads);
491 } 506 }
492 507
508 TEST_F(CCTextureUpdateControllerTest, ClearUploadsToEvictedResources)
509 {
510 appendFullUploadsOfIndexedTextureToUpdateQueue(1, 0);
511 appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 1);
512 appendFullUploadsOfIndexedTextureToUpdateQueue(1, 2);
513 appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 3);
514 DebugScopedSetImplThread implThread;
515
516 m_queue->clearUploadsToEvictedResources();
517 EXPECT_EQ(2u, m_queue->fullUploadSize());
518 EXPECT_EQ(2u, m_queue->partialUploadSize());
519
520 m_textures[0].evictBackingResource();
521 m_queue->clearUploadsToEvictedResources();
522 EXPECT_EQ(1u, m_queue->fullUploadSize());
523 EXPECT_EQ(2u, m_queue->partialUploadSize());
524
525 m_textures[3].evictBackingResource();
526 m_queue->clearUploadsToEvictedResources();
527 EXPECT_EQ(1u, m_queue->fullUploadSize());
528 EXPECT_EQ(1u, m_queue->partialUploadSize());
529
530 m_textures[2].evictBackingResource();
531 m_queue->clearUploadsToEvictedResources();
532 EXPECT_EQ(0u, m_queue->fullUploadSize());
533 EXPECT_EQ(1u, m_queue->partialUploadSize());
534
535 m_textures[1].evictBackingResource();
536 m_queue->clearUploadsToEvictedResources();
537 EXPECT_EQ(0u, m_queue->fullUploadSize());
538 EXPECT_EQ(0u, m_queue->partialUploadSize());
539 }
540
493 } // namespace 541 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698