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

Side by Side Diff: cc/texture_update_controller_unittest.cc

Issue 11074009: cc: Remove LayerTextureUpdater::Texture::updateRect() callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 2 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
« no previous file with comments | « cc/texture_update_controller.cc ('k') | cc/texture_update_queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 uploadTexture(cc::CCResourceProvider*, Parameters) OVERRIDE; 60 virtual void uploadTexture(cc::CCResourceProvider*, Parameters) OVERRIDE;
61 61
62 private: 62 private:
63 CCTextureUpdateControllerTest* m_test; 63 CCTextureUpdateControllerTest* m_test;
64 }; 64 };
65 65
66 class TextureForUploadTest : public LayerTextureUpdater::Texture {
67 public:
68 TextureForUploadTest()
69 : LayerTextureUpdater::Texture(scoped_ptr<CCPrioritizedTexture>())
70 , m_evicted(false)
71 {
72 }
73 virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, cons t IntSize& destOffset) { }
74 virtual bool backingResourceWasEvicted() const { return m_evicted; }
75 void evictBackingResource() { m_evicted = true; }
76 private:
77 bool m_evicted;
78 };
79
80
81 class CCTextureUpdateControllerTest : public Test { 66 class CCTextureUpdateControllerTest : public Test {
82 public: 67 public:
83 CCTextureUpdateControllerTest() 68 CCTextureUpdateControllerTest()
84 : m_queue(adoptPtr(new CCTextureUpdateQueue)) 69 : m_queue(adoptPtr(new CCTextureUpdateQueue))
85 , m_uploader(this) 70 , m_uploader(this)
86 , m_compositorInitializer(m_thread.get()) 71 , m_compositorInitializer(m_thread.get())
87 , m_fullUploadCountExpected(0) 72 , m_fullUploadCountExpected(0)
88 , m_partialCountExpected(0) 73 , m_partialCountExpected(0)
89 , m_totalUploadCountExpected(0) 74 , m_totalUploadCountExpected(0)
90 , m_maxUploadCountPerUpdate(0) 75 , m_maxUploadCountPerUpdate(0)
(...skipping 27 matching lines...) Expand all
118 m_numDanglingUploads++; 103 m_numDanglingUploads++;
119 m_numTotalUploads++; 104 m_numTotalUploads++;
120 } 105 }
121 106
122 protected: 107 protected:
123 virtual void SetUp() 108 virtual void SetUp()
124 { 109 {
125 m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraph icsContext3DForUploadTest(this))); 110 m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraph icsContext3DForUploadTest(this)));
126 DebugScopedSetImplThread implThread; 111 DebugScopedSetImplThread implThread;
127 m_resourceProvider = CCResourceProvider::create(m_context.get()); 112 m_resourceProvider = CCResourceProvider::create(m_context.get());
113 for (int i = 0; i < 4; i++)
114 m_textures[i] = CCPrioritizedTexture::create(
115 NULL, IntSize(256, 256), GL_RGBA);
128 } 116 }
129 117
130 118
131 void appendFullUploadsOfIndexedTextureToUpdateQueue(int count, int textureIn dex) 119 void appendFullUploadsOfIndexedTextureToUpdateQueue(int count, int textureIn dex)
132 { 120 {
133 m_fullUploadCountExpected += count; 121 m_fullUploadCountExpected += count;
134 m_totalUploadCountExpected += count; 122 m_totalUploadCountExpected += count;
135 123
136 const IntRect rect(0, 0, 300, 150); 124 const IntRect rect(0, 0, 300, 150);
137 const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() }; 125 const TextureUploader::Parameters upload = { m_textures[textureIndex].ge t(), NULL, NULL, { rect, rect, IntSize() } };
138 for (int i = 0; i < count; i++) 126 for (int i = 0; i < count; i++)
139 m_queue->appendFullUpload(upload); 127 m_queue->appendFullUpload(upload);
140 } 128 }
141 129
142 void appendFullUploadsToUpdateQueue(int count) 130 void appendFullUploadsToUpdateQueue(int count)
143 { 131 {
144 appendFullUploadsOfIndexedTextureToUpdateQueue(count, 0); 132 appendFullUploadsOfIndexedTextureToUpdateQueue(count, 0);
145 } 133 }
146 134
147 void appendPartialUploadsOfIndexedTextureToUpdateQueue(int count, int textur eIndex) 135 void appendPartialUploadsOfIndexedTextureToUpdateQueue(int count, int textur eIndex)
148 { 136 {
149 m_partialCountExpected += count; 137 m_partialCountExpected += count;
150 m_totalUploadCountExpected += count; 138 m_totalUploadCountExpected += count;
151 139
152 const IntRect rect(0, 0, 100, 100); 140 const IntRect rect(0, 0, 100, 100);
153 const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() }; 141 const TextureUploader::Parameters upload = { m_textures[textureIndex].ge t(), NULL, NULL, { rect, rect, IntSize() } };
154 for (int i = 0; i < count; i++) 142 for (int i = 0; i < count; i++)
155 m_queue->appendPartialUpload(upload); 143 m_queue->appendPartialUpload(upload);
156 } 144 }
157 145
158 void appendPartialUploadsToUpdateQueue(int count) 146 void appendPartialUploadsToUpdateQueue(int count)
159 { 147 {
160 appendPartialUploadsOfIndexedTextureToUpdateQueue(count, 0); 148 appendPartialUploadsOfIndexedTextureToUpdateQueue(count, 0);
161 } 149 }
162 150
163 void setMaxUploadCountPerUpdate(int count) 151 void setMaxUploadCountPerUpdate(int count)
(...skipping 11 matching lines...) Expand all
175 m_resourceProvider.get(), 163 m_resourceProvider.get(),
176 &m_uploader); 164 &m_uploader);
177 updateController->finalize(); 165 updateController->finalize();
178 } 166 }
179 167
180 protected: 168 protected:
181 // Classes required to interact and test the CCTextureUpdateController 169 // Classes required to interact and test the CCTextureUpdateController
182 scoped_ptr<CCGraphicsContext> m_context; 170 scoped_ptr<CCGraphicsContext> m_context;
183 OwnPtr<CCResourceProvider> m_resourceProvider; 171 OwnPtr<CCResourceProvider> m_resourceProvider;
184 OwnPtr<CCTextureUpdateQueue> m_queue; 172 OwnPtr<CCTextureUpdateQueue> m_queue;
185 TextureForUploadTest m_textures[4]; 173 scoped_ptr<CCPrioritizedTexture> m_textures[4];
186 TextureUploaderForUploadTest m_uploader; 174 TextureUploaderForUploadTest m_uploader;
187 OwnPtr<WebThread> m_thread; 175 OwnPtr<WebThread> m_thread;
188 WebCompositorInitializer m_compositorInitializer; 176 WebCompositorInitializer m_compositorInitializer;
189 177
190 178
191 // Properties / expectations of this test 179 // Properties / expectations of this test
192 int m_fullUploadCountExpected; 180 int m_fullUploadCountExpected;
193 int m_partialCountExpected; 181 int m_partialCountExpected;
194 int m_totalUploadCountExpected; 182 int m_totalUploadCountExpected;
195 int m_maxUploadCountPerUpdate; 183 int m_maxUploadCountPerUpdate;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 453
466 if (thread.hasPendingTask()) 454 if (thread.hasPendingTask())
467 runPendingTask(&thread, controller.get()); 455 runPendingTask(&thread, controller.get());
468 } 456 }
469 457
470 EXPECT_FALSE(thread.hasPendingTask()); 458 EXPECT_FALSE(thread.hasPendingTask());
471 EXPECT_TRUE(client.readyToFinalizeCalled()); 459 EXPECT_TRUE(client.readyToFinalizeCalled());
472 EXPECT_EQ(2, m_numTotalUploads); 460 EXPECT_EQ(2, m_numTotalUploads);
473 } 461 }
474 462
475 TEST_F(CCTextureUpdateControllerTest, ClearUploadsToEvictedResources)
476 {
477 appendFullUploadsOfIndexedTextureToUpdateQueue(1, 0);
478 appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 1);
479 appendFullUploadsOfIndexedTextureToUpdateQueue(1, 2);
480 appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 3);
481 DebugScopedSetImplThread implThread;
482
483 m_queue->clearUploadsToEvictedResources();
484 EXPECT_EQ(2u, m_queue->fullUploadSize());
485 EXPECT_EQ(2u, m_queue->partialUploadSize());
486
487 m_textures[0].evictBackingResource();
488 m_queue->clearUploadsToEvictedResources();
489 EXPECT_EQ(1u, m_queue->fullUploadSize());
490 EXPECT_EQ(2u, m_queue->partialUploadSize());
491
492 m_textures[3].evictBackingResource();
493 m_queue->clearUploadsToEvictedResources();
494 EXPECT_EQ(1u, m_queue->fullUploadSize());
495 EXPECT_EQ(1u, m_queue->partialUploadSize());
496
497 m_textures[2].evictBackingResource();
498 m_queue->clearUploadsToEvictedResources();
499 EXPECT_EQ(0u, m_queue->fullUploadSize());
500 EXPECT_EQ(1u, m_queue->partialUploadSize());
501
502 m_textures[1].evictBackingResource();
503 m_queue->clearUploadsToEvictedResources();
504 EXPECT_EQ(0u, m_queue->fullUploadSize());
505 EXPECT_EQ(0u, m_queue->partialUploadSize());
506 }
507
508 } // namespace 463 } // namespace
OLDNEW
« no previous file with comments | « cc/texture_update_controller.cc ('k') | cc/texture_update_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698