| OLD | NEW |
| 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 "cc/resource_provider.h" | 5 #include "cc/resource_provider.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 } | 753 } |
| 754 if (resources.sync_point) | 754 if (resources.sync_point) |
| 755 GLC(context3d, context3d->waitSyncPoint(resources.sync_point)); | 755 GLC(context3d, context3d->waitSyncPoint(resources.sync_point)); |
| 756 for (TransferableResourceArray::const_iterator it = resources.resources.begi
n(); it != resources.resources.end(); ++it) { | 756 for (TransferableResourceArray::const_iterator it = resources.resources.begi
n(); it != resources.resources.end(); ++it) { |
| 757 ResourceMap::iterator mapIterator = m_resources.find(it->id); | 757 ResourceMap::iterator mapIterator = m_resources.find(it->id); |
| 758 DCHECK(mapIterator != m_resources.end()); | 758 DCHECK(mapIterator != m_resources.end()); |
| 759 Resource* resource = &mapIterator->second; | 759 Resource* resource = &mapIterator->second; |
| 760 DCHECK(resource->exported); | 760 DCHECK(resource->exported); |
| 761 resource->exported = false; | 761 resource->exported = false; |
| 762 DCHECK(resource->mailbox.Equals(it->mailbox)); | 762 DCHECK(resource->mailbox.Equals(it->mailbox)); |
| 763 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); | 763 if (resource->glId) { |
| 764 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail
box.name)); | 764 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); |
| 765 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->ma
ilbox.name)); |
| 766 } else { |
| 767 resource->mailbox = TextureMailbox(resource->mailbox.name(), resource-
>mailbox.callback(), resources.sync_point); |
| 768 } |
| 765 if (resource->markedForDeletion) | 769 if (resource->markedForDeletion) |
| 766 deleteResourceInternal(mapIterator); | 770 deleteResourceInternal(mapIterator); |
| 767 } | 771 } |
| 768 } | 772 } |
| 769 | 773 |
| 770 bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI
d id, TransferableResource* resource) | 774 bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI
d id, TransferableResource* resource) |
| 771 { | 775 { |
| 772 DCHECK(m_threadChecker.CalledOnValidThread()); | 776 DCHECK(m_threadChecker.CalledOnValidThread()); |
| 773 WebGraphicsContext3D* context3d = m_outputSurface->context3d(); | 777 WebGraphicsContext3D* context3d = m_outputSurface->context3d(); |
| 774 ResourceMap::iterator it = m_resources.find(id); | 778 ResourceMap::iterator it = m_resources.find(id); |
| 775 CHECK(it != m_resources.end()); | 779 CHECK(it != m_resources.end()); |
| 776 Resource* source = &it->second; | 780 Resource* source = &it->second; |
| 777 DCHECK(!source->lockedForWrite); | 781 DCHECK(!source->lockedForWrite); |
| 778 DCHECK(!source->lockForReadCount); | 782 DCHECK(!source->lockForReadCount); |
| 779 DCHECK(!source->external || (source->external && !source->mailbox.IsEmpty())
); | 783 DCHECK(!source->external || (source->external && !source->mailbox.IsEmpty())
); |
| 780 DCHECK(source->allocated); | 784 DCHECK(source->allocated); |
| 781 if (source->exported) | 785 if (source->exported) |
| 782 return false; | 786 return false; |
| 783 resource->id = id; | 787 resource->id = id; |
| 784 resource->format = source->format; | 788 resource->format = source->format; |
| 785 resource->filter = source->filter; | 789 resource->filter = source->filter; |
| 786 resource->size = source->size; | 790 resource->size = source->size; |
| 787 | 791 |
| 788 if (source->mailbox.IsEmpty()) { | 792 if (source->mailbox.IsEmpty()) { |
| 789 GLC(context3d, context3d->genMailboxCHROMIUM(resource->mailbox.name)); | 793 GLC(context3d, context3d->genMailboxCHROMIUM(resource->mailbox.name)); |
| 790 source->mailbox.SetName(resource->mailbox); | 794 source->mailbox.SetName(resource->mailbox); |
| 791 } else | 795 } else |
| 792 resource->mailbox = source->mailbox.name(); | 796 resource->mailbox = source->mailbox.name(); |
| 793 | 797 |
| 794 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId)); | 798 if (source->glId) { |
| 795 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbo
x.name)); | 799 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId)); |
| 800 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->ma
ilbox.name)); |
| 801 } else if (source->mailbox.sync_point()) { |
| 802 GLC(context3d, context3d->waitSyncPoint(source->mailbox.sync_point())); |
| 803 source->mailbox.ResetSyncPoint(); |
| 804 } |
| 796 return true; | 805 return true; |
| 797 } | 806 } |
| 798 | 807 |
| 799 void ResourceProvider::acquirePixelBuffer(ResourceId id) | 808 void ResourceProvider::acquirePixelBuffer(ResourceId id) |
| 800 { | 809 { |
| 801 DCHECK(m_threadChecker.CalledOnValidThread()); | 810 DCHECK(m_threadChecker.CalledOnValidThread()); |
| 802 ResourceMap::iterator it = m_resources.find(id); | 811 ResourceMap::iterator it = m_resources.find(id); |
| 803 CHECK(it != m_resources.end()); | 812 CHECK(it != m_resources.end()); |
| 804 Resource* resource = &it->second; | 813 Resource* resource = &it->second; |
| 805 DCHECK(!resource->external); | 814 DCHECK(!resource->external); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 | 1127 |
| 1119 void ResourceProvider::enableReadLockFences(ResourceProvider::ResourceId id, boo
l enable) { | 1128 void ResourceProvider::enableReadLockFences(ResourceProvider::ResourceId id, boo
l enable) { |
| 1120 DCHECK(m_threadChecker.CalledOnValidThread()); | 1129 DCHECK(m_threadChecker.CalledOnValidThread()); |
| 1121 ResourceMap::iterator it = m_resources.find(id); | 1130 ResourceMap::iterator it = m_resources.find(id); |
| 1122 CHECK(it != m_resources.end()); | 1131 CHECK(it != m_resources.end()); |
| 1123 Resource* resource = &it->second; | 1132 Resource* resource = &it->second; |
| 1124 resource->enableReadLockFences = enable; | 1133 resource->enableReadLockFences = enable; |
| 1125 } | 1134 } |
| 1126 | 1135 |
| 1127 } // namespace cc | 1136 } // namespace cc |
| OLD | NEW |