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

Side by Side Diff: cc/CCTextureUpdateControllerTest.cpp

Issue 11074009: cc: Remove LayerTextureUpdater::Texture::updateRect() callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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(nullptr)
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 66
81 class CCTextureUpdateControllerTest : public Test { 67 class CCTextureUpdateControllerTest : public Test {
82 public: 68 public:
83 CCTextureUpdateControllerTest() 69 CCTextureUpdateControllerTest()
84 : m_queue(adoptPtr(new CCTextureUpdateQueue)) 70 : m_queue(adoptPtr(new CCTextureUpdateQueue))
85 , m_uploader(this) 71 , m_uploader(this)
86 , m_compositorInitializer(m_thread.get()) 72 , m_compositorInitializer(m_thread.get())
87 , m_fullUploadCountExpected(0) 73 , m_fullUploadCountExpected(0)
88 , m_partialCountExpected(0) 74 , m_partialCountExpected(0)
89 , m_totalUploadCountExpected(0) 75 , m_totalUploadCountExpected(0)
(...skipping 28 matching lines...) Expand all
118 m_numDanglingUploads++; 104 m_numDanglingUploads++;
119 m_numTotalUploads++; 105 m_numTotalUploads++;
120 } 106 }
121 107
122 protected: 108 protected:
123 virtual void SetUp() 109 virtual void SetUp()
124 { 110 {
125 m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraph icsContext3DForUploadTest(this))); 111 m_context = FakeWebCompositorOutputSurface::create(adoptPtr(new WebGraph icsContext3DForUploadTest(this)));
126 DebugScopedSetImplThread implThread; 112 DebugScopedSetImplThread implThread;
127 m_resourceProvider = CCResourceProvider::create(m_context.get()); 113 m_resourceProvider = CCResourceProvider::create(m_context.get());
114 for (int i = 0; i < 4; i++)
115 m_textures[i] = CCPrioritizedTexture::create(
116 NULL, IntSize(256, 256), GL_RGBA);
128 } 117 }
129 118
130 119
131 void appendFullUploadsOfIndexedTextureToUpdateQueue(int count, int textureIn dex) 120 void appendFullUploadsOfIndexedTextureToUpdateQueue(int count, int textureIn dex)
132 { 121 {
133 m_fullUploadCountExpected += count; 122 m_fullUploadCountExpected += count;
134 m_totalUploadCountExpected += count; 123 m_totalUploadCountExpected += count;
135 124
136 const IntRect rect(0, 0, 300, 150); 125 const IntRect rect(0, 0, 300, 150);
137 const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() }; 126 const TextureUploader::Parameters upload = { m_textures[textureIndex].ge t(), NULL, NULL, { rect, rect, IntSize() } };
138 for (int i = 0; i < count; i++) 127 for (int i = 0; i < count; i++)
139 m_queue->appendFullUpload(upload); 128 m_queue->appendFullUpload(upload);
140 } 129 }
141 130
142 void appendFullUploadsToUpdateQueue(int count) 131 void appendFullUploadsToUpdateQueue(int count)
143 { 132 {
144 appendFullUploadsOfIndexedTextureToUpdateQueue(count, 0); 133 appendFullUploadsOfIndexedTextureToUpdateQueue(count, 0);
145 } 134 }
146 135
147 void appendPartialUploadsOfIndexedTextureToUpdateQueue(int count, int textur eIndex) 136 void appendPartialUploadsOfIndexedTextureToUpdateQueue(int count, int textur eIndex)
148 { 137 {
149 m_partialCountExpected += count; 138 m_partialCountExpected += count;
150 m_totalUploadCountExpected += count; 139 m_totalUploadCountExpected += count;
151 140
152 const IntRect rect(0, 0, 100, 100); 141 const IntRect rect(0, 0, 100, 100);
153 const TextureUploader::Parameters upload = { &m_textures[textureIndex], rect, IntSize() }; 142 const TextureUploader::Parameters upload = { m_textures[textureIndex].ge t(), NULL, NULL, { rect, rect, IntSize() } };
154 for (int i = 0; i < count; i++) 143 for (int i = 0; i < count; i++)
155 m_queue->appendPartialUpload(upload); 144 m_queue->appendPartialUpload(upload);
156 } 145 }
157 146
158 void appendPartialUploadsToUpdateQueue(int count) 147 void appendPartialUploadsToUpdateQueue(int count)
159 { 148 {
160 appendPartialUploadsOfIndexedTextureToUpdateQueue(count, 0); 149 appendPartialUploadsOfIndexedTextureToUpdateQueue(count, 0);
161 } 150 }
162 151
163 void setMaxUploadCountPerUpdate(int count) 152 void setMaxUploadCountPerUpdate(int count)
(...skipping 11 matching lines...) Expand all
175 m_resourceProvider.get(), 164 m_resourceProvider.get(),
176 &m_uploader); 165 &m_uploader);
177 updateController->finalize(); 166 updateController->finalize();
178 } 167 }
179 168
180 protected: 169 protected:
181 // Classes required to interact and test the CCTextureUpdateController 170 // Classes required to interact and test the CCTextureUpdateController
182 OwnPtr<CCGraphicsContext> m_context; 171 OwnPtr<CCGraphicsContext> m_context;
183 OwnPtr<CCResourceProvider> m_resourceProvider; 172 OwnPtr<CCResourceProvider> m_resourceProvider;
184 OwnPtr<CCTextureUpdateQueue> m_queue; 173 OwnPtr<CCTextureUpdateQueue> m_queue;
185 TextureForUploadTest m_textures[4]; 174 OwnPtr<CCPrioritizedTexture> m_textures[4];
186 TextureUploaderForUploadTest m_uploader; 175 TextureUploaderForUploadTest m_uploader;
187 OwnPtr<WebThread> m_thread; 176 OwnPtr<WebThread> m_thread;
188 WebCompositorInitializer m_compositorInitializer; 177 WebCompositorInitializer m_compositorInitializer;
189 178
190 179
191 // Properties / expectations of this test 180 // Properties / expectations of this test
192 int m_fullUploadCountExpected; 181 int m_fullUploadCountExpected;
193 int m_partialCountExpected; 182 int m_partialCountExpected;
194 int m_totalUploadCountExpected; 183 int m_totalUploadCountExpected;
195 int m_maxUploadCountPerUpdate; 184 int m_maxUploadCountPerUpdate;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 appendFullUploadsOfIndexedTextureToUpdateQueue(1, 0); 466 appendFullUploadsOfIndexedTextureToUpdateQueue(1, 0);
478 appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 1); 467 appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 1);
479 appendFullUploadsOfIndexedTextureToUpdateQueue(1, 2); 468 appendFullUploadsOfIndexedTextureToUpdateQueue(1, 2);
480 appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 3); 469 appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 3);
481 DebugScopedSetImplThread implThread; 470 DebugScopedSetImplThread implThread;
482 471
483 m_queue->clearUploadsToEvictedResources(); 472 m_queue->clearUploadsToEvictedResources();
484 EXPECT_EQ(2u, m_queue->fullUploadSize()); 473 EXPECT_EQ(2u, m_queue->fullUploadSize());
485 EXPECT_EQ(2u, m_queue->partialUploadSize()); 474 EXPECT_EQ(2u, m_queue->partialUploadSize());
486 475
476 #if 0
487 m_textures[0].evictBackingResource(); 477 m_textures[0].evictBackingResource();
488 m_queue->clearUploadsToEvictedResources(); 478 m_queue->clearUploadsToEvictedResources();
489 EXPECT_EQ(1u, m_queue->fullUploadSize()); 479 EXPECT_EQ(1u, m_queue->fullUploadSize());
490 EXPECT_EQ(2u, m_queue->partialUploadSize()); 480 EXPECT_EQ(2u, m_queue->partialUploadSize());
491 481
492 m_textures[3].evictBackingResource(); 482 m_textures[3].evictBackingResource();
493 m_queue->clearUploadsToEvictedResources(); 483 m_queue->clearUploadsToEvictedResources();
494 EXPECT_EQ(1u, m_queue->fullUploadSize()); 484 EXPECT_EQ(1u, m_queue->fullUploadSize());
495 EXPECT_EQ(1u, m_queue->partialUploadSize()); 485 EXPECT_EQ(1u, m_queue->partialUploadSize());
496 486
497 m_textures[2].evictBackingResource(); 487 m_textures[2].evictBackingResource();
498 m_queue->clearUploadsToEvictedResources(); 488 m_queue->clearUploadsToEvictedResources();
499 EXPECT_EQ(0u, m_queue->fullUploadSize()); 489 EXPECT_EQ(0u, m_queue->fullUploadSize());
500 EXPECT_EQ(1u, m_queue->partialUploadSize()); 490 EXPECT_EQ(1u, m_queue->partialUploadSize());
501 491
502 m_textures[1].evictBackingResource(); 492 m_textures[1].evictBackingResource();
503 m_queue->clearUploadsToEvictedResources(); 493 m_queue->clearUploadsToEvictedResources();
504 EXPECT_EQ(0u, m_queue->fullUploadSize()); 494 EXPECT_EQ(0u, m_queue->fullUploadSize());
505 EXPECT_EQ(0u, m_queue->partialUploadSize()); 495 EXPECT_EQ(0u, m_queue->partialUploadSize());
496 #endif
497
506 } 498 }
507 499
508 } // namespace 500 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698