Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: cc/resource_provider.cc

Issue 11366123: Uber Comp: never change mailbox name associated with a texture object. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resource_provider.h ('k') | cc/resource_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/resource_provider.h" 7 #include "cc/resource_provider.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); 171 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE));
172 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); 172 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE));
173 173
174 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer) 174 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer)
175 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); 175 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
176 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { 176 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) {
177 GLenum storageFormat = textureToStorageFormat(format); 177 GLenum storageFormat = textureToStorageFormat(format);
178 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height())); 178 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height()));
179 } else 179 } else
180 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); 180 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0));
181
181 ResourceId id = m_nextId++; 182 ResourceId id = m_nextId++;
182 Resource resource(textureId, pool, size, format); 183 Resource resource(textureId, pool, size, format);
183 m_resources[id] = resource; 184 m_resources[id] = resource;
184 return id; 185 return id;
185 } 186 }
186 187
187 ResourceProvider::ResourceId ResourceProvider::createBitmap(int pool, const gfx: :Size& size) 188 ResourceProvider::ResourceId ResourceProvider::createBitmap(int pool, const gfx: :Size& size)
188 { 189 {
189 DCHECK(Proxy::isImplThread()); 190 DCHECK(Proxy::isImplThread());
190 191
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 return child; 532 return child;
532 } 533 }
533 534
534 void ResourceProvider::destroyChild(int child) 535 void ResourceProvider::destroyChild(int child)
535 { 536 {
536 DCHECK(Proxy::isImplThread()); 537 DCHECK(Proxy::isImplThread());
537 ChildMap::iterator it = m_children.find(child); 538 ChildMap::iterator it = m_children.find(child);
538 DCHECK(it != m_children.end()); 539 DCHECK(it != m_children.end());
539 deleteOwnedResources(it->second.pool); 540 deleteOwnedResources(it->second.pool);
540 m_children.erase(it); 541 m_children.erase(it);
541 trimMailboxDeque();
542 } 542 }
543 543
544 const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int child) const 544 const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int child) const
545 { 545 {
546 DCHECK(Proxy::isImplThread()); 546 DCHECK(Proxy::isImplThread());
547 ChildMap::const_iterator it = m_children.find(child); 547 ChildMap::const_iterator it = m_children.find(child);
548 DCHECK(it != m_children.end()); 548 DCHECK(it != m_children.end());
549 return it->second.childToParentMap; 549 return it->second.childToParentMap;
550 } 550 }
551 551
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 GLC(context3d, context3d->waitSyncPoint(resources.sync_point)); 614 GLC(context3d, context3d->waitSyncPoint(resources.sync_point));
615 } 615 }
616 Child& childInfo = m_children.find(child)->second; 616 Child& childInfo = m_children.find(child)->second;
617 for (TransferableResourceArray::const_iterator it = resources.resources.begi n(); it != resources.resources.end(); ++it) { 617 for (TransferableResourceArray::const_iterator it = resources.resources.begi n(); it != resources.resources.end(); ++it) {
618 unsigned textureId; 618 unsigned textureId;
619 GLC(context3d, textureId = context3d->createTexture()); 619 GLC(context3d, textureId = context3d->createTexture());
620 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); 620 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
621 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail box.name)); 621 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail box.name));
622 ResourceId id = m_nextId++; 622 ResourceId id = m_nextId++;
623 Resource resource(textureId, childInfo.pool, it->size, it->format); 623 Resource resource(textureId, childInfo.pool, it->size, it->format);
624 resource.mailbox.setName(it->mailbox.name);
624 m_resources[id] = resource; 625 m_resources[id] = resource;
625 m_mailboxes.push_back(it->mailbox);
626 childInfo.parentToChildMap[id] = it->id; 626 childInfo.parentToChildMap[id] = it->id;
627 childInfo.childToParentMap[it->id] = id; 627 childInfo.childToParentMap[it->id] = id;
628 } 628 }
629 } 629 }
630 630
631 void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc es) 631 void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc es)
632 { 632 {
633 DCHECK(Proxy::isImplThread()); 633 DCHECK(Proxy::isImplThread());
634 WebGraphicsContext3D* context3d = m_context->context3D(); 634 WebGraphicsContext3D* context3d = m_context->context3D();
635 if (!context3d || !context3d->makeContextCurrent()) { 635 if (!context3d || !context3d->makeContextCurrent()) {
636 // FIXME: Implement this path for software compositing. 636 // FIXME: Implement this path for software compositing.
637 return; 637 return;
638 } 638 }
639 if (resources.sync_point) 639 if (resources.sync_point)
640 GLC(context3d, context3d->waitSyncPoint(resources.sync_point)); 640 GLC(context3d, context3d->waitSyncPoint(resources.sync_point));
641 for (TransferableResourceArray::const_iterator it = resources.resources.begi n(); it != resources.resources.end(); ++it) { 641 for (TransferableResourceArray::const_iterator it = resources.resources.begi n(); it != resources.resources.end(); ++it) {
642 ResourceMap::iterator mapIterator = m_resources.find(it->id); 642 ResourceMap::iterator mapIterator = m_resources.find(it->id);
643 DCHECK(mapIterator != m_resources.end()); 643 DCHECK(mapIterator != m_resources.end());
644 Resource* resource = &mapIterator->second; 644 Resource* resource = &mapIterator->second;
645 DCHECK(resource->exported); 645 DCHECK(resource->exported);
646 resource->exported = false; 646 resource->exported = false;
647 resource->mailbox.setName(it->mailbox.name);
647 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); 648 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
648 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail box.name)); 649 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail box.name));
649 m_mailboxes.push_back(it->mailbox);
650 if (resource->markedForDeletion) 650 if (resource->markedForDeletion)
651 deleteResourceInternal(mapIterator); 651 deleteResourceInternal(mapIterator);
652 } 652 }
653 } 653 }
654 654
655 bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI d id, TransferableResource* resource) 655 bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI d id, TransferableResource* resource)
656 { 656 {
657 DCHECK(Proxy::isImplThread()); 657 DCHECK(Proxy::isImplThread());
658 ResourceMap::const_iterator it = m_resources.find(id); 658 WebGraphicsContext3D* context3d = m_context->context3D();
659 ResourceMap::iterator it = m_resources.find(id);
659 CHECK(it != m_resources.end()); 660 CHECK(it != m_resources.end());
660 const Resource* source = &it->second; 661 Resource* source = &it->second;
661 DCHECK(!source->lockedForWrite); 662 DCHECK(!source->lockedForWrite);
662 DCHECK(!source->lockForReadCount); 663 DCHECK(!source->lockForReadCount);
663 DCHECK(!source->external); 664 DCHECK(!source->external);
664 if (source->exported) 665 if (source->exported)
665 return false; 666 return false;
666 resource->id = id; 667 resource->id = id;
667 resource->format = source->format; 668 resource->format = source->format;
668 resource->size = source->size; 669 resource->size = source->size;
669 if (!m_mailboxes.empty()) { 670
670 resource->mailbox = m_mailboxes.front(); 671 if (source->mailbox.isZero()) {
671 m_mailboxes.pop_front(); 672 GLbyte name[GL_MAILBOX_SIZE_CHROMIUM];
673 GLC(context3d, context3d->genMailboxCHROMIUM(name));
apatrick_chromium 2012/11/08 21:36:09 Counting the needed mailboxes is obviously possibl
674 source->mailbox.setName(name);
672 } 675 }
673 else 676
674 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); 677 resource->mailbox = source->mailbox;
675 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId)); 678 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId));
676 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbo x.name)); 679 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbo x.name));
677 return true; 680 return true;
678 } 681 }
679 682
680 void ResourceProvider::trimMailboxDeque()
681 {
682 // Trim the mailbox deque to the maximum number of resources we may need to
683 // send.
684 // If we have a parent, any non-external resource not already transfered is
685 // eligible to be sent to the parent. Otherwise, all resources belonging to
686 // a child might need to be sent back to the child.
687 size_t maxMailboxCount = 0;
688 if (m_context->capabilities().hasParentCompositor) {
689 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.e nd(); ++it) {
690 if (!it->second.exported && !it->second.external)
691 ++maxMailboxCount;
692 }
693 } else {
694 base::hash_set<int> childPoolSet;
695 for (ChildMap::iterator it = m_children.begin(); it != m_children.end(); ++it)
696 childPoolSet.insert(it->second.pool);
697 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.e nd(); ++it) {
698 if (ContainsKey(childPoolSet, it->second.pool))
699 ++maxMailboxCount;
700 }
701 }
702 while (m_mailboxes.size() > maxMailboxCount)
703 m_mailboxes.pop_front();
704 }
705
706 void ResourceProvider::debugNotifyEnterZone(unsigned int zone) 683 void ResourceProvider::debugNotifyEnterZone(unsigned int zone)
707 { 684 {
708 g_debugZone = zone; 685 g_debugZone = zone;
709 } 686 }
710 687
711 void ResourceProvider::debugNotifyLeaveZone() 688 void ResourceProvider::debugNotifyLeaveZone()
712 { 689 {
713 g_debugZone = 0; 690 g_debugZone = 0;
714 } 691 }
715 692
716 693
717 } // namespace cc 694 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource_provider.h ('k') | cc/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698