| Index: cc/CCResourceProvider.cpp
|
| diff --git a/cc/CCResourceProvider.cpp b/cc/CCResourceProvider.cpp
|
| index 3cfc5f96ebea38f9569f30e635235612d3440d20..2568f1ca495b855f1f5458109d825a356200cc66 100644
|
| --- a/cc/CCResourceProvider.cpp
|
| +++ b/cc/CCResourceProvider.cpp
|
| @@ -69,7 +69,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)
|
| @@ -140,16 +145,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);
|
| }
|
| @@ -159,8 +169,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);
|
| @@ -170,7 +185,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)
|
| @@ -178,19 +198,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));
|
| @@ -229,9 +254,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)
|
| @@ -239,8 +269,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)
|
| @@ -248,11 +283,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)
|
| @@ -260,9 +300,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)
|
| @@ -384,7 +429,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();
|
| }
|
| @@ -394,7 +443,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)
|
| @@ -410,7 +463,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);
|
| }
|
| }
|
| @@ -429,7 +486,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))
|
| @@ -462,7 +523,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());
|
| @@ -488,10 +553,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);
|
| }
|
| @@ -502,19 +571,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;
|
| }
|
| @@ -529,15 +603,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;
|
| }
|
| }
|
|
|