Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Side by Side Diff: cc/resources/resource_provider.cc

Issue 1134993003: ozone: Implement zero/one-copy texture for Ozone GBM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to new crrev.com/1128113011 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 resource_provider_->UnlockForWrite(resource_); 950 resource_provider_->UnlockForWrite(resource_);
951 if (!gpu_memory_buffer_) 951 if (!gpu_memory_buffer_)
952 return; 952 return;
953 953
954 resource_provider_->LazyCreate(resource_); 954 resource_provider_->LazyCreate(resource_);
955 955
956 if (!resource_->image_id) { 956 if (!resource_->image_id) {
957 GLES2Interface* gl = resource_provider_->ContextGL(); 957 GLES2Interface* gl = resource_provider_->ContextGL();
958 DCHECK(gl); 958 DCHECK(gl);
959 959
960 #if defined(OS_CHROMEOS)
reveman 2015/06/25 14:07:51 we should just remove this. if there are still per
961 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization
962 // on ChromeOS to avoid some performance issues. This only works with
963 // shared memory backed buffers. crbug.com/436314
964 DCHECK_EQ(gpu_memory_buffer_->GetHandle().type, gfx::SHARED_MEMORY_BUFFER);
965 #endif
966
967 resource_->image_id = gl->CreateImageCHROMIUM( 960 resource_->image_id = gl->CreateImageCHROMIUM(
968 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(), 961 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(),
969 GLInternalFormat(resource_->format)); 962 GLInternalFormat(resource_->format));
970 } 963 }
971 964
972 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_); 965 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_);
973 resource_->allocated = true; 966 resource_->allocated = true;
974 resource_->dirty_image = true; 967 resource_->dirty_image = true;
975 968
976 // GpuMemoryBuffer provides direct access to the memory used by the GPU. 969 // GpuMemoryBuffer provides direct access to the memory used by the GPU.
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 GLES2Interface* gl = ContextGL(); 1851 GLES2Interface* gl = ContextGL();
1859 DCHECK(gl); 1852 DCHECK(gl);
1860 if (source_resource->image_id && source_resource->dirty_image) { 1853 if (source_resource->image_id && source_resource->dirty_image) {
1861 gl->BindTexture(source_resource->target, source_resource->gl_id); 1854 gl->BindTexture(source_resource->target, source_resource->gl_id);
1862 BindImageForSampling(source_resource); 1855 BindImageForSampling(source_resource);
1863 } 1856 }
1864 if (use_sync_query_) { 1857 if (use_sync_query_) {
1865 if (!source_resource->gl_read_lock_query_id) 1858 if (!source_resource->gl_read_lock_query_id)
1866 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); 1859 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id);
1867 #if defined(OS_CHROMEOS) 1860 #if defined(OS_CHROMEOS)
1868 // TODO(reveman): This avoids a performance problem on some ChromeOS 1861 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization
1869 // devices. This needs to be removed to support native GpuMemoryBuffer 1862 // on ChromeOS to avoid some performance issues. This only works with
1870 // implementations. crbug.com/436314 1863 // shared memory backed buffers. crbug.com/436314
1871 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, 1864 if (source_resource->gpu_memory_buffer->GetHandle().type ==
1872 source_resource->gl_read_lock_query_id); 1865 gfx::SHARED_MEMORY_BUFFER)
1873 #else 1866 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM,
1867 source_resource->gl_read_lock_query_id);
1868 else
dshwang 2015/06/25 14:52:13 This quirk is for ARM ChromeOS perf issue. After t
1869 #endif
1874 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, 1870 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM,
1875 source_resource->gl_read_lock_query_id); 1871 source_resource->gl_read_lock_query_id);
1876 #endif
1877 } 1872 }
1878 DCHECK(!dest_resource->image_id); 1873 DCHECK(!dest_resource->image_id);
1879 dest_resource->allocated = true; 1874 dest_resource->allocated = true;
1880 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, 1875 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id,
1881 dest_resource->gl_id, rect.x(), rect.y(), rect.x(), 1876 dest_resource->gl_id, rect.x(), rect.y(), rect.x(),
1882 rect.y(), rect.width(), rect.height(), 1877 rect.y(), rect.width(), rect.height(),
1883 false, false, false); 1878 false, false, false);
1884 if (source_resource->gl_read_lock_query_id) { 1879 if (source_resource->gl_read_lock_query_id) {
1885 // End query and create a read lock fence that will prevent access to 1880 // End query and create a read lock fence that will prevent access to
1886 // source resource until CopySubTextureCHROMIUM command has completed. 1881 // source resource until CopySubTextureCHROMIUM command has completed.
1887 #if defined(OS_CHROMEOS) 1882 #if defined(OS_CHROMEOS)
1888 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); 1883 if (source_resource->gpu_memory_buffer->GetHandle().type ==
1889 #else 1884 gfx::SHARED_MEMORY_BUFFER)
1890 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 1885 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
1886 else
1891 #endif 1887 #endif
1888 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
1892 source_resource->read_lock_fence = make_scoped_refptr( 1889 source_resource->read_lock_fence = make_scoped_refptr(
1893 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); 1890 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id));
1894 } else { 1891 } else {
1895 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. 1892 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing.
1896 // Try to use one synchronous fence for as many CopyResource operations as 1893 // Try to use one synchronous fence for as many CopyResource operations as
1897 // possible as that reduce the number of times we have to synchronize with 1894 // possible as that reduce the number of times we have to synchronize with
1898 // the GL. 1895 // the GL.
1899 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) 1896 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized())
1900 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); 1897 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl));
1901 source_resource->read_lock_fence = synchronous_fence_; 1898 source_resource->read_lock_fence = synchronous_fence_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 } 1942 }
1946 1943
1947 class GrContext* ResourceProvider::GrContext(bool worker_context) const { 1944 class GrContext* ResourceProvider::GrContext(bool worker_context) const {
1948 ContextProvider* context_provider = 1945 ContextProvider* context_provider =
1949 worker_context ? output_surface_->worker_context_provider() 1946 worker_context ? output_surface_->worker_context_provider()
1950 : output_surface_->context_provider(); 1947 : output_surface_->context_provider();
1951 return context_provider ? context_provider->GrContext() : NULL; 1948 return context_provider ? context_provider->GrContext() : NULL;
1952 } 1949 }
1953 1950
1954 } // namespace cc 1951 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698