diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-18 17:38:27 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-18 17:38:27 +0000 |
commit | 522b4fc54b0bcebe3faeb411477876be049b18aa (patch) | |
tree | 80d1151f0f42b0082eb2514d415d22700617f289 /cc | |
parent | 148f77ab0e14f4a58ee1856fda317620c06730be (diff) | |
download | chromium_src-522b4fc54b0bcebe3faeb411477876be049b18aa.zip chromium_src-522b4fc54b0bcebe3faeb411477876be049b18aa.tar.gz chromium_src-522b4fc54b0bcebe3faeb411477876be049b18aa.tar.bz2 |
Make cc's use of WTF::HashMap robust to key/value change
A future WebKit change (bug 82784) plans to change HashMap iterator's
first/second to key/value. Since cc is still (unfortunately) using WebKit's WTF
template classes, be robust to this patch landing with an #ifdef.
BUG=none
Review URL: https://codereview.chromium.org/10914327
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/CCDamageTracker.cpp | 4 | ||||
-rw-r--r-- | cc/CCDirectRenderer.cpp | 12 | ||||
-rw-r--r-- | cc/CCLayerTilingData.cpp | 5 | ||||
-rw-r--r-- | cc/CCLayerTreeHost.cpp | 12 | ||||
-rw-r--r-- | cc/CCLayerTreeHostImpl.cpp | 4 | ||||
-rw-r--r-- | cc/CCResourceProvider.cpp | 164 | ||||
-rw-r--r-- | cc/TiledLayerChromium.cpp | 22 |
7 files changed, 184 insertions, 39 deletions
diff --git a/cc/CCDamageTracker.cpp b/cc/CCDamageTracker.cpp index d2a94a8..9d4b108 100644 --- a/cc/CCDamageTracker.cpp +++ b/cc/CCDamageTracker.cpp @@ -207,7 +207,11 @@ FloatRect CCDamageTracker::trackDamageFromLeftoverRects() FloatRect damageRect = FloatRect(); for (RectMap::iterator it = m_currentRectHistory->begin(); it != m_currentRectHistory->end(); ++it) +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + damageRect.unite(it->value); +#else damageRect.unite(it->second); +#endif m_currentRectHistory->clear(); diff --git a/cc/CCDirectRenderer.cpp b/cc/CCDirectRenderer.cpp index 3b1bf32..d0590fa 100644 --- a/cc/CCDirectRenderer.cpp +++ b/cc/CCDirectRenderer.cpp @@ -98,15 +98,27 @@ void CCDirectRenderer::decideRenderPassAllocationsForFrame(const CCRenderPassLis Vector<CCRenderPass::Id> passesToDelete; HashMap<CCRenderPass::Id, OwnPtr<CachedTexture> >::const_iterator passIterator; for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPassTextures.end(); ++passIterator) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + const CCRenderPass* renderPassInFrame = renderPassesInFrame.get(passIterator->key); +#else const CCRenderPass* renderPassInFrame = renderPassesInFrame.get(passIterator->first); +#endif if (!renderPassInFrame) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + passesToDelete.append(passIterator->key); +#else passesToDelete.append(passIterator->first); +#endif continue; } const IntSize& requiredSize = renderPassTextureSize(renderPassInFrame); GC3Denum requiredFormat = renderPassTextureFormat(renderPassInFrame); +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + CachedTexture* texture = passIterator->value.get(); +#else CachedTexture* texture = passIterator->second.get(); +#endif ASSERT(texture); if (texture->id() && (texture->size() != requiredSize || texture->format() != requiredFormat)) diff --git a/cc/CCLayerTilingData.cpp b/cc/CCLayerTilingData.cpp index 5edde41..f650aa3 100644 --- a/cc/CCLayerTilingData.cpp +++ b/cc/CCLayerTilingData.cpp @@ -132,8 +132,13 @@ void CCLayerTilingData::setBounds(const IntSize& size) contentRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom); Vector<TileMapKey> invalidTileKeys; for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + if (it->key.first > right || it->key.second > bottom) + invalidTileKeys.append(it->key); +#else if (it->first.first > right || it->first.second > bottom) invalidTileKeys.append(it->first); +#endif } for (size_t i = 0; i < invalidTileKeys.size(); ++i) m_tiles.remove(invalidTileKeys[i]); diff --git a/cc/CCLayerTreeHost.cpp b/cc/CCLayerTreeHost.cpp index 18786f5..dac1f69 100644 --- a/cc/CCLayerTreeHost.cpp +++ b/cc/CCLayerTreeHost.cpp @@ -99,7 +99,11 @@ CCLayerTreeHost::~CCLayerTreeHost() numLayerTreeInstances--; RateLimiterMap::iterator it = m_rateLimiters.begin(); if (it != m_rateLimiters.end()) +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + it->value->stop(); +#else it->second->stop(); +#endif } void CCLayerTreeHost::setSurfaceReady() @@ -685,7 +689,11 @@ void CCLayerTreeHost::startRateLimiter(WebKit::WebGraphicsContext3D* context) ASSERT(context); RateLimiterMap::iterator it = m_rateLimiters.find(context); if (it != m_rateLimiters.end()) +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + it->value->start(); +#else it->second->start(); +#endif else { RefPtr<RateLimiter> rateLimiter = RateLimiter::create(context, this); m_rateLimiters.set(context, rateLimiter); @@ -697,7 +705,11 @@ void CCLayerTreeHost::stopRateLimiter(WebKit::WebGraphicsContext3D* context) { RateLimiterMap::iterator it = m_rateLimiters.find(context); if (it != m_rateLimiters.end()) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + it->value->stop(); +#else it->second->stop(); +#endif m_rateLimiters.remove(it); } } diff --git a/cc/CCLayerTreeHostImpl.cpp b/cc/CCLayerTreeHostImpl.cpp index c5f18e7..7d883c9 100644 --- a/cc/CCLayerTreeHostImpl.cpp +++ b/cc/CCLayerTreeHostImpl.cpp @@ -385,7 +385,11 @@ static inline CCRenderPass* findRenderPassById(CCRenderPass::Id renderPassId, co { CCRenderPassIdHashMap::const_iterator it = frame.renderPassesById.find(renderPassId); ASSERT(it != frame.renderPassesById.end()); +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + return it->value.get(); +#else return it->second.get(); +#endif } static void removeRenderPassesRecursive(CCRenderPass::Id removeRenderPassId, CCLayerTreeHostImpl::FrameData& frame) diff --git a/cc/CCResourceProvider.cpp b/cc/CCResourceProvider.cpp index 05b79c3..4c58769 100644 --- a/cc/CCResourceProvider.cpp +++ b/cc/CCResourceProvider.cpp @@ -77,7 +77,12 @@ bool CCResourceProvider::inUseByConsumer(ResourceId id) ASSERT(CCProxy::isImplThread()); ResourceMap::iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - return !!it->second.lockForReadCount || it->second.exported; +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &it->value; +#else + Resource* resource = &it->second; +#endif + return !!resource->lockForReadCount || resource->exported; } CCResourceProvider::ResourceId CCResourceProvider::createResource(int pool, const IntSize& size, GC3Denum format, TextureUsageHint hint) @@ -148,16 +153,21 @@ void CCResourceProvider::deleteResource(ResourceId id) ASSERT(CCProxy::isImplThread()); ResourceMap::iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - ASSERT(!it->second.lockedForWrite); - ASSERT(!it->second.lockForReadCount); +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &it->value; +#else + Resource* resource = &it->second; +#endif + ASSERT(!resource->lockedForWrite); + ASSERT(!resource->lockForReadCount); - if (it->second.glId && !it->second.external) { + if (resource->glId && !resource->external) { WebGraphicsContext3D* context3d = m_context->context3D(); ASSERT(context3d); - GLC(context3d, context3d->deleteTexture(it->second.glId)); + GLC(context3d, context3d->deleteTexture(resource->glId)); } - if (it->second.pixels) - delete it->second.pixels; + if (resource->pixels) + delete resource->pixels; m_resources.remove(it); } @@ -167,8 +177,13 @@ void CCResourceProvider::deleteOwnedResources(int pool) ASSERT(CCProxy::isImplThread()); ResourceIdArray toDelete; for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + if (it->value.pool == pool && !it->value.external) + toDelete.append(it->key); +#else if (it->second.pool == pool && !it->second.external) toDelete.append(it->first); +#endif } for (ResourceIdArray::iterator it = toDelete.begin(); it != toDelete.end(); ++it) deleteResource(*it); @@ -178,7 +193,12 @@ CCResourceProvider::ResourceType CCResourceProvider::resourceType(ResourceId id) { ResourceMap::iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - return it->second.type; +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &it->value; +#else + Resource* resource = &it->second; +#endif + return resource->type; } void CCResourceProvider::upload(ResourceId id, const uint8_t* image, const IntRect& imageRect, const IntRect& sourceRect, const IntSize& destOffset) @@ -186,19 +206,24 @@ void CCResourceProvider::upload(ResourceId id, const uint8_t* image, const IntRe ASSERT(CCProxy::isImplThread()); ResourceMap::iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - ASSERT(!it->second.lockedForWrite); - ASSERT(!it->second.lockForReadCount); - ASSERT(!it->second.external); +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &it->value; +#else + Resource* resource = &it->second; +#endif + ASSERT(!resource->lockedForWrite); + ASSERT(!resource->lockForReadCount); + ASSERT(!resource->external); - if (it->second.glId) { + if (resource->glId) { WebGraphicsContext3D* context3d = m_context->context3D(); ASSERT(context3d); ASSERT(m_texSubImage.get()); - context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, it->second.glId); - m_texSubImage->upload(image, imageRect, sourceRect, destOffset, it->second.format, context3d); + context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, resource->glId); + m_texSubImage->upload(image, imageRect, sourceRect, destOffset, resource->format, context3d); } - if (it->second.pixels) { + if (resource->pixels) { SkBitmap srcFull; srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageRect.height()); srcFull.setPixels(const_cast<uint8_t*>(image)); @@ -237,9 +262,14 @@ const CCResourceProvider::Resource* CCResourceProvider::lockForRead(ResourceId i ASSERT(CCProxy::isImplThread()); ResourceMap::iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - ASSERT(!it->second.lockedForWrite); - it->second.lockForReadCount++; - return &it->second; +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &it->value; +#else + Resource* resource = &it->second; +#endif + ASSERT(!resource->lockedForWrite); + resource->lockForReadCount++; + return resource; } void CCResourceProvider::unlockForRead(ResourceId id) @@ -247,8 +277,13 @@ void CCResourceProvider::unlockForRead(ResourceId id) ASSERT(CCProxy::isImplThread()); ResourceMap::iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - ASSERT(it->second.lockForReadCount > 0); - it->second.lockForReadCount--; +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &it->value; +#else + Resource* resource = &it->second; +#endif + ASSERT(resource->lockForReadCount > 0); + resource->lockForReadCount--; } const CCResourceProvider::Resource* CCResourceProvider::lockForWrite(ResourceId id) @@ -256,11 +291,16 @@ const CCResourceProvider::Resource* CCResourceProvider::lockForWrite(ResourceId ASSERT(CCProxy::isImplThread()); ResourceMap::iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - ASSERT(!it->second.lockedForWrite); - ASSERT(!it->second.lockForReadCount); - ASSERT(!it->second.external); - it->second.lockedForWrite = true; - return &it->second; +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &it->value; +#else + Resource* resource = &it->second; +#endif + ASSERT(!resource->lockedForWrite); + ASSERT(!resource->lockForReadCount); + ASSERT(!resource->external); + resource->lockedForWrite = true; + return resource; } void CCResourceProvider::unlockForWrite(ResourceId id) @@ -268,9 +308,14 @@ void CCResourceProvider::unlockForWrite(ResourceId id) ASSERT(CCProxy::isImplThread()); ResourceMap::iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - ASSERT(it->second.lockedForWrite); - ASSERT(!it->second.external); - it->second.lockedForWrite = false; +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &it->value; +#else + Resource* resource = &it->second; +#endif + ASSERT(resource->lockedForWrite); + ASSERT(!resource->external); + resource->lockedForWrite = false; } CCResourceProvider::ScopedReadLockGL::ScopedReadLockGL(CCResourceProvider* resourceProvider, CCResourceProvider::ResourceId resourceId) @@ -402,7 +447,11 @@ void CCResourceProvider::destroyChild(int child) ASSERT(CCProxy::isImplThread()); ChildMap::iterator it = m_children.find(child); ASSERT(it != m_children.end()); +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + deleteOwnedResources(it->value.pool); +#else deleteOwnedResources(it->second.pool); +#endif m_children.remove(it); trimMailboxDeque(); } @@ -412,7 +461,11 @@ const CCResourceProvider::ResourceIdMap& CCResourceProvider::getChildToParentMap ASSERT(CCProxy::isImplThread()); ChildMap::const_iterator it = m_children.find(child); ASSERT(it != m_children.end()); +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + return it->value.childToParentMap; +#else return it->second.childToParentMap; +#endif } CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToParent(const ResourceIdArray& resources) @@ -428,7 +481,11 @@ CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToPa for (ResourceIdArray::const_iterator it = resources.begin(); it != resources.end(); ++it) { TransferableResource resource; if (transferResource(context3d, *it, &resource)) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + m_resources.find(*it)->value.exported = true; +#else m_resources.find(*it)->second.exported = true; +#endif list.resources.append(resource); } } @@ -447,7 +504,11 @@ CCResourceProvider::TransferableResourceList CCResourceProvider::prepareSendToCh // FIXME: Implement this path for software compositing. return list; } +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Child& childInfo = m_children.find(child)->value; +#else Child& childInfo = m_children.find(child)->second; +#endif for (ResourceIdArray::const_iterator it = resources.begin(); it != resources.end(); ++it) { TransferableResource resource; if (!transferResource(context3d, *it, &resource)) @@ -480,7 +541,11 @@ void CCResourceProvider::receiveFromChild(int child, const TransferableResourceL // (and is simpler) to wait. GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); } +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Child& childInfo = m_children.find(child)->value; +#else Child& childInfo = m_children.find(child)->second; +#endif for (Vector<TransferableResource>::const_iterator it = resources.resources.begin(); it != resources.resources.end(); ++it) { unsigned textureId; GLC(context3d, textureId = context3d->createTexture()); @@ -506,10 +571,14 @@ void CCResourceProvider::receiveFromParent(const TransferableResourceList& resou if (resources.syncPoint) GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); for (Vector<TransferableResource>::const_iterator it = resources.resources.begin(); it != resources.resources.end(); ++it) { - Resource& resource = m_resources.find(it->id)->second; - ASSERT(resource.exported); - resource.exported = false; - GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, resource.glId)); +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + Resource* resource = &m_resources.find(it->id)->value; +#else + Resource* resource = &m_resources.find(it->id)->second; +#endif + ASSERT(resource->exported); + resource->exported = false; + GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, resource->glId)); GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, it->mailbox.name)); m_mailboxes.append(it->mailbox); } @@ -520,19 +589,24 @@ bool CCResourceProvider::transferResource(WebGraphicsContext3D* context, Resourc ASSERT(CCProxy::isImplThread()); ResourceMap::const_iterator it = m_resources.find(id); ASSERT(it != m_resources.end()); - ASSERT(!it->second.lockedForWrite); - ASSERT(!it->second.lockForReadCount); - ASSERT(!it->second.external); - if (it->second.exported) +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + const Resource* source = &it->value; +#else + const Resource* source = &it->second; +#endif + ASSERT(!source->lockedForWrite); + ASSERT(!source->lockForReadCount); + ASSERT(!source->external); + if (source->exported) return false; resource->id = id; - resource->format = it->second.format; - resource->size = it->second.size; + resource->format = source->format; + resource->size = source->size; if (!m_mailboxes.isEmpty()) resource->mailbox = m_mailboxes.takeFirst(); else GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); - GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, it->second.glId)); + GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, source->glId)); GLC(context, context->produceTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, resource->mailbox.name)); return true; } @@ -547,15 +621,27 @@ void CCResourceProvider::trimMailboxDeque() size_t maxMailboxCount = 0; if (m_context->capabilities().hasParentCompositor) { for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + if (!it->value.exported && !it->value.external) +#else if (!it->second.exported && !it->second.external) +#endif ++maxMailboxCount; } } else { HashSet<int> childPoolSet; for (ChildMap::iterator it = m_children.begin(); it != m_children.end(); ++it) +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + childPoolSet.add(it->value.pool); +#else childPoolSet.add(it->second.pool); +#endif for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + if (childPoolSet.contains(it->value.pool)) +#else if (childPoolSet.contains(it->second.pool)) +#endif ++maxMailboxCount; } } diff --git a/cc/TiledLayerChromium.cpp b/cc/TiledLayerChromium.cpp index 914e211..75bd57d 100644 --- a/cc/TiledLayerChromium.cpp +++ b/cc/TiledLayerChromium.cpp @@ -203,9 +203,15 @@ void TiledLayerChromium::pushPropertiesTo(CCLayerImpl* layer) Vector<UpdatableTile*> invalidTiles; for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + int i = iter->key.first; + int j = iter->key.second; + UpdatableTile* tile = static_cast<UpdatableTile*>(iter->value.get()); +#else int i = iter->first.first; int j = iter->first.second; UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); +#endif // FIXME: This should not ever be null. if (!tile) continue; @@ -235,7 +241,11 @@ void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) { if (host && host != layerTreeHost()) { for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + UpdatableTile* tile = static_cast<UpdatableTile*>(iter->value.get()); +#else UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); +#endif // FIXME: This should not ever be null. if (!tile) continue; @@ -303,7 +313,11 @@ void TiledLayerChromium::invalidateContentRect(const IntRect& contentRect) return; for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + UpdatableTile* tile = static_cast<UpdatableTile*>(iter->value.get()); +#else UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); +#endif ASSERT(tile); // FIXME: This should not ever be null. if (!tile) @@ -632,7 +646,11 @@ void TiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& priori // Now update priorities on all tiles we have in the layer, no matter where they are. for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + UpdatableTile* tile = static_cast<UpdatableTile*>(iter->value.get()); +#else UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); +#endif // FIXME: This should not ever be null. if (!tile) continue; @@ -657,7 +675,11 @@ void TiledLayerChromium::resetUpdateState() CCLayerTilingData::TileMap::const_iterator end = m_tiler->tiles().end(); for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != end; ++iter) { +#if WTF_NEW_HASHMAP_ITERATORS_INTERFACE + UpdatableTile* tile = static_cast<UpdatableTile*>(iter->value.get()); +#else UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); +#endif // FIXME: This should not ever be null. if (!tile) continue; |