Changeset 107177 in webkit
- Timestamp:
- Feb 8, 2012 9:26:00 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107176 r107177 1 2012-02-08 David Reveman <reveman@chromium.org> 2 3 [Chromium] Avoid unnecessary full tile updates without breaking atomicity of commits. 4 https://bugs.webkit.org/show_bug.cgi?id=76740 5 6 Reviewed by James Robinson. 7 8 Allow the final batch of texture uploads to be performed without 9 allocating new textures and re-painting complete tiles. 10 11 This patch is tested by the following unit test: 12 - CCLayerTreeHostTestAtomicCommitWithPartialUpdate.runMultiThread 13 - TiledLayerChromiumTest.partialUpdates 14 15 * platform/graphics/chromium/TiledLayerChromium.cpp: 16 (WebCore::UpdatableTile::UpdatableTile): 17 (UpdatableTile): 18 (WebCore::TiledLayerChromium::updateCompositorResources): 19 (WebCore): 20 (WebCore::TiledLayerChromium::tileOnlyNeedsPartialUpdate): 21 (WebCore::TiledLayerChromium::tileNeedsBufferedUpdate): 22 (WebCore::TiledLayerChromium::prepareToUpdateTiles): 23 * platform/graphics/chromium/TiledLayerChromium.h: 24 (TiledLayerChromium): 25 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 26 (WebCore::CCLayerTreeHost::CCLayerTreeHost): 27 (WebCore::CCLayerTreeHost::initializeLayerRenderer): 28 (WebCore::CCLayerTreeHost::updateLayers): 29 (WebCore::CCLayerTreeHost::requestPartialTextureUpdate): 30 (WebCore): 31 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 32 (WebCore::CCSettings::CCSettings): 33 (CCSettings): 34 (CCLayerTreeHost): 35 * platform/graphics/chromium/cc/CCProxy.h: 36 (CCProxy): 37 * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: 38 (WebCore::CCSingleThreadProxy::doCommit): 39 * platform/graphics/chromium/cc/CCSingleThreadProxy.h: 40 (WebCore::CCSingleThreadProxy::maxPartialTextureUpdates): 41 * platform/graphics/chromium/cc/CCTextureUpdater.cpp: 42 (WebCore::CCTextureUpdater::append): 43 (WebCore): 44 (WebCore::CCTextureUpdater::appendPartial): 45 (WebCore::CCTextureUpdater::hasMoreUpdates): 46 (WebCore::CCTextureUpdater::update): 47 (WebCore::CCTextureUpdater::clear): 48 * platform/graphics/chromium/cc/CCTextureUpdater.h: 49 (CCTextureUpdater): 50 * platform/graphics/chromium/cc/CCThreadProxy.cpp: 51 (WTF): 52 (WebCore::CCThreadProxy::scheduledActionUpdateMoreResources): 53 (WebCore::CCThreadProxy::maxPartialTextureUpdates): 54 * platform/graphics/chromium/cc/CCThreadProxy.h: 55 (CCThreadProxy): 56 1 57 2012-02-07 MORITA Hajime <morrita@google.com> 2 58 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
r106891 r107177 54 54 WTF_MAKE_NONCOPYABLE(UpdatableTile); 55 55 public: 56 explicit UpdatableTile(PassOwnPtr<LayerTextureUpdater::Texture> texture) : m_texture(texture) { } 56 explicit UpdatableTile(PassOwnPtr<LayerTextureUpdater::Texture> texture) 57 : m_partialUpdate(false) 58 , m_texture(texture) 59 { 60 } 57 61 58 62 LayerTextureUpdater::Texture* texture() { return m_texture.get(); } … … 69 73 IntRect m_updateRect; 70 74 IntRect m_opaqueRect; 75 bool m_partialUpdate; 71 76 private: 72 77 OwnPtr<LayerTextureUpdater::Texture> m_texture; … … 211 216 CRASH(); 212 217 213 updater.append(tile->texture(), sourceRect, destRect); 218 if (tile->m_partialUpdate) 219 updater.appendPartial(tile->texture(), sourceRect, destRect); 220 else 221 updater.append(tile->texture(), sourceRect, destRect); 214 222 } 215 223 } … … 352 360 } 353 361 362 // Returns true if tile is dirty and only part of it needs to be updated. 363 bool TiledLayerChromium::tileOnlyNeedsPartialUpdate(UpdatableTile* tile) 364 { 365 if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) 366 return false; 367 368 if (!tile->isDirty()) 369 return false; 370 371 return !tile->m_dirtyRect.contains(m_tiler->tileRect(tile)); 372 } 373 374 // Dirty tiles with valid textures needs buffered update to guarantee that 375 // we don't modify textures currently used for drawing by the impl thread. 376 bool TiledLayerChromium::tileNeedsBufferedUpdate(UpdatableTile* tile) 377 { 378 // No impl thread?. 379 if (!CCProxy::hasImplThread()) 380 return false; 381 382 if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) 383 return false; 384 385 if (!tile->isDirty()) 386 return false; 387 388 return true; 389 } 390 354 391 void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int right, int bottom) 355 392 { … … 358 395 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); 359 396 tile->m_updateRect = IntRect(); 397 tile->m_partialUpdate = false; 360 398 } 361 399 … … 373 411 tile = createTile(i, j); 374 412 375 // Do post commit deletion of current texture when partial texture 376 // updates are not used. 377 if (tile->isDirty() && layerTreeHost() && !layerTreeHost()->settings().partialTextureUpdates) 413 // FIXME: Decide if partial update should be allowed based on cost 414 // of update. https://bugs.webkit.org/show_bug.cgi?id=77376 415 if (tileOnlyNeedsPartialUpdate(tile) && layerTreeHost() && layerTreeHost()->requestPartialTextureUpdate()) 416 tile->m_partialUpdate = true; 417 else if (tileNeedsBufferedUpdate(tile) && layerTreeHost()) 378 418 layerTreeHost()->deleteTextureAfterCommit(tile->managedTexture()->steal()); 379 419 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
r106891 r107177 108 108 void setTilingOption(TilingOption); 109 109 110 bool tileOnlyNeedsPartialUpdate(UpdatableTile*); 111 bool tileNeedsBufferedUpdate(UpdatableTile*); 112 110 113 void prepareToUpdateTiles(bool idle, int left, int top, int right, int bottom); 111 114 IntRect idlePaintRect(const IntRect& visibleLayerRect); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r106986 r107177 40 40 #include "cc/CCThreadProxy.h" 41 41 42 using namespace std; 43 42 44 namespace { 43 45 static int numLayerTreeInstances; … … 72 74 , m_maxPageScale(1) 73 75 , m_triggerIdlePaints(true) 76 , m_partialTextureUpdateRequests(0) 74 77 { 75 78 ASSERT(CCProxy::isMainThread()); … … 121 124 122 125 // Update m_settings based on partial update capability. 123 m_settings. partialTextureUpdates = m_settings.partialTextureUpdates && m_proxy->partialTextureUpdateCapability();126 m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates()); 124 127 125 128 m_contentsTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()), … … 415 418 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, identityMatrix, identityMatrix, m_updateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize); 416 419 } 420 421 // Reset partial texture update requests. 422 m_partialTextureUpdateRequests = 0; 417 423 418 424 reserveTextures(); … … 624 630 } 625 631 632 bool CCLayerTreeHost::requestPartialTextureUpdate() 633 { 634 if (m_partialTextureUpdateRequests >= m_settings.maxPartialTextureUpdates) 635 return false; 636 637 m_partialTextureUpdateRequests++; 638 return true; 639 } 640 626 641 void CCLayerTreeHost::deleteTextureAfterCommit(PassOwnPtr<ManagedTexture> texture) 627 642 { -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r106986 r107177 34 34 #include "cc/CCProxy.h" 35 35 36 #include <limits> 36 37 #include <wtf/HashMap.h> 37 38 #include <wtf/PassOwnPtr.h> … … 75 76 , perTilePainting(false) 76 77 , partialSwapEnabled(false) 77 , partialTextureUpdates(true) { }78 , maxPartialTextureUpdates(std::numeric_limits<size_t>::max()) { } 78 79 79 80 bool acceleratePainting; … … 84 85 bool perTilePainting; 85 86 bool partialSwapEnabled; 86 bool partialTextureUpdates;87 size_t maxPartialTextureUpdates; 87 88 }; 88 89 … … 193 194 void stopRateLimiter(GraphicsContext3D*); 194 195 196 bool requestPartialTextureUpdate(); 195 197 void deleteTextureAfterCommit(PassOwnPtr<ManagedTexture>); 196 198 … … 244 246 245 247 TextureList m_deleteTextureAfterCommitList; 248 size_t m_partialTextureUpdateRequests; 246 249 }; 247 250 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h
r106700 r107177 81 81 virtual void stop() = 0; // Must be called before deleting the proxy. 82 82 83 // Whether sub-regions of textures can be updated or if complete texture 84 // updates are required. 85 virtual bool partialTextureUpdateCapability() const = 0; 83 // Maximum number of sub-region texture updates supported for each commit. 84 virtual size_t maxPartialTextureUpdates() const = 0; 86 85 87 86 // Debug hooks -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
r107161 r107177 34 34 #include <wtf/CurrentTime.h> 35 35 36 using namespace std; 36 37 using namespace WTF; 37 38 … … 173 174 CCTextureUpdater updater(m_layerTreeHostImpl->contentsTextureAllocator()); 174 175 m_layerTreeHost->updateCompositorResources(m_layerTreeHostImpl->context(), updater); 175 while (updater.update(m_layerTreeHostImpl->context(), 1)) { } 176 updater.update(m_layerTreeHostImpl->context(), numeric_limits<size_t>::max()); 177 ASSERT(!updater.hasMoreUpdates()); 176 178 m_layerTreeHostImpl->setVisible(m_layerTreeHost->visible()); 177 179 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
r106986 r107177 29 29 #include "cc/CCLayerTreeHostImpl.h" 30 30 #include "cc/CCProxy.h" 31 #include <limits> 31 32 #include <wtf/OwnPtr.h> 32 33 … … 56 57 virtual void start(); 57 58 virtual void stop(); 58 virtual bool partialTextureUpdateCapability() const { return true; }59 virtual size_t maxPartialTextureUpdates() const { return std::numeric_limits<size_t>::max(); } 59 60 60 61 // CCLayerTreeHostImplClient implementation -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp
r101600 r107177 49 49 } 50 50 51 void CCTextureUpdater::append(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect )51 void CCTextureUpdater::append(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect, Vector<UpdateEntry>& entries) 52 52 { 53 53 ASSERT(texture); … … 57 57 entry.m_sourceRect = sourceRect; 58 58 entry.m_destRect = destRect; 59 m_entries.append(entry); 59 entries.append(entry); 60 } 61 62 void CCTextureUpdater::append(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) 63 { 64 append(texture, sourceRect, destRect, m_entries); 65 } 66 67 void CCTextureUpdater::appendPartial(LayerTextureUpdater::Texture* texture, const IntRect& sourceRect, const IntRect& destRect) 68 { 69 append(texture, sourceRect, destRect, m_partialEntries); 60 70 } 61 71 62 72 bool CCTextureUpdater::hasMoreUpdates() const 63 73 { 64 return m_entries.size() ;74 return m_entries.size() || m_partialEntries.size(); 65 75 } 66 76 67 77 bool CCTextureUpdater::update(GraphicsContext3D* context, size_t count) 68 78 { 79 size_t index; 69 80 size_t maxIndex = min(m_entryIndex + count, m_entries.size()); 70 for ( ; m_entryIndex < maxIndex; ++m_entryIndex) {71 UpdateEntry& entry = m_entries[ m_entryIndex];81 for (index = m_entryIndex; index < maxIndex; ++index) { 82 UpdateEntry& entry = m_entries[index]; 72 83 entry.m_texture->updateRect(context, m_allocator, entry.m_sourceRect, entry.m_destRect); 73 84 } 74 85 75 if (maxIndex < m_entries.size()) 86 bool moreUpdates = maxIndex < m_entries.size(); 87 88 ASSERT(m_partialEntries.size() <= count); 89 // Make sure the number of updates including partial updates are not more 90 // than |count|. 91 if ((count - (index - m_entryIndex)) < m_partialEntries.size()) 92 moreUpdates = true; 93 94 if (moreUpdates) { 95 m_entryIndex = index; 76 96 return true; 97 } 98 99 for (index = 0; index < m_partialEntries.size(); ++index) { 100 UpdateEntry& entry = m_partialEntries[index]; 101 entry.m_texture->updateRect(context, m_allocator, entry.m_sourceRect, entry.m_destRect); 102 } 77 103 78 104 // If no entries left to process, auto-clear. … … 85 111 m_entryIndex = 0; 86 112 m_entries.clear(); 113 m_partialEntries.clear(); 87 114 } 88 115 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.h
r101600 r107177 42 42 43 43 void append(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); 44 void appendPartial(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect); 44 45 45 46 bool hasMoreUpdates() const; … … 59 60 }; 60 61 62 static void append(LayerTextureUpdater::Texture*, const IntRect& sourceRect, const IntRect& destRect, Vector<UpdateEntry>&); 63 61 64 TextureAllocator* m_allocator; 62 65 size_t m_entryIndex; 63 66 Vector<UpdateEntry> m_entries; 67 Vector<UpdateEntry> m_partialEntries; 64 68 }; 65 69 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
r106986 r107177 44 44 namespace { 45 45 46 static const size_t textureUpdatesPerFrame = 0; 46 // Number of textures to update with each call to 47 // scheduledActionUpdateMoreResources(). 48 static const size_t textureUpdatesPerFrame = 5; 47 49 48 50 } // anonymous namespace … … 463 465 TRACE_EVENT("CCThreadProxy::scheduledActionUpdateMoreResources", this, 0); 464 466 ASSERT(m_currentTextureUpdaterOnImplThread); 465 m_currentTextureUpdaterOnImplThread->update(m_layerTreeHostImpl->context(), textureUpdatesPerFrame > 0 ? textureUpdatesPerFrame : 99999);467 m_currentTextureUpdaterOnImplThread->update(m_layerTreeHostImpl->context(), textureUpdatesPerFrame); 466 468 } 467 469 … … 596 598 } 597 599 598 bool CCThreadProxy::partialTextureUpdateCapability() const599 { 600 return !textureUpdatesPerFrame;600 size_t CCThreadProxy::maxPartialTextureUpdates() const 601 { 602 return textureUpdatesPerFrame; 601 603 } 602 604 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
r106951 r107177 64 64 virtual void start(); 65 65 virtual void stop(); 66 virtual bool partialTextureUpdateCapability() const;66 virtual size_t maxPartialTextureUpdates() const; 67 67 68 68 // CCLayerTreeHostImplClient implementation -
trunk/Source/WebKit/chromium/ChangeLog
r107176 r107177 1 2012-02-08 David Reveman <reveman@chromium.org> 2 3 [Chromium] Avoid unnecessary full tile updates without breaking atomicity of commits. 4 https://bugs.webkit.org/show_bug.cgi?id=76740 5 6 Reviewed by James Robinson. 7 8 Add CCLayerTreeHostTestAtomicCommitWithPartialUpdate and 9 TiledLayerChromiumTest.partialUpdates tests that verifies 10 atomicity of commits with partial updates. 11 12 * tests/CCLayerTreeHostTest.cpp: 13 (WTF::CCLayerTreeHostTestAtomicCommit::CCLayerTreeHostTestAtomicCommit): 14 (WTF::CCLayerTreeHostTestAtomicCommit::beginTest): 15 (WTF::CCLayerTreeHostTestAtomicCommit::commitCompleteOnCCThread): 16 (WTF::CCLayerTreeHostTestAtomicCommit::layout): 17 (CCLayerTreeHostTestAtomicCommit): 18 (CCLayerTreeHostTestAtomicCommitWithPartialUpdate): 19 (WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::CCLayerTreeHostTestAtomicCommitWithPartialUpdate): 20 (WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::beginTest): 21 (WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::commitCompleteOnCCThread): 22 (WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::drawLayersOnCCThread): 23 (WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::layout): 24 (WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::afterTest): 25 (WTF): 26 (WTF::TEST_F): 27 * tests/TiledLayerChromiumTest.cpp: 28 (WTF::FakeLayerTextureUpdater::Texture::Texture): 29 (WTF::FakeLayerTextureUpdater::Texture::updateRect): 30 (Texture): 31 (WTF::FakeLayerTextureUpdater::FakeLayerTextureUpdater): 32 (FakeLayerTextureUpdater): 33 (WTF::FakeLayerTextureUpdater::updateCount): 34 (WTF::FakeLayerTextureUpdater::clearUpdateCount): 35 (WTF::FakeLayerTextureUpdater::updateRect): 36 (WTF::FakeLayerTextureUpdater::createTexture): 37 (FakeTiledLayerChromium): 38 (WTF::TEST): 39 (WTF): 40 1 41 2012-02-07 MORITA Hajime <morrita@google.com> 2 42 -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r106994 r107177 1148 1148 public: 1149 1149 CCLayerTreeHostTestAtomicCommit() 1150 : m_updateCheckLayer(ContentLayerChromiumWithUpdateTracking::create(&m_delegate)) 1151 , m_numCommits(0) 1150 : m_layer(ContentLayerChromiumWithUpdateTracking::create(&m_delegate)) 1152 1151 { 1153 1152 // Make sure partial texture updates are turned off. 1154 m_settings. partialTextureUpdates = false;1153 m_settings.maxPartialTextureUpdates = 0; 1155 1154 } 1156 1155 1157 1156 virtual void beginTest() 1158 1157 { 1159 m_layerTreeHost->setRootLayer(m_ updateCheckLayer);1158 m_layerTreeHost->setRootLayer(m_layer); 1160 1159 m_layerTreeHost->setViewportSize(IntSize(10, 10)); 1161 1160 … … 1174 1173 // Number of textures used for commit should be one. 1175 1174 EXPECT_EQ(1, context->numUsedTextures()); 1176 // Verify used texture is correct.1175 // Verify that used texture is correct. 1177 1176 EXPECT_TRUE(context->usedTexture(context->texture(0))); 1178 1177 … … 1215 1214 virtual void layout() 1216 1215 { 1217 m_ updateCheckLayer->setNeedsDisplay();1216 m_layer->setNeedsDisplay(); 1218 1217 } 1219 1218 … … 1224 1223 private: 1225 1224 MockContentLayerDelegate m_delegate; 1226 RefPtr<ContentLayerChromiumWithUpdateTracking> m_updateCheckLayer; 1225 RefPtr<ContentLayerChromiumWithUpdateTracking> m_layer; 1226 }; 1227 1228 TEST_F(CCLayerTreeHostTestAtomicCommit, runMultiThread) 1229 { 1230 runTest(true); 1231 } 1232 1233 class CCLayerTreeHostTestAtomicCommitWithPartialUpdate : public CCLayerTreeHostTest { 1234 public: 1235 CCLayerTreeHostTestAtomicCommitWithPartialUpdate() 1236 : m_parent(ContentLayerChromiumWithUpdateTracking::create(&m_delegate)) 1237 , m_child(ContentLayerChromiumWithUpdateTracking::create(&m_delegate)) 1238 , m_numCommits(0) 1239 { 1240 // Allow one partial texture update. 1241 m_settings.maxPartialTextureUpdates = 1; 1242 } 1243 1244 virtual void beginTest() 1245 { 1246 m_layerTreeHost->setRootLayer(m_parent); 1247 m_layerTreeHost->setViewportSize(IntSize(10, 10)); 1248 m_parent->addChild(m_child); 1249 m_child->setOpacity(0.5); 1250 m_child->setBounds(IntSize(20, 20)); 1251 1252 postSetNeedsCommitToMainThread(); 1253 postSetNeedsRedrawToMainThread(); 1254 } 1255 1256 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) 1257 { 1258 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(impl->context())); 1259 1260 switch (impl->frameNumber()) { 1261 case 0: 1262 // Number of textures should be two. 1263 EXPECT_EQ(2, context->numTextures()); 1264 // Number of textures used for commit should be two. 1265 EXPECT_EQ(2, context->numUsedTextures()); 1266 // Verify that used textures are correct. 1267 EXPECT_TRUE(context->usedTexture(context->texture(0))); 1268 EXPECT_TRUE(context->usedTexture(context->texture(1))); 1269 1270 context->resetUsedTextures(); 1271 break; 1272 case 1: 1273 // Number of textures should be four as the first two 1274 // textures are used by the impl thread. 1275 EXPECT_EQ(4, context->numTextures()); 1276 // Number of textures used for commit should still be two. 1277 EXPECT_EQ(2, context->numUsedTextures()); 1278 // First two textures should not have been used. 1279 EXPECT_FALSE(context->usedTexture(context->texture(0))); 1280 EXPECT_FALSE(context->usedTexture(context->texture(1))); 1281 // New textures should have been used. 1282 EXPECT_TRUE(context->usedTexture(context->texture(2))); 1283 EXPECT_TRUE(context->usedTexture(context->texture(3))); 1284 1285 context->resetUsedTextures(); 1286 break; 1287 case 2: 1288 // Number of textures should be three as we allow one 1289 // partial update and the first two textures are used by 1290 // the impl thread. 1291 EXPECT_EQ(3, context->numTextures()); 1292 // Number of textures used for commit should still be two. 1293 EXPECT_EQ(2, context->numUsedTextures()); 1294 // First texture should not have been used. 1295 EXPECT_FALSE(context->usedTexture(context->texture(0))); 1296 // Second texture should have been used. 1297 EXPECT_TRUE(context->usedTexture(context->texture(1))); 1298 // New textures should have been used. 1299 EXPECT_TRUE(context->usedTexture(context->texture(2))); 1300 1301 context->resetUsedTextures(); 1302 break; 1303 default: 1304 ASSERT_NOT_REACHED(); 1305 break; 1306 } 1307 } 1308 1309 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) 1310 { 1311 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(impl->context())); 1312 1313 // Number of textures used for drawing should always be two. 1314 EXPECT_EQ(2, context->numUsedTextures()); 1315 1316 if (impl->frameNumber() < 3) { 1317 context->resetUsedTextures(); 1318 postSetNeedsAnimateAndCommitToMainThread(); 1319 postSetNeedsRedrawToMainThread(); 1320 } else 1321 endTest(); 1322 } 1323 1324 virtual void layout() 1325 { 1326 switch (m_numCommits++) { 1327 case 0: 1328 case 1: 1329 m_parent->setNeedsDisplay(); 1330 m_child->setNeedsDisplay(); 1331 break; 1332 case 2: 1333 // Damage part of layers. 1334 m_parent->setNeedsDisplayRect(FloatRect(0, 0, 5, 5)); 1335 m_child->setNeedsDisplayRect(FloatRect(0, 0, 5, 5)); 1336 break; 1337 default: 1338 ASSERT_NOT_REACHED(); 1339 break; 1340 } 1341 } 1342 1343 virtual void afterTest() 1344 { 1345 } 1346 1347 private: 1348 MockContentLayerDelegate m_delegate; 1349 RefPtr<ContentLayerChromiumWithUpdateTracking> m_parent; 1350 RefPtr<ContentLayerChromiumWithUpdateTracking> m_child; 1227 1351 int m_numCommits; 1228 1352 }; 1229 1353 1230 TEST_F(CCLayerTreeHostTestAtomicCommit , runMultiThread)1354 TEST_F(CCLayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread) 1231 1355 { 1232 1356 runTest(true); -
trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
r106891 r107177 61 61 class Texture : public LayerTextureUpdater::Texture { 62 62 public: 63 Texture(PassOwnPtr<ManagedTexture> texture) : LayerTextureUpdater::Texture(texture) { } 63 Texture(FakeLayerTextureUpdater* layer, PassOwnPtr<ManagedTexture> texture) 64 : LayerTextureUpdater::Texture(texture) 65 , m_layer(layer) 66 { 67 } 64 68 virtual ~Texture() { } 65 69 66 virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect&, const IntRect&) { } 70 virtual void updateRect(GraphicsContext3D*, TextureAllocator*, const IntRect&, const IntRect&) { m_layer->updateRect(); } 71 72 private: 73 FakeLayerTextureUpdater* m_layer; 67 74 }; 68 75 69 FakeLayerTextureUpdater() : m_prepareCount(0) { } 76 FakeLayerTextureUpdater() 77 : m_prepareCount(0) 78 , m_updateCount(0) 79 { 80 } 70 81 virtual ~FakeLayerTextureUpdater() { } 71 82 … … 78 89 void clearPrepareCount() { m_prepareCount = 0; } 79 90 91 // Number of times updateRect has been invoked. 92 int updateCount() const { return m_updateCount; } 93 void clearUpdateCount() { m_updateCount = 0; } 94 void updateRect() { m_updateCount++; } 95 80 96 void setOpaquePaintRect(const IntRect& opaquePaintRect) { m_opaquePaintRect = opaquePaintRect; } 81 97 … … 83 99 const IntRect& lastUpdateRect() const { return m_lastUpdateRect; } 84 100 85 virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture( ManagedTexture::create(manager))); }101 virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager* manager) { return adoptPtr(new Texture(this, ManagedTexture::create(manager))); } 86 102 virtual SampledTexelFormat sampledTexelFormat(GC3Denum) { return SampledTexelFormatRGBA; } 87 103 virtual void prepareToUpdate(const IntRect& contentRect, const IntSize&, int, float, IntRect* resultingOpaqueRect); … … 89 105 private: 90 106 int m_prepareCount; 107 int m_updateCount; 91 108 IntRect m_rectToInvalidate; 92 109 IntRect m_lastUpdateRect; … … 156 173 157 174 private: 158 virtual void createTextureUpdater(const CCLayerTreeHost*) { }159 160 175 virtual LayerTextureUpdater* textureUpdater() const 161 176 { … … 580 595 } 581 596 597 TEST(TiledLayerChromiumTest, partialUpdates) 598 { 599 CCSettings settings; 600 settings.maxPartialTextureUpdates = 4; 601 // Initialize without threading support. 602 WebKit::WebCompositor::initialize(0); 603 FakeCCLayerTreeHostClient fakeCCLayerTreeHostClient; 604 RefPtr<CCLayerTreeHost> ccLayerTreeHost = CCLayerTreeHost::create(&fakeCCLayerTreeHostClient, settings); 605 606 // Create one 500 x 300 tiled layer. 607 IntSize contentBounds(300, 200); 608 IntRect contentRect(IntPoint::zero(), contentBounds); 609 610 OwnPtr<TextureManager> textureManager = TextureManager::create(60*1024*1024, 60*1024*1024, 1024); 611 RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); 612 layer->setBounds(contentBounds); 613 layer->setPosition(FloatPoint(150, 150)); 614 layer->invalidateRect(contentRect); 615 616 FakeTextureAllocator textureAllocator; 617 CCTextureUpdater updater(&textureAllocator); 618 619 ccLayerTreeHost->setRootLayer(layer); 620 ccLayerTreeHost->setViewportSize(IntSize(300, 200)); 621 622 // Full update of all 6 tiles. 623 ccLayerTreeHost->updateLayers(); 624 ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater); 625 updater.update(0, 4); 626 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); 627 EXPECT_TRUE(updater.hasMoreUpdates()); 628 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 629 updater.update(0, 4); 630 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); 631 EXPECT_FALSE(updater.hasMoreUpdates()); 632 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 633 ccLayerTreeHost->commitComplete(); 634 635 // Full update of 3 tiles and partial update of 3 tiles. 636 layer->invalidateRect(IntRect(0, 0, 300, 150)); 637 ccLayerTreeHost->updateLayers(); 638 ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater); 639 updater.update(0, 4); 640 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); 641 EXPECT_TRUE(updater.hasMoreUpdates()); 642 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 643 updater.update(0, 4); 644 EXPECT_EQ(3, layer->fakeLayerTextureUpdater()->updateCount()); 645 EXPECT_FALSE(updater.hasMoreUpdates()); 646 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 647 ccLayerTreeHost->commitComplete(); 648 649 // Partial update of 6 tiles. 650 layer->invalidateRect(IntRect(50, 50, 200, 100)); 651 ccLayerTreeHost->updateLayers(); 652 ccLayerTreeHost->updateCompositorResources(ccLayerTreeHost->context(), updater); 653 updater.update(0, 4); 654 EXPECT_EQ(2, layer->fakeLayerTextureUpdater()->updateCount()); 655 EXPECT_TRUE(updater.hasMoreUpdates()); 656 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 657 updater.update(0, 4); 658 EXPECT_EQ(4, layer->fakeLayerTextureUpdater()->updateCount()); 659 EXPECT_FALSE(updater.hasMoreUpdates()); 660 layer->fakeLayerTextureUpdater()->clearUpdateCount(); 661 ccLayerTreeHost->commitComplete(); 662 663 ccLayerTreeHost->setRootLayer(0); 664 ccLayerTreeHost.clear(); 665 WebKit::WebCompositor::shutdown(); 666 } 667 582 668 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.