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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 if (resource->type == GLTexture && !resource->gl_id) { | 861 if (resource->type == GLTexture && !resource->gl_id) { |
862 DCHECK(resource->origin != Resource::Internal); | 862 DCHECK(resource->origin != Resource::Internal); |
863 DCHECK(resource->mailbox.IsTexture()); | 863 DCHECK(resource->mailbox.IsTexture()); |
864 | 864 |
865 // Mailbox sync_points must be processed by a call to | 865 // Mailbox sync_points must be processed by a call to |
866 // WaitSyncPointIfNeeded() prior to calling LockForRead(). | 866 // WaitSyncPointIfNeeded() prior to calling LockForRead(). |
867 DCHECK(!resource->mailbox.sync_point()); | 867 DCHECK(!resource->mailbox.sync_point()); |
868 | 868 |
869 GLES2Interface* gl = ContextGL(); | 869 GLES2Interface* gl = ContextGL(); |
870 DCHECK(gl); | 870 DCHECK(gl); |
871 resource->gl_id = texture_id_allocator_->NextId(); | 871 resource->gl_id = |
872 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); | 872 GLC(gl, gl->CreateAndConsumeTextureCHROMIUM(resource->mailbox.target(), |
873 GLC(gl, | 873 resource->mailbox.name())); |
874 gl->ConsumeTextureCHROMIUM(resource->mailbox.target(), | |
875 resource->mailbox.name())); | |
876 } | 874 } |
877 | 875 |
878 if (!resource->pixels && resource->has_shared_bitmap_id && | 876 if (!resource->pixels && resource->has_shared_bitmap_id && |
879 shared_bitmap_manager_) { | 877 shared_bitmap_manager_) { |
880 scoped_ptr<SharedBitmap> bitmap = | 878 scoped_ptr<SharedBitmap> bitmap = |
881 shared_bitmap_manager_->GetSharedBitmapFromId( | 879 shared_bitmap_manager_->GetSharedBitmapFromId( |
882 resource->size, resource->shared_bitmap_id); | 880 resource->size, resource->shared_bitmap_id); |
883 if (bitmap) { | 881 if (bitmap) { |
884 resource->shared_bitmap = bitmap.release(); | 882 resource->shared_bitmap = bitmap.release(); |
885 resource->pixels = resource->shared_bitmap->pixels(); | 883 resource->pixels = resource->shared_bitmap->pixels(); |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 resource->is_repeated = (source->wrap_mode == GL_REPEAT); | 1553 resource->is_repeated = (source->wrap_mode == GL_REPEAT); |
1556 resource->allow_overlay = source->allow_overlay; | 1554 resource->allow_overlay = source->allow_overlay; |
1557 | 1555 |
1558 if (source->type == Bitmap) { | 1556 if (source->type == Bitmap) { |
1559 resource->mailbox_holder.mailbox = source->shared_bitmap_id; | 1557 resource->mailbox_holder.mailbox = source->shared_bitmap_id; |
1560 resource->is_software = true; | 1558 resource->is_software = true; |
1561 } else if (!source->mailbox.IsValid()) { | 1559 } else if (!source->mailbox.IsValid()) { |
1562 LazyCreate(source); | 1560 LazyCreate(source); |
1563 DCHECK(source->gl_id); | 1561 DCHECK(source->gl_id); |
1564 DCHECK(source->origin == Resource::Internal); | 1562 DCHECK(source->origin == Resource::Internal); |
1565 GLC(gl, | 1563 |
1566 gl->BindTexture(resource->mailbox_holder.texture_target, | |
1567 source->gl_id)); | |
1568 if (source->image_id) { | 1564 if (source->image_id) { |
1569 DCHECK(source->dirty_image); | 1565 DCHECK(source->dirty_image); |
1570 BindImageForSampling(source); | 1566 BindImageForSampling(source); |
1571 } | 1567 } |
1572 // This is a resource allocated by the compositor, we need to produce it. | 1568 // This is a resource allocated by the compositor, we need to produce it. |
1573 // Don't set a sync point, the caller will do it. | 1569 // Don't set a sync point, the caller will do it. |
1574 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); | 1570 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); |
1575 GLC(gl, | 1571 GLC(gl, gl->ProduceTextureDirectCHROMIUM( |
1576 gl->ProduceTextureCHROMIUM(resource->mailbox_holder.texture_target, | 1572 source->gl_id, resource->mailbox_holder.texture_target, |
1577 resource->mailbox_holder.mailbox.name)); | 1573 resource->mailbox_holder.mailbox.name)); |
| 1574 |
1578 source->mailbox = TextureMailbox(resource->mailbox_holder); | 1575 source->mailbox = TextureMailbox(resource->mailbox_holder); |
1579 } else { | 1576 } else { |
1580 DCHECK(source->mailbox.IsTexture()); | 1577 DCHECK(source->mailbox.IsTexture()); |
1581 if (source->image_id && source->dirty_image) { | 1578 if (source->image_id && source->dirty_image) { |
1582 DCHECK(source->gl_id); | 1579 DCHECK(source->gl_id); |
1583 DCHECK(source->origin == Resource::Internal); | 1580 DCHECK(source->origin == Resource::Internal); |
1584 GLC(gl, | 1581 GLC(gl, |
1585 gl->BindTexture(resource->mailbox_holder.texture_target, | 1582 gl->BindTexture(resource->mailbox_holder.texture_target, |
1586 source->gl_id)); | 1583 source->gl_id)); |
1587 BindImageForSampling(source); | 1584 BindImageForSampling(source); |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 ContextProvider* context_provider = output_surface_->context_provider(); | 2131 ContextProvider* context_provider = output_surface_->context_provider(); |
2135 return context_provider ? context_provider->ContextGL() : NULL; | 2132 return context_provider ? context_provider->ContextGL() : NULL; |
2136 } | 2133 } |
2137 | 2134 |
2138 class GrContext* ResourceProvider::GrContext() const { | 2135 class GrContext* ResourceProvider::GrContext() const { |
2139 ContextProvider* context_provider = output_surface_->context_provider(); | 2136 ContextProvider* context_provider = output_surface_->context_provider(); |
2140 return context_provider ? context_provider->GrContext() : NULL; | 2137 return context_provider ? context_provider->GrContext() : NULL; |
2141 } | 2138 } |
2142 | 2139 |
2143 } // namespace cc | 2140 } // namespace cc |
OLD | NEW |