Chromium Code Reviews| 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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 953 resource_provider_->UnlockForWrite(resource_); | 953 resource_provider_->UnlockForWrite(resource_); |
| 954 if (!gpu_memory_buffer_) | 954 if (!gpu_memory_buffer_) |
| 955 return; | 955 return; |
| 956 | 956 |
| 957 resource_provider_->LazyCreate(resource_); | 957 resource_provider_->LazyCreate(resource_); |
| 958 | 958 |
| 959 if (!resource_->image_id) { | 959 if (!resource_->image_id) { |
| 960 GLES2Interface* gl = resource_provider_->ContextGL(); | 960 GLES2Interface* gl = resource_provider_->ContextGL(); |
| 961 DCHECK(gl); | 961 DCHECK(gl); |
| 962 | 962 |
| 963 #if defined(OS_CHROMEOS) | |
| 964 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization | |
| 965 // on ChromeOS to avoid some performance issues. This only works with | |
| 966 // shared memory backed buffers. crbug.com/436314 | |
| 967 DCHECK_EQ(gpu_memory_buffer_->GetHandle().type, gfx::SHARED_MEMORY_BUFFER); | |
| 968 #endif | |
| 969 | |
| 970 resource_->image_id = gl->CreateImageCHROMIUM( | 963 resource_->image_id = gl->CreateImageCHROMIUM( |
| 971 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(), | 964 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(), |
| 972 GLInternalFormat(resource_->format)); | 965 GLInternalFormat(resource_->format)); |
| 973 } | 966 } |
| 974 | 967 |
| 975 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_); | 968 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_); |
| 976 resource_->allocated = true; | 969 resource_->allocated = true; |
| 977 resource_->dirty_image = true; | 970 resource_->dirty_image = true; |
| 978 | 971 |
| 979 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 972 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1860 GLES2Interface* gl = ContextGL(); | 1853 GLES2Interface* gl = ContextGL(); |
| 1861 DCHECK(gl); | 1854 DCHECK(gl); |
| 1862 if (source_resource->image_id && source_resource->dirty_image) { | 1855 if (source_resource->image_id && source_resource->dirty_image) { |
| 1863 gl->BindTexture(source_resource->target, source_resource->gl_id); | 1856 gl->BindTexture(source_resource->target, source_resource->gl_id); |
| 1864 BindImageForSampling(source_resource); | 1857 BindImageForSampling(source_resource); |
| 1865 } | 1858 } |
| 1866 if (use_sync_query_) { | 1859 if (use_sync_query_) { |
| 1867 if (!source_resource->gl_read_lock_query_id) | 1860 if (!source_resource->gl_read_lock_query_id) |
| 1868 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); | 1861 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); |
| 1869 #if defined(OS_CHROMEOS) | 1862 #if defined(OS_CHROMEOS) |
| 1870 // TODO(reveman): This avoids a performance problem on some ChromeOS | 1863 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization |
| 1871 // devices. This needs to be removed to support native GpuMemoryBuffer | 1864 // on ChromeOS to avoid some performance issues. This only works with |
| 1872 // implementations. crbug.com/436314 | 1865 // shared memory backed buffers. crbug.com/436314 |
| 1873 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, | 1866 if (source_resource->gpu_memory_buffer->GetHandle().type == |
| 1874 source_resource->gl_read_lock_query_id); | 1867 gfx::SHARED_MEMORY_BUFFER) |
|
dshwang
2015/08/05 12:33:16
This quirk was introduced for ARM chrome os. until
reveman
2015/08/05 14:11:49
I'd rather not make this nastier than it already i
dshwang
2015/08/06 08:30:30
Ok, I remove this change. We will resolve this iss
| |
| 1875 #else | 1868 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, |
| 1869 source_resource->gl_read_lock_query_id); | |
| 1870 else | |
| 1871 #endif | |
| 1876 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, | 1872 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, |
| 1877 source_resource->gl_read_lock_query_id); | 1873 source_resource->gl_read_lock_query_id); |
| 1878 #endif | |
| 1879 } | 1874 } |
| 1880 DCHECK(!dest_resource->image_id); | 1875 DCHECK(!dest_resource->image_id); |
| 1881 dest_resource->allocated = true; | 1876 dest_resource->allocated = true; |
| 1882 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, | 1877 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, |
| 1883 dest_resource->gl_id, rect.x(), rect.y(), rect.x(), | 1878 dest_resource->gl_id, rect.x(), rect.y(), rect.x(), |
| 1884 rect.y(), rect.width(), rect.height(), | 1879 rect.y(), rect.width(), rect.height(), |
| 1885 false, false, false); | 1880 false, false, false); |
| 1886 if (source_resource->gl_read_lock_query_id) { | 1881 if (source_resource->gl_read_lock_query_id) { |
| 1887 // End query and create a read lock fence that will prevent access to | 1882 // End query and create a read lock fence that will prevent access to |
| 1888 // source resource until CopySubTextureCHROMIUM command has completed. | 1883 // source resource until CopySubTextureCHROMIUM command has completed. |
| 1889 #if defined(OS_CHROMEOS) | 1884 #if defined(OS_CHROMEOS) |
| 1890 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); | 1885 if (source_resource->gpu_memory_buffer->GetHandle().type == |
| 1891 #else | 1886 gfx::SHARED_MEMORY_BUFFER) |
| 1892 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | 1887 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); |
| 1888 else | |
| 1893 #endif | 1889 #endif |
| 1890 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | |
| 1894 source_resource->read_lock_fence = make_scoped_refptr( | 1891 source_resource->read_lock_fence = make_scoped_refptr( |
| 1895 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); | 1892 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); |
| 1896 } else { | 1893 } else { |
| 1897 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. | 1894 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. |
| 1898 // Try to use one synchronous fence for as many CopyResource operations as | 1895 // Try to use one synchronous fence for as many CopyResource operations as |
| 1899 // possible as that reduce the number of times we have to synchronize with | 1896 // possible as that reduce the number of times we have to synchronize with |
| 1900 // the GL. | 1897 // the GL. |
| 1901 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) | 1898 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) |
| 1902 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); | 1899 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); |
| 1903 source_resource->read_lock_fence = synchronous_fence_; | 1900 source_resource->read_lock_fence = synchronous_fence_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1947 } | 1944 } |
| 1948 | 1945 |
| 1949 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 1946 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
| 1950 ContextProvider* context_provider = | 1947 ContextProvider* context_provider = |
| 1951 worker_context ? output_surface_->worker_context_provider() | 1948 worker_context ? output_surface_->worker_context_provider() |
| 1952 : output_surface_->context_provider(); | 1949 : output_surface_->context_provider(); |
| 1953 return context_provider ? context_provider->GrContext() : NULL; | 1950 return context_provider ? context_provider->GrContext() : NULL; |
| 1954 } | 1951 } |
| 1955 | 1952 |
| 1956 } // namespace cc | 1953 } // namespace cc |
| OLD | NEW |