Chromium Code Reviews| Index: cc/resource_provider.cc |
| =================================================================== |
| --- cc/resource_provider.cc (revision 166046) |
| +++ cc/resource_provider.cc (working copy) |
| @@ -74,8 +74,9 @@ |
| { |
| } |
| -ResourceProvider::Resource::Resource(unsigned textureId, int pool, const gfx::Size& size, GLenum format) |
| +ResourceProvider::Resource::Resource(unsigned textureId, const Mailbox& mailbox, int pool, const gfx::Size& size, GLenum format) |
| : glId(textureId) |
| + , mailbox(mailbox) |
| , pixels(0) |
| , pool(pool) |
| , lockForReadCount(0) |
| @@ -178,8 +179,12 @@ |
| GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageFormat, size.width(), size.height())); |
| } else |
| GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); |
| + |
| + Mailbox mailbox; |
| + GLC(context3d, context3d->genMailboxCHROMIUM(mailbox.name)); |
|
piman
2012/11/07 00:49:55
I've been thinking about this more, and I'm leanin
|
| + |
| ResourceId id = m_nextId++; |
| - Resource resource(textureId, pool, size, format); |
| + Resource resource(textureId, mailbox, pool, size, format); |
| m_resources[id] = resource; |
| return id; |
| } |
| @@ -199,9 +204,14 @@ |
| ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture(unsigned textureId) |
| { |
| DCHECK(Proxy::isImplThread()); |
| - DCHECK(m_context->context3D()); |
| + WebGraphicsContext3D* context3d = m_context->context3D(); |
| + DCHECK(context3d); |
| + |
| + Mailbox mailbox; |
| + GLC(context3d, context3d->genMailboxCHROMIUM(mailbox.name)); |
|
piman
2012/11/07 00:49:55
We don't have to do this at all here, since we won
|
| + |
| ResourceId id = m_nextId++; |
| - Resource resource(textureId, 0, gfx::Size(), 0); |
| + Resource resource(textureId, mailbox, 0, gfx::Size(), 0); |
| resource.external = true; |
| m_resources[id] = resource; |
| return id; |
| @@ -538,7 +548,6 @@ |
| DCHECK(it != m_children.end()); |
| deleteOwnedResources(it->second.pool); |
| m_children.erase(it); |
| - trimMailboxDeque(); |
| } |
| const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int child) const |
| @@ -620,9 +629,8 @@ |
| GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); |
| GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mailbox.name)); |
| ResourceId id = m_nextId++; |
| - Resource resource(textureId, childInfo.pool, it->size, it->format); |
| + Resource resource(textureId, it->mailbox, childInfo.pool, it->size, it->format); |
| m_resources[id] = resource; |
| - m_mailboxes.push_back(it->mailbox); |
| childInfo.parentToChildMap[id] = it->id; |
| childInfo.childToParentMap[it->id] = id; |
| } |
| @@ -646,7 +654,6 @@ |
| resource->exported = false; |
| GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); |
| GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mailbox.name)); |
| - m_mailboxes.push_back(it->mailbox); |
| if (resource->markedForDeletion) |
| deleteResourceInternal(mapIterator); |
| } |
| @@ -666,43 +673,12 @@ |
| resource->id = id; |
| resource->format = source->format; |
| resource->size = source->size; |
| - if (!m_mailboxes.empty()) { |
| - resource->mailbox = m_mailboxes.front(); |
| - m_mailboxes.pop_front(); |
| - } |
| - else |
| - GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); |
| + resource->mailbox = source->mailbox; |
| GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId)); |
| GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbox.name)); |
| return true; |
| } |
| -void ResourceProvider::trimMailboxDeque() |
| -{ |
| - // Trim the mailbox deque to the maximum number of resources we may need to |
| - // send. |
| - // If we have a parent, any non-external resource not already transfered is |
| - // eligible to be sent to the parent. Otherwise, all resources belonging to |
| - // a child might need to be sent back to the child. |
| - size_t maxMailboxCount = 0; |
| - if (m_context->capabilities().hasParentCompositor) { |
| - for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) { |
| - if (!it->second.exported && !it->second.external) |
| - ++maxMailboxCount; |
| - } |
| - } else { |
| - base::hash_set<int> childPoolSet; |
| - for (ChildMap::iterator it = m_children.begin(); it != m_children.end(); ++it) |
| - childPoolSet.insert(it->second.pool); |
| - for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) { |
| - if (ContainsKey(childPoolSet, it->second.pool)) |
| - ++maxMailboxCount; |
| - } |
| - } |
| - while (m_mailboxes.size() > maxMailboxCount) |
| - m_mailboxes.pop_front(); |
| -} |
| - |
| void ResourceProvider::debugNotifyEnterZone(unsigned int zone) |
| { |
| g_debugZone = zone; |