| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 // implementations. crbug.com/436314 | 2096 // implementations. crbug.com/436314 |
| 2101 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, | 2097 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, |
| 2102 source_resource->gl_read_lock_query_id); | 2098 source_resource->gl_read_lock_query_id); |
| 2103 #else | 2099 #else |
| 2104 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, | 2100 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, |
| 2105 source_resource->gl_read_lock_query_id); | 2101 source_resource->gl_read_lock_query_id); |
| 2106 #endif | 2102 #endif |
| 2107 } | 2103 } |
| 2108 DCHECK(!dest_resource->image_id); | 2104 DCHECK(!dest_resource->image_id); |
| 2109 dest_resource->allocated = true; | 2105 dest_resource->allocated = true; |
| 2110 gl->CopyTextureCHROMIUM(dest_resource->target, | 2106 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, |
| 2111 source_resource->gl_id, | 2107 dest_resource->gl_id, 0, 0); |
| 2112 dest_resource->gl_id, | |
| 2113 0, | |
| 2114 GLInternalFormat(dest_resource->format), | |
| 2115 GLDataType(dest_resource->format)); | |
| 2116 if (source_resource->gl_read_lock_query_id) { | 2108 if (source_resource->gl_read_lock_query_id) { |
| 2117 // End query and create a read lock fence that will prevent access to | 2109 // End query and create a read lock fence that will prevent access to |
| 2118 // source resource until CopyTextureCHROMIUM command has completed. | 2110 // source resource until CopySubTextureCHROMIUM command has completed. |
| 2119 #if defined(OS_CHROMEOS) | 2111 #if defined(OS_CHROMEOS) |
| 2120 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); | 2112 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); |
| 2121 #else | 2113 #else |
| 2122 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | 2114 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 2123 #endif | 2115 #endif |
| 2124 source_resource->read_lock_fence = make_scoped_refptr( | 2116 source_resource->read_lock_fence = make_scoped_refptr( |
| 2125 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); | 2117 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); |
| 2126 } else { | 2118 } else { |
| 2127 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. | 2119 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. |
| 2128 // Try to use one synchronous fence for as many CopyResource operations as | 2120 // Try to use one synchronous fence for as many CopyResource operations as |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 } | 2163 } |
| 2172 | 2164 |
| 2173 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 2165 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
| 2174 ContextProvider* context_provider = | 2166 ContextProvider* context_provider = |
| 2175 worker_context ? output_surface_->worker_context_provider() | 2167 worker_context ? output_surface_->worker_context_provider() |
| 2176 : output_surface_->context_provider(); | 2168 : output_surface_->context_provider(); |
| 2177 return context_provider ? context_provider->GrContext() : NULL; | 2169 return context_provider ? context_provider->GrContext() : NULL; |
| 2178 } | 2170 } |
| 2179 | 2171 |
| 2180 } // namespace cc | 2172 } // namespace cc |
| OLD | NEW |