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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 if (resource->type == GLTexture && !resource->gl_id) { | 869 if (resource->type == GLTexture && !resource->gl_id) { |
870 DCHECK(resource->origin != Resource::Internal); | 870 DCHECK(resource->origin != Resource::Internal); |
871 DCHECK(resource->mailbox.IsTexture()); | 871 DCHECK(resource->mailbox.IsTexture()); |
872 | 872 |
873 // Mailbox sync_points must be processed by a call to | 873 // Mailbox sync_points must be processed by a call to |
874 // WaitSyncPointIfNeeded() prior to calling LockForRead(). | 874 // WaitSyncPointIfNeeded() prior to calling LockForRead(). |
875 DCHECK(!resource->mailbox.sync_point()); | 875 DCHECK(!resource->mailbox.sync_point()); |
876 | 876 |
877 GLES2Interface* gl = ContextGL(); | 877 GLES2Interface* gl = ContextGL(); |
878 DCHECK(gl); | 878 DCHECK(gl); |
879 resource->gl_id = texture_id_allocator_->NextId(); | 879 resource->gl_id = |
880 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); | 880 GLC(gl, |
881 GLC(gl, | 881 gl->CreateAndConsumeTextureCHROMIUM(resource->mailbox.target(), |
882 gl->ConsumeTextureCHROMIUM(resource->mailbox.target(), | 882 resource->mailbox.name())); |
883 resource->mailbox.name())); | |
884 } | 883 } |
885 | 884 |
886 if (!resource->pixels && resource->has_shared_bitmap_id && | 885 if (!resource->pixels && resource->has_shared_bitmap_id && |
887 shared_bitmap_manager_) { | 886 shared_bitmap_manager_) { |
888 scoped_ptr<SharedBitmap> bitmap = | 887 scoped_ptr<SharedBitmap> bitmap = |
889 shared_bitmap_manager_->GetSharedBitmapFromId( | 888 shared_bitmap_manager_->GetSharedBitmapFromId( |
890 resource->size, resource->shared_bitmap_id); | 889 resource->size, resource->shared_bitmap_id); |
891 if (bitmap) { | 890 if (bitmap) { |
892 resource->shared_bitmap = bitmap.release(); | 891 resource->shared_bitmap = bitmap.release(); |
893 resource->pixels = resource->shared_bitmap->pixels(); | 892 resource->pixels = resource->shared_bitmap->pixels(); |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 resource->is_repeated = (source->wrap_mode == GL_REPEAT); | 1521 resource->is_repeated = (source->wrap_mode == GL_REPEAT); |
1523 resource->allow_overlay = source->allow_overlay; | 1522 resource->allow_overlay = source->allow_overlay; |
1524 | 1523 |
1525 if (source->type == Bitmap) { | 1524 if (source->type == Bitmap) { |
1526 resource->mailbox_holder.mailbox = source->shared_bitmap_id; | 1525 resource->mailbox_holder.mailbox = source->shared_bitmap_id; |
1527 resource->is_software = true; | 1526 resource->is_software = true; |
1528 } else if (!source->mailbox.IsValid()) { | 1527 } else if (!source->mailbox.IsValid()) { |
1529 LazyCreate(source); | 1528 LazyCreate(source); |
1530 DCHECK(source->gl_id); | 1529 DCHECK(source->gl_id); |
1531 DCHECK(source->origin == Resource::Internal); | 1530 DCHECK(source->origin == Resource::Internal); |
1532 GLC(gl, | 1531 |
1533 gl->BindTexture(resource->mailbox_holder.texture_target, | |
1534 source->gl_id)); | |
1535 if (source->image_id) { | 1532 if (source->image_id) { |
1536 DCHECK(source->dirty_image); | 1533 DCHECK(source->dirty_image); |
1537 BindImageForSampling(source); | 1534 BindImageForSampling(source); |
1538 } | 1535 } |
1539 // This is a resource allocated by the compositor, we need to produce it. | 1536 // This is a resource allocated by the compositor, we need to produce it. |
1540 // Don't set a sync point, the caller will do it. | 1537 // Don't set a sync point, the caller will do it. |
1541 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); | 1538 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); |
1542 GLC(gl, | 1539 GLC(gl, |
1543 gl->ProduceTextureCHROMIUM(resource->mailbox_holder.texture_target, | 1540 gl->ProduceTextureDirectCHROMIUM( |
1544 resource->mailbox_holder.mailbox.name)); | 1541 source->gl_id, |
| 1542 resource->mailbox_holder.texture_target, |
| 1543 resource->mailbox_holder.mailbox.name)); |
| 1544 |
1545 source->mailbox = TextureMailbox(resource->mailbox_holder); | 1545 source->mailbox = TextureMailbox(resource->mailbox_holder); |
1546 } else { | 1546 } else { |
1547 DCHECK(source->mailbox.IsTexture()); | 1547 DCHECK(source->mailbox.IsTexture()); |
1548 if (source->image_id && source->dirty_image) { | 1548 if (source->image_id && source->dirty_image) { |
1549 DCHECK(source->gl_id); | 1549 DCHECK(source->gl_id); |
1550 DCHECK(source->origin == Resource::Internal); | 1550 DCHECK(source->origin == Resource::Internal); |
1551 GLC(gl, | 1551 GLC(gl, |
1552 gl->BindTexture(resource->mailbox_holder.texture_target, | 1552 gl->BindTexture(resource->mailbox_holder.texture_target, |
1553 source->gl_id)); | 1553 source->gl_id)); |
1554 BindImageForSampling(source); | 1554 BindImageForSampling(source); |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2077 ContextProvider* context_provider = output_surface_->context_provider(); | 2077 ContextProvider* context_provider = output_surface_->context_provider(); |
2078 return context_provider ? context_provider->ContextGL() : NULL; | 2078 return context_provider ? context_provider->ContextGL() : NULL; |
2079 } | 2079 } |
2080 | 2080 |
2081 class GrContext* ResourceProvider::GrContext() const { | 2081 class GrContext* ResourceProvider::GrContext() const { |
2082 ContextProvider* context_provider = output_surface_->context_provider(); | 2082 ContextProvider* context_provider = output_surface_->context_provider(); |
2083 return context_provider ? context_provider->GrContext() : NULL; | 2083 return context_provider ? context_provider->GrContext() : NULL; |
2084 } | 2084 } |
2085 | 2085 |
2086 } // namespace cc | 2086 } // namespace cc |
OLD | NEW |