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/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 if (resource->type == RESOURCE_TYPE_GL_TEXTURE && !resource->gl_id) { | 891 if (resource->type == RESOURCE_TYPE_GL_TEXTURE && !resource->gl_id) { |
892 DCHECK(resource->origin != Resource::INTERNAL); | 892 DCHECK(resource->origin != Resource::INTERNAL); |
893 DCHECK(resource->mailbox.IsTexture()); | 893 DCHECK(resource->mailbox.IsTexture()); |
894 | 894 |
895 // Mailbox sync_points must be processed by a call to | 895 // Mailbox sync_points must be processed by a call to |
896 // WaitSyncPointIfNeeded() prior to calling LockForRead(). | 896 // WaitSyncPointIfNeeded() prior to calling LockForRead(). |
897 DCHECK(!resource->mailbox.sync_point()); | 897 DCHECK(!resource->mailbox.sync_point()); |
898 | 898 |
899 GLES2Interface* gl = ContextGL(); | 899 GLES2Interface* gl = ContextGL(); |
900 DCHECK(gl); | 900 DCHECK(gl); |
901 resource->gl_id = texture_id_allocator_->NextId(); | 901 resource->gl_id = |
902 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); | 902 GLC(gl, gl->CreateAndConsumeTextureCHROMIUM(resource->mailbox.target(), |
903 GLC(gl, | 903 resource->mailbox.name())); |
904 gl->ConsumeTextureCHROMIUM(resource->mailbox.target(), | |
905 resource->mailbox.name())); | |
906 } | 904 } |
907 | 905 |
908 if (!resource->pixels && resource->has_shared_bitmap_id && | 906 if (!resource->pixels && resource->has_shared_bitmap_id && |
909 shared_bitmap_manager_) { | 907 shared_bitmap_manager_) { |
910 scoped_ptr<SharedBitmap> bitmap = | 908 scoped_ptr<SharedBitmap> bitmap = |
911 shared_bitmap_manager_->GetSharedBitmapFromId( | 909 shared_bitmap_manager_->GetSharedBitmapFromId( |
912 resource->size, resource->shared_bitmap_id); | 910 resource->size, resource->shared_bitmap_id); |
913 if (bitmap) { | 911 if (bitmap) { |
914 resource->shared_bitmap = bitmap.release(); | 912 resource->shared_bitmap = bitmap.release(); |
915 resource->pixels = resource->shared_bitmap->pixels(); | 913 resource->pixels = resource->shared_bitmap->pixels(); |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 resource->is_repeated = (source->wrap_mode == GL_REPEAT); | 1586 resource->is_repeated = (source->wrap_mode == GL_REPEAT); |
1589 resource->allow_overlay = source->allow_overlay; | 1587 resource->allow_overlay = source->allow_overlay; |
1590 | 1588 |
1591 if (source->type == RESOURCE_TYPE_BITMAP) { | 1589 if (source->type == RESOURCE_TYPE_BITMAP) { |
1592 resource->mailbox_holder.mailbox = source->shared_bitmap_id; | 1590 resource->mailbox_holder.mailbox = source->shared_bitmap_id; |
1593 resource->is_software = true; | 1591 resource->is_software = true; |
1594 } else if (!source->mailbox.IsValid()) { | 1592 } else if (!source->mailbox.IsValid()) { |
1595 LazyCreate(source); | 1593 LazyCreate(source); |
1596 DCHECK(source->gl_id); | 1594 DCHECK(source->gl_id); |
1597 DCHECK(source->origin == Resource::INTERNAL); | 1595 DCHECK(source->origin == Resource::INTERNAL); |
1598 GLC(gl, | |
1599 gl->BindTexture(resource->mailbox_holder.texture_target, | |
1600 source->gl_id)); | |
1601 if (source->image_id) { | 1596 if (source->image_id) { |
1602 DCHECK(source->dirty_image); | 1597 DCHECK(source->dirty_image); |
1603 BindImageForSampling(source); | 1598 BindImageForSampling(source); |
1604 } | 1599 } |
1605 // This is a resource allocated by the compositor, we need to produce it. | 1600 // This is a resource allocated by the compositor, we need to produce it. |
1606 // Don't set a sync point, the caller will do it. | 1601 // Don't set a sync point, the caller will do it. |
1607 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); | 1602 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); |
1608 GLC(gl, | 1603 GLC(gl, gl->ProduceTextureDirectCHROMIUM( |
1609 gl->ProduceTextureCHROMIUM(resource->mailbox_holder.texture_target, | 1604 source->gl_id, resource->mailbox_holder.texture_target, |
1610 resource->mailbox_holder.mailbox.name)); | 1605 resource->mailbox_holder.mailbox.name)); |
| 1606 |
1611 source->mailbox = TextureMailbox(resource->mailbox_holder); | 1607 source->mailbox = TextureMailbox(resource->mailbox_holder); |
1612 } else { | 1608 } else { |
1613 DCHECK(source->mailbox.IsTexture()); | 1609 DCHECK(source->mailbox.IsTexture()); |
1614 if (source->image_id && source->dirty_image) { | 1610 if (source->image_id && source->dirty_image) { |
1615 DCHECK(source->gl_id); | 1611 DCHECK(source->gl_id); |
1616 DCHECK(source->origin == Resource::INTERNAL); | 1612 DCHECK(source->origin == Resource::INTERNAL); |
1617 GLC(gl, | 1613 GLC(gl, |
1618 gl->BindTexture(resource->mailbox_holder.texture_target, | 1614 gl->BindTexture(resource->mailbox_holder.texture_target, |
1619 source->gl_id)); | 1615 source->gl_id)); |
1620 BindImageForSampling(source); | 1616 BindImageForSampling(source); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 } | 2167 } |
2172 | 2168 |
2173 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 2169 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
2174 ContextProvider* context_provider = | 2170 ContextProvider* context_provider = |
2175 worker_context ? output_surface_->worker_context_provider() | 2171 worker_context ? output_surface_->worker_context_provider() |
2176 : output_surface_->context_provider(); | 2172 : output_surface_->context_provider(); |
2177 return context_provider ? context_provider->GrContext() : NULL; | 2173 return context_provider ? context_provider->GrContext() : NULL; |
2178 } | 2174 } |
2179 | 2175 |
2180 } // namespace cc | 2176 } // namespace cc |
OLD | NEW |