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

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: not-leak USE_OZONE_GBM, GetSupportedGpuMemoryBufferConfigurations from ozone, return handle Created 5 years, 7 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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 ~ScopedWriteLockGpuMemoryBuffer() { 1063 ~ScopedWriteLockGpuMemoryBuffer() {
1064 DCHECK(thread_checker_.CalledOnValidThread()); 1064 DCHECK(thread_checker_.CalledOnValidThread());
1065 resource_provider_->UnlockForWrite(resource_); 1065 resource_provider_->UnlockForWrite(resource_);
1066 if (!gpu_memory_buffer_) 1066 if (!gpu_memory_buffer_)
1067 return; 1067 return;
1068 1068
1069 if (!resource_->image_id) { 1069 if (!resource_->image_id) {
1070 GLES2Interface* gl = resource_provider_->ContextGL(); 1070 GLES2Interface* gl = resource_provider_->ContextGL();
1071 DCHECK(gl); 1071 DCHECK(gl);
1072 1072
1073 #if defined(OS_CHROMEOS)
1074 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization
1075 // on ChromeOS to avoid some performance issues. This only works with
1076 // shared memory backed buffers. crbug.com/436314
1077 DCHECK_EQ(gpu_memory_buffer_->GetHandle().type, gfx::SHARED_MEMORY_BUFFER);
1078 #endif
1079
1080 resource_->image_id = gl->CreateImageCHROMIUM( 1073 resource_->image_id = gl->CreateImageCHROMIUM(
1081 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(), 1074 gpu_memory_buffer_->AsClientBuffer(), size_.width(), size_.height(),
1082 GLInternalFormat(resource_->format)); 1075 GLInternalFormat(resource_->format));
1083 } 1076 }
1084 1077
1085 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_); 1078 std::swap(resource_->gpu_memory_buffer, gpu_memory_buffer_);
1086 resource_->allocated = true; 1079 resource_->allocated = true;
1087 resource_->dirty_image = true; 1080 resource_->dirty_image = true;
1088 1081
1089 // GpuMemoryBuffer provides direct access to the memory used by the GPU. 1082 // GpuMemoryBuffer provides direct access to the memory used by the GPU.
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 GLES2Interface* gl = ContextGL(); 1964 GLES2Interface* gl = ContextGL();
1972 DCHECK(gl); 1965 DCHECK(gl);
1973 if (source_resource->image_id && source_resource->dirty_image) { 1966 if (source_resource->image_id && source_resource->dirty_image) {
1974 gl->BindTexture(source_resource->target, source_resource->gl_id); 1967 gl->BindTexture(source_resource->target, source_resource->gl_id);
1975 BindImageForSampling(source_resource); 1968 BindImageForSampling(source_resource);
1976 } 1969 }
1977 if (use_sync_query_) { 1970 if (use_sync_query_) {
1978 if (!source_resource->gl_read_lock_query_id) 1971 if (!source_resource->gl_read_lock_query_id)
1979 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); 1972 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id);
1980 #if defined(OS_CHROMEOS) 1973 #if defined(OS_CHROMEOS)
1981 // TODO(reveman): This avoids a performance problem on some ChromeOS 1974 // TODO(reveman): GL_COMMANDS_ISSUED_CHROMIUM is used for synchronization
1982 // devices. This needs to be removed to support native GpuMemoryBuffer 1975 // on ChromeOS to avoid some performance issues. This only works with
1983 // implementations. crbug.com/436314 1976 // shared memory backed buffers. crbug.com/436314
reveman 2015/05/14 13:22:03 GL_COMMANDS_COMPLETED_CHROMIUM has to be used with
1984 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, 1977 if (source_resource->gpu_memory_buffer->GetHandle().type ==
1985 source_resource->gl_read_lock_query_id); 1978 gfx::SHARED_MEMORY_BUFFER)
1986 #else 1979 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM,
1980 source_resource->gl_read_lock_query_id);
1981 else
1982 #endif
1987 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, 1983 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM,
1988 source_resource->gl_read_lock_query_id); 1984 source_resource->gl_read_lock_query_id);
1989 #endif
1990 } 1985 }
1991 DCHECK(!dest_resource->image_id); 1986 DCHECK(!dest_resource->image_id);
1992 dest_resource->allocated = true; 1987 dest_resource->allocated = true;
1993 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, 1988 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id,
1994 dest_resource->gl_id, 0, 0); 1989 dest_resource->gl_id, 0, 0);
1995 if (source_resource->gl_read_lock_query_id) { 1990 if (source_resource->gl_read_lock_query_id) {
1996 // End query and create a read lock fence that will prevent access to 1991 // End query and create a read lock fence that will prevent access to
1997 // source resource until CopySubTextureCHROMIUM command has completed. 1992 // source resource until CopySubTextureCHROMIUM command has completed.
1998 #if defined(OS_CHROMEOS) 1993 #if defined(OS_CHROMEOS)
1999 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); 1994 if (source_resource->gpu_memory_buffer->GetHandle().type ==
2000 #else 1995 gfx::SHARED_MEMORY_BUFFER)
2001 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 1996 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
1997 else
2002 #endif 1998 #endif
1999 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
2003 source_resource->read_lock_fence = make_scoped_refptr( 2000 source_resource->read_lock_fence = make_scoped_refptr(
2004 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); 2001 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id));
2005 } else { 2002 } else {
2006 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. 2003 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing.
2007 // Try to use one synchronous fence for as many CopyResource operations as 2004 // Try to use one synchronous fence for as many CopyResource operations as
2008 // possible as that reduce the number of times we have to synchronize with 2005 // possible as that reduce the number of times we have to synchronize with
2009 // the GL. 2006 // the GL.
2010 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) 2007 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized())
2011 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); 2008 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl));
2012 source_resource->read_lock_fence = synchronous_fence_; 2009 source_resource->read_lock_fence = synchronous_fence_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 } 2053 }
2057 2054
2058 class GrContext* ResourceProvider::GrContext(bool worker_context) const { 2055 class GrContext* ResourceProvider::GrContext(bool worker_context) const {
2059 ContextProvider* context_provider = 2056 ContextProvider* context_provider =
2060 worker_context ? output_surface_->worker_context_provider() 2057 worker_context ? output_surface_->worker_context_provider()
2061 : output_surface_->context_provider(); 2058 : output_surface_->context_provider();
2062 return context_provider ? context_provider->GrContext() : NULL; 2059 return context_provider ? context_provider->GrContext() : NULL;
2063 } 2060 }
2064 2061
2065 } // namespace cc 2062 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698