WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-95057-20120905150212.patch (text/plain), 45.76 KB, created by
Christopher Cameron
on 2012-09-05 15:02:30 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Christopher Cameron
Created:
2012-09-05 15:02:30 PDT
Size:
45.76 KB
patch
obsolete
>Subversion Revision: 127533 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c7761d0f90e3d4c1bc2f847416fd5e87cbb99b8f..efba855769a7e2dce476f4ac99f459411e5398c6 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,50 @@ >+2012-08-31 Christopher Cameron <ccameron@chromium.org> >+ >+ [chromium] Allow impl-thread deletion of only some resources >+ https://bugs.webkit.org/show_bug.cgi?id=95057 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Towards allowing the impl thread to delete just some resources (as >+ opposed to deleting all resources). >+ >+ Do impl-thread deletion through CCPrioritizedTextureManager instead of >+ CCResourceProvider. In subsequent changes the impl thread will be able >+ to set a threshold for what to delete). Add a set of textures that >+ have been deleted by the impl thread, but have not had their related >+ structures cleared by the main thread yet. >+ >+ Allow multiple texture purges to occur without a commit between them. >+ In CCThreadProxy, make the acknowledgement of texture deletion be an >+ integer counter instead of a bool, because we may have multiple >+ not-yet-acknowledged purges. Remove many instances where texture purges >+ were avoided when there was an outstanding texture purge. >+ >+ Add the ability to clear only the references to deleted textures from >+ the texture upload queue. >+ >+ Add assertions that resources be freed to CCPrioritizedTextureManager. >+ >+ New test CCTextureUpdateControllerTest_AsyncDeletion >+ >+ * platform/graphics/chromium/LayerTextureUpdater.h: >+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: >+ * platform/graphics/chromium/cc/CCLayerTreeHost.h: >+ * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: >+ * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: >+ * platform/graphics/chromium/cc/CCPrioritizedTexture.cpp: >+ * platform/graphics/chromium/cc/CCPrioritizedTexture.h: >+ * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp: >+ * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h: >+ * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: >+ * platform/graphics/chromium/cc/CCSingleThreadProxy.h: >+ * platform/graphics/chromium/cc/CCTextureUpdateController.cpp: >+ * platform/graphics/chromium/cc/CCTextureUpdateController.h: >+ * platform/graphics/chromium/cc/CCTextureUpdateQueue.cpp: >+ * platform/graphics/chromium/cc/CCTextureUpdateQueue.h: >+ * platform/graphics/chromium/cc/CCThreadProxy.cpp: >+ * platform/graphics/chromium/cc/CCThreadProxy.h: >+ > 2012-09-03 Sam Weinig <sam@webkit.org> > > Part 1 of removing PlatformString.h, move remaining functions to new homes >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index f234e7b17813ca0018eb5ffdea5e1c3c152fe4ad..32828975dfb8491b8e14ef87b05bdcbb4bbabd77 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,23 @@ >+2012-08-31 Christopher Cameron <ccameron@chromium.org> >+ >+ [chromium] Allow impl-thread deletion of only some resources >+ https://bugs.webkit.org/show_bug.cgi?id=95057 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In CCLayerTreeHostImplTest, remove the test >+ releaseContentsTextureShouldTriggerCommit because it is no longer valid >+ and is redundant. A releaseContentsTexture will only trigger a commit >+ if the releaseContentsTexture actually deletes any textures, and >+ CCLayerTreeHostTestEvictTextures already tests that the commit is >+ issued upon eviction. >+ >+ Add CCTextureUpdateControllerTest_AsyncDeletion test to validate new >+ texture upload queue behavior. >+ >+ * tests/CCLayerTreeHostImplTest.cpp: >+ * tests/CCTextureUpdateControllerTest.cpp: >+ > 2012-09-04 Tien-Ren Chen <trchen@chromium.org> > > [chromium] Rename WebViewClient::handleDisambiguationPopup >diff --git a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >index 1ad61c8d8ca4653c1f20b8cee4262c771e4be21c..74f4c5da549dcd665b4693b84a1ae77ab1343774 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >+++ b/Source/WebCore/platform/graphics/chromium/LayerTextureUpdater.h >@@ -49,6 +49,7 @@ public: > > CCPrioritizedTexture* texture() { return m_texture.get(); } > void swapTextureWith(OwnPtr<CCPrioritizedTexture>& texture) { m_texture.swap(texture); } >+ virtual bool backingResourceWasDeleted() const { return m_texture->backingResourceWasDeleted(); } > virtual void prepareRect(const IntRect& /* sourceRect */, CCRenderingStats&) { } > virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, const IntSize& destOffset) = 0; > protected: >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >index 08474a1d37ed17d6cd3e996932cbcc5a6a589d10..dd12acd308c36668116fd418b33147bcf85ad80d 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >@@ -193,13 +193,21 @@ CCLayerTreeHost::RecreateResult CCLayerTreeHost::recreateContext() > return RecreateFailedAndGaveUp; > } > >-void CCLayerTreeHost::deleteContentsTexturesOnImplThread(CCResourceProvider* resourceProvider) >+void CCLayerTreeHost::deleteAllContentsTexturesOnImplThread(CCResourceProvider* resourceProvider) > { > ASSERT(CCProxy::isImplThread()); > if (m_rendererInitialized) > m_contentsTextureManager->clearAllMemory(resourceProvider); > } > >+bool CCLayerTreeHost::reduceContentsTexturesMemoryOnImplThread(CCResourceProvider* resourceProvider) >+{ >+ ASSERT(CCProxy::isImplThread()); >+ if (m_rendererInitialized) >+ return m_contentsTextureManager->reduceMemoryOnImplThread(resourceProvider); >+ return false; >+} >+ > void CCLayerTreeHost::acquireLayerTextures() > { > ASSERT(CCProxy::isMainThread()); >@@ -414,11 +422,12 @@ void CCLayerTreeHost::setVisible(bool visible) > m_proxy->setVisible(visible); > } > >-void CCLayerTreeHost::evictAllContentTextures() >+ >+void CCLayerTreeHost::destroyContentsTexturesEvictedByImplThread(int* purgeCounterAck) > { > ASSERT(CCProxy::isMainThread()); > ASSERT(m_contentsTextureManager.get()); >- m_contentsTextureManager->allBackingTexturesWereDeleted(); >+ m_contentsTextureManager->destroyEvictedBackings(purgeCounterAck); > } > > void CCLayerTreeHost::startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec) >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >index 742788c706783bb638f53d626f2dc5cc1e3a580a..dc25ad41f95c55940921b9747db8f0a4dc32e8e1 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >@@ -154,7 +154,6 @@ public: > RecreateResult recreateContext(); > void didCommitAndDrawFrame() { m_client->didCommitAndDrawFrame(); } > void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); } >- void deleteContentsTexturesOnImplThread(CCResourceProvider*); > virtual void acquireLayerTextures(); > // Returns false if we should abort this frame due to initialization failure. > bool initializeRendererIfNeeded(); >@@ -212,11 +211,16 @@ public: > > CCPrioritizedTextureManager* contentsTextureManager() const; > >- // This will cause contents texture manager to evict all textures, but >- // without deleting them. This happens after all content textures have >- // already been deleted on impl, after getting a 0 allocation limit. >- // Set during a commit, but before updateLayers. >- void evictAllContentTextures(); >+ void deleteAllContentsTexturesOnImplThread(CCResourceProvider*); >+ >+ // This will cause contents texture manager to free some resources used >+ // by textures, but will not delete the texture backings objects. The >+ // function returns true if some resources were indeed destroyed. >+ bool reduceContentsTexturesMemoryOnImplThread(CCResourceProvider*); >+ >+ // This will destroy the backings that had their GPU resources freed >+ // by deleteContentsTexturesResourcesOnImplThread. >+ void destroyContentsTexturesEvictedByImplThread(int* purgeCounterAck); > > bool visible() const { return m_visible; } > void setVisible(bool); >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp >index fcdd28bce865b5e601df518b5e3c681973457b1c..daa481a4bb028b171763e138f9c13771e4d16c22 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp >@@ -525,11 +525,7 @@ bool CCLayerTreeHostImpl::prepareToDraw(FrameData& frame) > > void CCLayerTreeHostImpl::releaseContentsTextures() > { >- if (m_contentsTexturesPurged) >- return; >- m_resourceProvider->deleteOwnedResources(CCRenderer::ContentPool); >- m_contentsTexturesPurged = true; >- m_client->setNeedsCommitOnImplThread(); >+ m_client->reduceContentsTexturesMemoryOnImplThread(); > } > > void CCLayerTreeHostImpl::setMemoryAllocationLimitBytes(size_t bytes) >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h >index b3d07ac29c0a8078f017c8e18930ba0072906384..2542f80df97e6f1528e23a1096b8f759132ccdbc 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h >@@ -60,6 +60,7 @@ public: > virtual void setNeedsRedrawOnImplThread() = 0; > virtual void setNeedsCommitOnImplThread() = 0; > virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) = 0; >+ virtual void reduceContentsTexturesMemoryOnImplThread() = 0; > }; > > // CCLayerTreeHostImpl owns the CCLayerImpl tree as well as associated rendering state >@@ -159,7 +160,7 @@ public: > int sourceFrameNumber() const { return m_sourceFrameNumber; } > void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumber; } > >- bool contentsTexturesPurged() const { return m_contentsTexturesPurged; } >+ void setContentsTexturesPurged() { m_contentsTexturesPurged = true; } > void resetContentsTexturesPurged() { m_contentsTexturesPurged = false; } > size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBytes; } > >@@ -282,6 +283,10 @@ private: > IntSize m_deviceViewportSize; > float m_deviceScaleFactor; > bool m_visible; >+ >+ // Set when the impl thread deletes textures, un-set when the impl's layer tree >+ // is known to not reference any deleted resources. Used to prevent drawing >+ // with deleted resources. > bool m_contentsTexturesPurged; > size_t m_memoryAllocationLimitBytes; > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp >index d9f68af0ae0b9928133a232d7416924761206ddb..148d5d970ec2005fc50a37dd7c52b3f8e0744c59 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.cpp >@@ -28,6 +28,7 @@ > > #include "CCPrioritizedTextureManager.h" > #include "CCPriorityCalculator.h" >+#include "CCProxy.h" > #include <algorithm> > > using namespace std; >@@ -110,9 +111,17 @@ void CCPrioritizedTexture::upload(CCResourceProvider* resourceProvider, > if (m_isAbovePriorityCutoff) > acquireBackingTexture(resourceProvider); > ASSERT(m_backing); >+ ASSERT(!backingResourceWasDeleted()); > resourceProvider->upload(resourceId(), image, imageRect, sourceRect, destOffset); > } > >+bool CCPrioritizedTexture::backingResourceWasDeleted() const >+{ >+ if (m_backing) >+ return m_backing->resourceDeleted(); >+ return false; >+} >+ > void CCPrioritizedTexture::link(Backing* backing) > { > ASSERT(backing); >@@ -139,4 +148,25 @@ void CCPrioritizedTexture::setToSelfManagedMemoryPlaceholder(size_t bytes) > m_bytes = bytes; > } > >+CCResourceProvider::ResourceId CCPrioritizedTexture::Backing::id() >+{ >+ ASSERT(CCProxy::isImplThread()); >+ return m_texture.id(); >+} >+ >+bool CCPrioritizedTexture::Backing::resourceDeleted() const >+{ >+ ASSERT(CCProxy::isImplThread()); >+ return m_resourceDeleted; >+} >+ >+void CCPrioritizedTexture::Backing::deleteResource(CCResourceProvider* resourceProvider) >+{ >+ ASSERT(CCProxy::isImplThread()); >+ ASSERT(resourceProvider); >+ ASSERT(!m_resourceDeleted); >+ resourceProvider->deleteResource(m_texture.id()); >+ m_resourceDeleted = true; >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h >index 3789d7f269a3d7e5195a892ddd376dae618d2b0e..46c7a187cb36dff87bc440f16b41a6a493204aa5 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTexture.h >@@ -88,6 +88,8 @@ public: > // Uploads pixels into the backing resource. This functions will aquire the backing if needed. > void upload(CCResourceProvider*, const uint8_t* image, const IntRect& imageRect, const IntRect& sourceRect, const IntSize& destOffset); > >+ bool backingResourceWasDeleted() const; >+ > CCResourceProvider::ResourceId resourceId() const; > > // Self-managed textures are accounted for when prioritizing other textures, >@@ -101,16 +103,28 @@ public: > private: > friend class CCPrioritizedTextureManager; > >- class Backing : public CCTexture { >+ class Backing { > WTF_MAKE_NONCOPYABLE(Backing); > public: > Backing(unsigned id, IntSize size, GC3Denum format) >- : CCTexture(id, size, format), m_owner(0) { } >- ~Backing() { ASSERT(!m_owner); } >+ : m_texture(id, size, format), m_resourceDeleted(false), m_owner(0) { } >+ ~Backing() { ASSERT(!m_owner && m_resourceDeleted); } >+ >+ CCPrioritizedTexture* owner() const { return m_owner; } >+ >+ CCResourceProvider::ResourceId id(); >+ const IntSize& size() const { return m_texture.size(); } >+ GC3Denum format() const { return m_texture.format(); } >+ size_t bytes() const { return m_texture.bytes(); } >+ >+ void deleteResource(CCResourceProvider*); >+ bool resourceDeleted() const; > >- CCPrioritizedTexture* owner() { return m_owner; } > private: > friend class CCPrioritizedTexture; >+ friend class CCPrioritizedTextureManager; >+ CCTexture m_texture; >+ bool m_resourceDeleted; > CCPrioritizedTexture* m_owner; > }; > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp >index 83d68ad071edb658282889abbb007f578eba2460..7fa464081afc22f6ac52776b1db9f72e65b8e2e8 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp >@@ -50,10 +50,11 @@ CCPrioritizedTextureManager::~CCPrioritizedTextureManager() > while (m_textures.size() > 0) > unregisterTexture(*m_textures.begin()); > >- // Each remaining backing is a leaked opengl texture. We don't have the resourceProvider >- // to delete the textures at this time so clearMemory() needs to be called before this. >- while (m_backings.size() > 0) >- destroyBacking(*m_backings.begin(), 0); >+ // Remove any backings that were evicted. >+ clearEvictedBackingsInternal(0); >+ >+ // Each remaining backing is real memory leak. This shouldn't happen. >+ ASSERT(m_backings.isEmpty()); > } > > void CCPrioritizedTextureManager::prioritizeTextures() >@@ -176,6 +177,7 @@ bool CCPrioritizedTextureManager::requestLate(CCPrioritizedTexture* texture) > void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTexture* texture, CCResourceProvider* resourceProvider) > { > ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); >+ ASSERT(resourceProvider); > ASSERT(!texture->isSelfManaged()); > ASSERT(texture->isAbovePriorityCutoff()); > if (texture->backing() || !texture->isAbovePriorityCutoff()) >@@ -188,6 +190,8 @@ void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTex > for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { > if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) > break; >+ if ((*it)->resourceDeleted()) >+ continue; > if ((*it)->size() == texture->size() && (*it)->format() == texture->format()) { > backing = (*it); > break; >@@ -198,6 +202,7 @@ void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTex > if (!backing) { > reduceMemory(m_memoryAvailableBytes - texture->bytes(), resourceProvider); > backing = createBacking(texture->size(), texture->format(), resourceProvider); >+ m_unevictedBackings.add(backing); > } > > // Move the used backing texture to the end of the eviction list. >@@ -211,6 +216,7 @@ void CCPrioritizedTextureManager::acquireBackingTextureIfNeeded(CCPrioritizedTex > void CCPrioritizedTextureManager::reduceMemory(size_t limitBytes, CCResourceProvider* resourceProvider) > { > ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); >+ ASSERT(resourceProvider); > if (memoryUseBytes() <= limitBytes) > return; > // Destroy backings until we are below the limit, >@@ -219,7 +225,15 @@ void CCPrioritizedTextureManager::reduceMemory(size_t limitBytes, CCResourceProv > BackingSet::iterator it = m_backings.begin(); > if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) > break; >- destroyBacking((*it), resourceProvider); >+ if ((*it)->resourceDeleted()) { >+ ASSERT(m_evictedBackings.find((*it)) != m_evictedBackings.end()); >+ m_evictedBackings.remove((*it)); >+ } else { >+ ASSERT(m_unevictedBackings.find((*it)) != m_unevictedBackings.end()); >+ m_unevictedBackings.remove((*it)); >+ (*it)->deleteResource(resourceProvider); >+ } >+ destroyBacking((*it)); > } > } > >@@ -246,23 +260,60 @@ void CCPrioritizedTextureManager::reduceMemory(CCResourceProvider* resourceProvi > reduceMemory(memoryUseBytes() - (wastedMemory - tenPercentOfMemory), resourceProvider); > } > >-void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourceProvider) >+bool CCPrioritizedTextureManager::reduceMemoryOnImplThread(CCResourceProvider* resourceProvider) > { >- // Unlink and destroy all backing textures. >- while (m_backings.size() > 0) { >- BackingSet::iterator it = m_backings.begin(); >- if ((*it)->owner()) >- (*it)->owner()->unlink(); >- destroyBacking((*it), resourceProvider); >+ ASSERT(CCProxy::isImplThread()); >+ ASSERT(resourceProvider); >+ >+ BackingVector backingsToEvict; >+ for (BackingSet::iterator it = m_unevictedBackings.begin(); it != m_unevictedBackings.end(); ++it) { >+ (*it)->deleteResource(resourceProvider); >+ backingsToEvict.append((*it)); >+ } >+ bool result = false; >+ MutexLocker lock(m_evictedStateMutex); >+ if (!backingsToEvict.isEmpty()) { >+ result = true; >+ for (BackingVector::iterator it = backingsToEvict.begin(); it != backingsToEvict.end(); ++it) { >+ m_unevictedBackings.remove((*it)); >+ m_evictedBackings.add((*it)); >+ } >+ m_evictionCounter++; >+ } >+ return result; >+} >+ >+void CCPrioritizedTextureManager::destroyEvictedBackings(int* evictionCounterAck) >+{ >+ ASSERT(CCProxy::isMainThread()); >+ clearEvictedBackingsInternal(evictionCounterAck); >+} >+ >+void CCPrioritizedTextureManager::clearEvictedBackingsInternal(int* evictionCounterAck) >+{ >+ // This can be called on the main or impl thread, or at tear-down. >+ MutexLocker lock(m_evictedStateMutex); >+ for (BackingSet::iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) { >+ destroyBacking((*it)); > } >+ m_evictedBackings.clear(); >+ if (evictionCounterAck) >+ *evictionCounterAck = m_evictionCounter; > } > >-void CCPrioritizedTextureManager::allBackingTexturesWereDeleted() >+bool CCPrioritizedTextureManager::isEvictionCounterAckUpToDate(int evictionCounterAck) > { >- // Same as clearAllMemory, except all our textures were already >- // deleted externally, so we don't delete them. Passing no >- // resourceProvider results in leaking the (now invalid) texture ids. >- clearAllMemory(0); >+ ASSERT(CCProxy::isImplThread()); >+ MutexLocker lock(m_evictedStateMutex); >+ return (evictionCounterAck == m_evictionCounter); >+} >+ >+void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourceProvider) >+{ >+ ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()); >+ ASSERT(resourceProvider); >+ reduceMemoryOnImplThread(resourceProvider); >+ clearEvictedBackingsInternal(0); > } > > void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture) >@@ -313,15 +364,13 @@ CCPrioritizedTexture::Backing* CCPrioritizedTextureManager::createBacking(IntSiz > return backing; > } > >-void CCPrioritizedTextureManager::destroyBacking(CCPrioritizedTexture::Backing* backing, CCResourceProvider* resourceProvider) >+void CCPrioritizedTextureManager::destroyBacking(CCPrioritizedTexture::Backing* backing) > { > ASSERT(backing); >- ASSERT(!backing->owner() || !backing->owner()->isAbovePriorityCutoff()); > ASSERT(!backing->owner() || !backing->owner()->isSelfManaged()); > ASSERT(m_backings.find(backing) != m_backings.end()); >+ ASSERT(backing->m_resourceDeleted); > >- if (resourceProvider) >- resourceProvider->deleteResource(backing->id()); > if (backing->owner()) > backing->owner()->unlink(); > m_memoryUseBytes -= backing->bytes(); >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h >index 13dbc5176bcd78ee297090a67651245f9bd764ca..b6739e687029faa720f5fee38895c4be126bc8c7 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h >@@ -33,6 +33,7 @@ > #include "IntSize.h" > #include <wtf/HashSet.h> > #include <wtf/ListHashSet.h> >+#include <wtf/ThreadingPrimitives.h> > #include <wtf/Vector.h> > > namespace WebCore { >@@ -77,8 +78,24 @@ public: > bool requestLate(CCPrioritizedTexture*); > > void reduceMemory(CCResourceProvider*); >+ >+ // Returns true and increments an internal eviction counter if resources are >+ // deleted as a result of this call. >+ // This function is asynchronous in that it is called on the impl thread while the >+ // main thread is not blocked (so it may be concurrent with other calls from the >+ // main thread) >+ bool reduceMemoryOnImplThread(CCResourceProvider*); >+ >+ // Remove the backings whose resources were destroyed by reduceMemoryOnImplThread. >+ // Writes the internal eviction counter to evictionCounterAck. >+ void destroyEvictedBackings(int* evictionCounterAck); >+ >+ // Returns true if evictionCounterAck is the value of internal eviction counter. >+ bool isEvictionCounterAckUpToDate(int evictionCounterAck); >+ >+ // Delete all textures and from the impl thread (at thread exit and >+ // context lost). > void clearAllMemory(CCResourceProvider*); >- void allBackingTexturesWereDeleted(); > > void acquireBackingTextureIfNeeded(CCPrioritizedTexture*, CCResourceProvider*); > >@@ -109,11 +126,10 @@ private: > } > > CCPrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize, int pool); >- > void reduceMemory(size_t limit, CCResourceProvider*); >- > CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, CCResourceProvider*); >- void destroyBacking(CCPrioritizedTexture::Backing*, CCResourceProvider*); >+ void clearEvictedBackingsInternal(int* evictionCounterAck); >+ void destroyBacking(CCPrioritizedTexture::Backing*); > > size_t m_maxMemoryLimitBytes; > unsigned m_priorityCutoff; >@@ -132,8 +148,23 @@ private: > > TextureVector m_tempTextureVector; > BackingVector m_tempBackingVector; >+ >+ // A copy of m_backings (minus evicted backings) which is accessed only on >+ // the impl thread. This is traversed when evicting backings (which happens >+ // while the main thread may be traversing m_backings). >+ // TOOD: make m_backings not accessed on the main thread, and remove this >+ // redundant state. >+ BackingSet m_unevictedBackings; >+ >+ // This state can be accessed by the impl thread and the main thread concurrently, >+ // and may be accessed only when m_evictedBackingsMutex is held. >+ Mutex m_evictedStateMutex; >+ BackingSet m_evictedBackings; >+ int m_evictionCounter; > }; > >+ >+ > } // WebCore > > #endif >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >index 6876ea2188baf6668a29ac37c1cd38c8cb441ce9..4b6517b4fe61486db958e35d68633a9fa07f9422 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp >@@ -155,9 +155,9 @@ bool CCSingleThreadProxy::recreateContext() > > bool initialized; > { >+ DebugScopedSetMainThreadBlocked mainThreadBlocked; > DebugScopedSetImplThread impl; >- if (!m_layerTreeHostImpl->contentsTexturesPurged()) >- m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); >+ m_layerTreeHost->deleteAllContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); > initialized = m_layerTreeHostImpl->initializeRenderer(context.release(), UnthrottledUploader); > if (initialized) { > m_RendererCapabilitiesForMainThread = m_layerTreeHostImpl->rendererCapabilities(); >@@ -260,9 +260,7 @@ void CCSingleThreadProxy::stop() > { > DebugScopedSetMainThreadBlocked mainThreadBlocked; > DebugScopedSetImplThread impl; >- >- if (!m_layerTreeHostImpl->contentsTexturesPurged()) >- m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); >+ m_layerTreeHost->deleteAllContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); > m_layerTreeHostImpl.clear(); > } > m_layerTreeHost = 0; >@@ -275,6 +273,15 @@ void CCSingleThreadProxy::postAnimationEventsToMainThreadOnImplThread(PassOwnPtr > m_layerTreeHost->setAnimationEvents(events, wallClockTime); > } > >+void CCSingleThreadProxy::reduceContentsTexturesMemoryOnImplThread() >+{ >+ ASSERT(CCProxy::isImplThread()); >+ if (m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(m_layerTreeHostImpl->resourceProvider())) { >+ m_layerTreeHostImpl->setContentsTexturesPurged(); >+ setNeedsCommitOnImplThread(); >+ } >+} >+ > // Called by the legacy scheduling path (e.g. where render_widget does the scheduling) > void CCSingleThreadProxy::compositeImmediately() > { >@@ -301,9 +308,7 @@ bool CCSingleThreadProxy::commitAndComposite() > if (!m_layerTreeHost->initializeRendererIfNeeded()) > return false; > >- if (m_layerTreeHostImpl->contentsTexturesPurged()) >- m_layerTreeHost->evictAllContentTextures(); >- >+ m_layerTreeHost->destroyContentsTexturesEvictedByImplThread(0); > CCTextureUpdateQueue queue; > m_layerTreeHost->updateLayers(queue, m_layerTreeHostImpl->memoryAllocationLimitBytes()); > m_layerTreeHostImpl->resetContentsTexturesPurged(); >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >index 71f4f4f57ece4adf1e465a2485997b5fc90a2e2d..9fb1ab8d34c8d77b40d8c4e31720a1e444b65d78 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h >@@ -72,6 +72,7 @@ public: > virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_layerTreeHost->scheduleComposite(); } > virtual void setNeedsCommitOnImplThread() OVERRIDE { m_layerTreeHost->scheduleComposite(); } > virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE; >+ virtual void reduceContentsTexturesMemoryOnImplThread() OVERRIDE; > > // Called by the legacy path where RenderWidget does the scheduling. > void compositeImmediately(); >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.cpp >index 6fc771e95905ee3c87e61b01f68663b2f90601c7..3939b1b3888cfbd4a89caf7453c7108c2d24d858 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.cpp >@@ -150,6 +150,11 @@ void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit) > updateMoreTexturesNow(); > } > >+void CCTextureUpdateController::discardUploadsToDeletedResources() >+{ >+ m_queue->clearUploadsToDeletedResources(); >+} >+ > void CCTextureUpdateController::onTimerFired() > { > if (!m_queue->hasMoreUpdates()) >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.h b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.h >index dd758beb4d9fcd866e18c847ccd0af289ba95bd1..ca323c9bbdfde03fdbc32b059d67a0d3c5c10ca8 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateController.h >@@ -51,6 +51,9 @@ public: > bool hasMoreUpdates() const; > void updateMoreTextures(double monotonicTimeLimit); > >+ // Discard uploads to textures that were evicted on the impl thread >+ void discardUploadsToDeletedResources(); >+ > // CCTimerClient implementation. > virtual void onTimerFired() OVERRIDE; > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateQueue.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateQueue.cpp >index 8f58fcbcb4cba24f34a5aad47ed7c9460743c1a8..a90557617136d13851bcaf76e33a8208513d26a3 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateQueue.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateQueue.cpp >@@ -54,10 +54,21 @@ void CCTextureUpdateQueue::appendCopy(TextureCopier::Parameters copy) > m_copyEntries.append(copy); > } > >-void CCTextureUpdateQueue::clearUploads() >+void CCTextureUpdateQueue::clearUploadsToDeletedResources() > { >- m_fullEntries.clear(); >- m_partialEntries.clear(); >+ clearUploadsToDeletedResources(m_fullEntries); >+ clearUploadsToDeletedResources(m_partialEntries); >+} >+ >+void CCTextureUpdateQueue::clearUploadsToDeletedResources(Deque<TextureUploader::Parameters>& entryQueue) >+{ >+ Deque<TextureUploader::Parameters> temp; >+ entryQueue.swap(temp); >+ while (temp.size()) { >+ TextureUploader::Parameters upload = temp.takeFirst(); >+ if (!upload.texture->backingResourceWasDeleted()) >+ entryQueue.append(upload); >+ } > } > > TextureUploader::Parameters CCTextureUpdateQueue::takeFirstFullUpload() >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateQueue.h b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateQueue.h >index de6373821f08a8454ae6485b6af37483c7805ee6..c8dcb16e023bba176b508e1cd94b68f627d970e2 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateQueue.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdateQueue.h >@@ -43,7 +43,7 @@ public: > void appendPartialUpload(TextureUploader::Parameters); > void appendCopy(TextureCopier::Parameters); > >- void clearUploads(); >+ void clearUploadsToDeletedResources(); > > TextureUploader::Parameters takeFirstFullUpload(); > TextureUploader::Parameters takeFirstPartialUpload(); >@@ -56,6 +56,7 @@ public: > bool hasMoreUpdates() const; > > private: >+ void clearUploadsToDeletedResources(Deque<TextureUploader::Parameters>& entryQueue); > Deque<TextureUploader::Parameters> m_fullEntries; > Deque<TextureUploader::Parameters> m_partialEntries; > Deque<TextureCopier::Parameters> m_copyEntries; >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >index 13b904527536a1d449062a15ace63d968041655d..3910d6568512b42bd44fce7d9b336bbfa1707198 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp >@@ -352,6 +352,24 @@ void CCThreadProxy::onVSyncParametersChanged(double monotonicTimebase, double in > m_schedulerOnImplThread->setTimebaseAndInterval(monotonicTimebase, intervalInSeconds); > } > >+void CCThreadProxy::reduceContentsTexturesMemoryOnImplThread() >+{ >+ ASSERT(isImplThread()); >+ TRACE_EVENT0("cc", "CCThreadProxy::reduceContentsTexturesMemoryOnImplThread"); >+ >+ if (m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(m_layerTreeHostImpl->resourceProvider())) { >+ // Clear any pending uploads to deleted resources. >+ if (m_currentTextureUpdateControllerOnImplThread) >+ m_currentTextureUpdateControllerOnImplThread->discardUploadsToDeletedResources(); >+ >+ // The impl layer tree may now contain references to deleted resources, so disallow >+ // drawing until a commit which acknowledges the references are removed occurs. >+ m_resetContentsTexturesPurgedAfterCommitOnImplThread = false; >+ m_layerTreeHostImpl->setContentsTexturesPurged(); >+ setNeedsCommitOnImplThread(); >+ } >+} >+ > void CCThreadProxy::setNeedsCommitOnImplThread() > { > ASSERT(isImplThread()); >@@ -475,7 +493,6 @@ void CCThreadProxy::scheduledActionBeginFrame() > m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState()); > m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasingTime(); > m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollDeltas(); >- m_pendingBeginFrameRequest->contentsTexturesWereDeleted = m_layerTreeHostImpl->contentsTexturesPurged(); > m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAllocationLimitBytes(); > > m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrame)); >@@ -545,8 +562,8 @@ void CCThreadProxy::beginFrame() > if (!m_layerTreeHost->initializeRendererIfNeeded()) > return; > >- if (request->contentsTexturesWereDeleted) >- m_layerTreeHost->evictAllContentTextures(); >+ int contentsTexturesPurgeAck = 0; >+ m_layerTreeHost->destroyContentsTexturesEvictedByImplThread(&contentsTexturesPurgeAck); > > OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue); > m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimitBytes); >@@ -576,7 +593,7 @@ void CCThreadProxy::beginFrame() > DebugScopedSetMainThreadBlocked mainThreadBlocked; > > CCCompletionEvent completion; >- CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrameCompleteOnImplThread, &completion, queue.release(), request->contentsTexturesWereDeleted)); >+ CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrameCompleteOnImplThread, &completion, queue.release(), contentsTexturesPurgeAck)); > completion.wait(); > } > >@@ -584,7 +601,7 @@ void CCThreadProxy::beginFrame() > m_layerTreeHost->didBeginFrame(); > } > >-void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion, PassOwnPtr<CCTextureUpdateQueue> queue, bool contentsTexturesWereDeleted) >+void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion, PassOwnPtr<CCTextureUpdateQueue> queue, int contentsTexturesEvictionCounterAck) > { > TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); > ASSERT(!m_commitCompletionEventOnImplThread); >@@ -597,12 +614,15 @@ void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion > return; > } > >- if (!contentsTexturesWereDeleted && m_layerTreeHostImpl->contentsTexturesPurged()) { >- // We purged the content textures on the impl thread between the time we >- // posted the beginFrame task and now, meaning we have a bunch of >- // uploads that are now invalid. Clear the uploads (they all go to >- // content textures), and kick another commit to fill them again. >- queue->clearUploads(); >+ if (!m_layerTreeHost->contentsTextureManager()->isEvictionCounterAckUpToDate(contentsTexturesEvictionCounterAck)) { >+ TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread_purge_since_commit"); >+ // The upload queue may contain references to textures that were asynchronously >+ // deleted. Remove them. >+ queue->clearUploadsToDeletedResources(); >+ >+ // There exist textures purged by the impl thread that the main thread >+ // doesn't know of. Request a recommit, which will inform the main thread >+ // of the purged resources. > setNeedsCommitOnImplThread(); > } else > m_resetContentsTexturesPurgedAfterCommitOnImplThread = true; >@@ -899,8 +919,7 @@ void CCThreadProxy::layerTreeHostClosedOnImplThread(CCCompletionEvent* completio > { > TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread"); > ASSERT(isImplThread()); >- if (!m_layerTreeHostImpl->contentsTexturesPurged()) >- m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); >+ m_layerTreeHost->deleteAllContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); > m_inputHandlerOnImplThread.clear(); > m_layerTreeHostImpl.clear(); > m_schedulerOnImplThread.clear(); >@@ -922,8 +941,7 @@ void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C > { > TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); > ASSERT(isImplThread()); >- if (!m_layerTreeHostImpl->contentsTexturesPurged()) >- m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); >+ m_layerTreeHost->deleteAllContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider()); > *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(adoptPtr(contextPtr), textureUploader); > if (*recreateSucceeded) { > *capabilities = m_layerTreeHostImpl->rendererCapabilities(); >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h >index 72ac825ca6da0fab750625c498fba407061e3de1..6b97917aeb20760ec09d604249cb9791f2be85d6 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h >@@ -81,6 +81,7 @@ public: > virtual void setNeedsRedrawOnImplThread() OVERRIDE; > virtual void setNeedsCommitOnImplThread() OVERRIDE; > virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE; >+ virtual void reduceContentsTexturesMemoryOnImplThread() OVERRIDE; > > // CCSchedulerClient implementation > virtual bool canDraw() OVERRIDE; >@@ -106,7 +107,6 @@ private: > > double monotonicFrameBeginTime; > OwnPtr<CCScrollAndScaleSet> scrollInfo; >- bool contentsTexturesWereDeleted; > size_t memoryAllocationLimitBytes; > }; > OwnPtr<BeginFrameAndCommitState> m_pendingBeginFrameRequest; >@@ -127,7 +127,7 @@ private: > IntRect rect; > }; > void forceBeginFrameOnImplThread(CCCompletionEvent*); >- void beginFrameCompleteOnImplThread(CCCompletionEvent*, PassOwnPtr<CCTextureUpdateQueue>, bool contentsTexturesWereDeleted); >+ void beginFrameCompleteOnImplThread(CCCompletionEvent*, PassOwnPtr<CCTextureUpdateQueue>, int contentsTexturesPurgeAck); > void beginFrameAbortedOnImplThread(); > void requestReadbackOnImplThread(ReadbackRequest*); > void requestStartPageScaleAnimationOnImplThread(IntSize targetPosition, bool useAnchor, float scale, double durationSec); >diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp >index d09bc3649eaebec43d89dd62374336ebf2561c24..48b220aa91e7ee2b6042e620f0c5e475c2843ce8 100644 >--- a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp >+++ b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp >@@ -87,6 +87,7 @@ public: > virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = true; } > virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = true; } > virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE { } >+ virtual void reduceContentsTexturesMemoryOnImplThread() OVERRIDE { } > > PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassOwnPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr) > { >@@ -3791,12 +3792,6 @@ TEST_F(CCLayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) > } > } > >-TEST_F(CCLayerTreeHostImplTest, releaseContentsTextureShouldTriggerCommit) >-{ >- m_hostImpl->releaseContentsTextures(); >- EXPECT_TRUE(m_didRequestCommit); >-} >- > struct RenderPassCacheEntry { > mutable OwnPtr<CCRenderPass> renderPassPtr; > CCRenderPass* renderPass; >diff --git a/Source/WebKit/chromium/tests/CCTextureUpdateControllerTest.cpp b/Source/WebKit/chromium/tests/CCTextureUpdateControllerTest.cpp >index 11659f6f52b8abd0ae30759b7a6654145106043a..022771168cc9d2b81ed0eec63a5373d99237bacd 100644 >--- a/Source/WebKit/chromium/tests/CCTextureUpdateControllerTest.cpp >+++ b/Source/WebKit/chromium/tests/CCTextureUpdateControllerTest.cpp >@@ -87,10 +87,14 @@ private: > > class TextureForUploadTest : public LayerTextureUpdater::Texture { > public: >- TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritizedTexture>(0)) { } >+ TextureForUploadTest() : LayerTextureUpdater::Texture(adoptPtr<CCPrioritizedTexture>(0)), m_deleted(false) { } >+ virtual bool backingResourceWasDeleted() const { return m_deleted; } > virtual void updateRect(CCResourceProvider*, const IntRect& sourceRect, const IntSize& destOffset) { } >-}; > >+ void setBackingResourceDeleted() { m_deleted = true; } >+private: >+ bool m_deleted; >+}; > > class CCTextureUpdateControllerTest : public Test { > public: >@@ -183,28 +187,38 @@ protected: > WebCompositor::shutdown(); > } > >- 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; >@@ -215,7 +229,7 @@ protected: > OwnPtr<CCGraphicsContext> m_context; > OwnPtr<CCResourceProvider> m_resourceProvider; > OwnPtr<CCTextureUpdateQueue> m_queue; >- TextureForUploadTest m_texture; >+ TextureForUploadTest m_textures[4]; > FakeTextureCopier m_copier; > TextureUploaderForUploadTest m_uploader; > >@@ -685,4 +699,37 @@ TEST_F(CCTextureUpdateControllerTest, UpdatesCompleteInFiniteTime) > EXPECT_EQ(2, m_numTotalUploads); > } > >+TEST_F(CCTextureUpdateControllerTest, AsyncDeletion) >+{ >+ appendFullUploadsOfIndexedTextureToUpdateQueue(1, 0); >+ appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 1); >+ appendFullUploadsOfIndexedTextureToUpdateQueue(1, 2); >+ appendPartialUploadsOfIndexedTextureToUpdateQueue(1, 3); >+ DebugScopedSetImplThread implThread; >+ >+ m_queue->clearUploadsToDeletedResources(); >+ EXPECT_EQ(2u, m_queue->fullUploadSize()); >+ EXPECT_EQ(2u, m_queue->partialUploadSize()); >+ >+ m_textures[0].setBackingResourceDeleted(); >+ m_queue->clearUploadsToDeletedResources(); >+ EXPECT_EQ(1u, m_queue->fullUploadSize()); >+ EXPECT_EQ(2u, m_queue->partialUploadSize()); >+ >+ m_textures[3].setBackingResourceDeleted(); >+ m_queue->clearUploadsToDeletedResources(); >+ EXPECT_EQ(1u, m_queue->fullUploadSize()); >+ EXPECT_EQ(1u, m_queue->partialUploadSize()); >+ >+ m_textures[2].setBackingResourceDeleted(); >+ m_queue->clearUploadsToDeletedResources(); >+ EXPECT_EQ(0u, m_queue->fullUploadSize()); >+ EXPECT_EQ(1u, m_queue->partialUploadSize()); >+ >+ m_textures[1].setBackingResourceDeleted(); >+ m_queue->clearUploadsToDeletedResources(); >+ EXPECT_EQ(0u, m_queue->fullUploadSize()); >+ EXPECT_EQ(0u, m_queue->partialUploadSize()); >+} >+ > } // namespace
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 95057
:
160669
|
161077
|
161370
|
161379
|
161601
|
161808
|
161809
|
162173
|
162335
|
162345
|
162358