| 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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 if (resource->type == GLTexture && !resource->gl_id) { | 836 if (resource->type == GLTexture && !resource->gl_id) { |
| 837 DCHECK(resource->origin != Resource::Internal); | 837 DCHECK(resource->origin != Resource::Internal); |
| 838 DCHECK(resource->mailbox.IsTexture()); | 838 DCHECK(resource->mailbox.IsTexture()); |
| 839 | 839 |
| 840 // Mailbox sync_points must be processed by a call to | 840 // Mailbox sync_points must be processed by a call to |
| 841 // WaitSyncPointIfNeeded() prior to calling LockForRead(). | 841 // WaitSyncPointIfNeeded() prior to calling LockForRead(). |
| 842 DCHECK(!resource->mailbox.sync_point()); | 842 DCHECK(!resource->mailbox.sync_point()); |
| 843 | 843 |
| 844 GLES2Interface* gl = ContextGL(); | 844 GLES2Interface* gl = ContextGL(); |
| 845 DCHECK(gl); | 845 DCHECK(gl); |
| 846 resource->gl_id = texture_id_allocator_->NextId(); | 846 resource->gl_id = |
| 847 GLC(gl, gl->BindTexture(resource->target, resource->gl_id)); | 847 GLC(gl, |
| 848 GLC(gl, | 848 gl->CreateAndConsumeTextureCHROMIUM(resource->mailbox.target(), |
| 849 gl->ConsumeTextureCHROMIUM(resource->mailbox.target(), | 849 resource->mailbox.name())); |
| 850 resource->mailbox.name())); | |
| 851 } | 850 } |
| 852 | 851 |
| 853 if (!resource->pixels && resource->has_shared_bitmap_id && | 852 if (!resource->pixels && resource->has_shared_bitmap_id && |
| 854 shared_bitmap_manager_) { | 853 shared_bitmap_manager_) { |
| 855 scoped_ptr<SharedBitmap> bitmap = | 854 scoped_ptr<SharedBitmap> bitmap = |
| 856 shared_bitmap_manager_->GetSharedBitmapFromId( | 855 shared_bitmap_manager_->GetSharedBitmapFromId( |
| 857 resource->size, resource->shared_bitmap_id); | 856 resource->size, resource->shared_bitmap_id); |
| 858 if (bitmap) { | 857 if (bitmap) { |
| 859 resource->shared_bitmap = bitmap.release(); | 858 resource->shared_bitmap = bitmap.release(); |
| 860 resource->pixels = resource->shared_bitmap->pixels(); | 859 resource->pixels = resource->shared_bitmap->pixels(); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 resource->is_repeated = (source->wrap_mode == GL_REPEAT); | 1508 resource->is_repeated = (source->wrap_mode == GL_REPEAT); |
| 1510 resource->allow_overlay = source->allow_overlay; | 1509 resource->allow_overlay = source->allow_overlay; |
| 1511 | 1510 |
| 1512 if (source->type == Bitmap) { | 1511 if (source->type == Bitmap) { |
| 1513 resource->mailbox_holder.mailbox = source->shared_bitmap_id; | 1512 resource->mailbox_holder.mailbox = source->shared_bitmap_id; |
| 1514 resource->is_software = true; | 1513 resource->is_software = true; |
| 1515 } else if (!source->mailbox.IsValid()) { | 1514 } else if (!source->mailbox.IsValid()) { |
| 1516 LazyCreate(source); | 1515 LazyCreate(source); |
| 1517 DCHECK(source->gl_id); | 1516 DCHECK(source->gl_id); |
| 1518 DCHECK(source->origin == Resource::Internal); | 1517 DCHECK(source->origin == Resource::Internal); |
| 1519 GLC(gl, | 1518 |
| 1520 gl->BindTexture(resource->mailbox_holder.texture_target, | |
| 1521 source->gl_id)); | |
| 1522 if (source->image_id) { | 1519 if (source->image_id) { |
| 1523 DCHECK(source->dirty_image); | 1520 DCHECK(source->dirty_image); |
| 1524 BindImageForSampling(source); | 1521 BindImageForSampling(source); |
| 1525 } | 1522 } |
| 1526 // This is a resource allocated by the compositor, we need to produce it. | 1523 // This is a resource allocated by the compositor, we need to produce it. |
| 1527 // Don't set a sync point, the caller will do it. | 1524 // Don't set a sync point, the caller will do it. |
| 1528 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); | 1525 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox_holder.mailbox.name)); |
| 1529 GLC(gl, | 1526 GLC(gl, |
| 1530 gl->ProduceTextureCHROMIUM(resource->mailbox_holder.texture_target, | 1527 gl->ProduceTextureDirectCHROMIUM( |
| 1531 resource->mailbox_holder.mailbox.name)); | 1528 source->gl_id, |
| 1529 resource->mailbox_holder.texture_target, |
| 1530 resource->mailbox_holder.mailbox.name)); |
| 1531 |
| 1532 source->mailbox = TextureMailbox(resource->mailbox_holder); | 1532 source->mailbox = TextureMailbox(resource->mailbox_holder); |
| 1533 } else { | 1533 } else { |
| 1534 DCHECK(source->mailbox.IsTexture()); | 1534 DCHECK(source->mailbox.IsTexture()); |
| 1535 if (source->image_id && source->dirty_image) { | 1535 if (source->image_id && source->dirty_image) { |
| 1536 DCHECK(source->gl_id); | 1536 DCHECK(source->gl_id); |
| 1537 DCHECK(source->origin == Resource::Internal); | 1537 DCHECK(source->origin == Resource::Internal); |
| 1538 GLC(gl, | 1538 GLC(gl, |
| 1539 gl->BindTexture(resource->mailbox_holder.texture_target, | 1539 gl->BindTexture(resource->mailbox_holder.texture_target, |
| 1540 source->gl_id)); | 1540 source->gl_id)); |
| 1541 BindImageForSampling(source); | 1541 BindImageForSampling(source); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 ContextProvider* context_provider = output_surface_->context_provider(); | 2055 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2056 return context_provider ? context_provider->ContextGL() : NULL; | 2056 return context_provider ? context_provider->ContextGL() : NULL; |
| 2057 } | 2057 } |
| 2058 | 2058 |
| 2059 class GrContext* ResourceProvider::GrContext() const { | 2059 class GrContext* ResourceProvider::GrContext() const { |
| 2060 ContextProvider* context_provider = output_surface_->context_provider(); | 2060 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2061 return context_provider ? context_provider->GrContext() : NULL; | 2061 return context_provider ? context_provider->GrContext() : NULL; |
| 2062 } | 2062 } |
| 2063 | 2063 |
| 2064 } // namespace cc | 2064 } // namespace cc |
| OLD | NEW |