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 14 matching lines...) Expand all Loading... |
25 #include "gpu/GLES2/gl2extchromium.h" | 25 #include "gpu/GLES2/gl2extchromium.h" |
26 #include "gpu/command_buffer/client/gles2_interface.h" | 26 #include "gpu/command_buffer/client/gles2_interface.h" |
27 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 27 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
28 #include "third_party/khronos/GLES2/gl2.h" | 28 #include "third_party/khronos/GLES2/gl2.h" |
29 #include "third_party/khronos/GLES2/gl2ext.h" | 29 #include "third_party/khronos/GLES2/gl2ext.h" |
30 #include "third_party/skia/include/core/SkSurface.h" | 30 #include "third_party/skia/include/core/SkSurface.h" |
31 #include "third_party/skia/include/gpu/GrContext.h" | 31 #include "third_party/skia/include/gpu/GrContext.h" |
32 #include "third_party/skia/include/gpu/GrTextureProvider.h" | 32 #include "third_party/skia/include/gpu/GrTextureProvider.h" |
33 #include "ui/gfx/geometry/rect.h" | 33 #include "ui/gfx/geometry/rect.h" |
34 #include "ui/gfx/geometry/vector2d.h" | 34 #include "ui/gfx/geometry/vector2d.h" |
| 35 #include "ui/gfx/gpu_memory_buffer.h" |
35 #include "ui/gl/trace_util.h" | 36 #include "ui/gl/trace_util.h" |
36 | 37 |
37 using gpu::gles2::GLES2Interface; | 38 using gpu::gles2::GLES2Interface; |
38 | 39 |
39 namespace cc { | 40 namespace cc { |
40 | 41 |
41 class IdAllocator { | 42 class IdAllocator { |
42 public: | 43 public: |
43 virtual ~IdAllocator() {} | 44 virtual ~IdAllocator() {} |
44 | 45 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return kBGRA_8888_GrPixelConfig; | 110 return kBGRA_8888_GrPixelConfig; |
110 case RGBA_4444: | 111 case RGBA_4444: |
111 return kRGBA_4444_GrPixelConfig; | 112 return kRGBA_4444_GrPixelConfig; |
112 default: | 113 default: |
113 break; | 114 break; |
114 } | 115 } |
115 DCHECK(false) << "Unsupported resource format."; | 116 DCHECK(false) << "Unsupported resource format."; |
116 return kSkia8888_GrPixelConfig; | 117 return kSkia8888_GrPixelConfig; |
117 } | 118 } |
118 | 119 |
| 120 gfx::BufferFormat ToGpuMemoryBufferFormat(ResourceFormat format) { |
| 121 switch (format) { |
| 122 case RGBA_8888: |
| 123 return gfx::BufferFormat::RGBA_8888; |
| 124 case BGRA_8888: |
| 125 return gfx::BufferFormat::BGRA_8888; |
| 126 case RGBA_4444: |
| 127 return gfx::BufferFormat::RGBA_4444; |
| 128 case ALPHA_8: |
| 129 case LUMINANCE_8: |
| 130 case RGB_565: |
| 131 case ETC1: |
| 132 case RED_8: |
| 133 break; |
| 134 } |
| 135 NOTREACHED(); |
| 136 return gfx::BufferFormat::RGBA_8888; |
| 137 } |
| 138 |
119 class ScopedSetActiveTexture { | 139 class ScopedSetActiveTexture { |
120 public: | 140 public: |
121 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) | 141 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) |
122 : gl_(gl), unit_(unit) { | 142 : gl_(gl), unit_(unit) { |
123 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); | 143 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); |
124 | 144 |
125 if (unit_ != GL_TEXTURE0) | 145 if (unit_ != GL_TEXTURE0) |
126 gl_->ActiveTexture(unit_); | 146 gl_->ActiveTexture(unit_); |
127 } | 147 } |
128 | 148 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 next_id_index_ = 0; | 199 next_id_index_ = 0; |
180 } | 200 } |
181 | 201 |
182 return ids_[next_id_index_++]; | 202 return ids_[next_id_index_++]; |
183 } | 203 } |
184 | 204 |
185 private: | 205 private: |
186 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); | 206 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); |
187 }; | 207 }; |
188 | 208 |
| 209 // Query object based fence implementation used to detect completion of copy |
| 210 // texture operations. Fence has passed when query result is available. |
| 211 class CopyTextureFence : public ResourceProvider::Fence { |
| 212 public: |
| 213 CopyTextureFence(gpu::gles2::GLES2Interface* gl, unsigned query_id) |
| 214 : gl_(gl), query_id_(query_id) {} |
| 215 |
| 216 // Overridden from ResourceProvider::Fence: |
| 217 void Set() override {} |
| 218 bool HasPassed() override { |
| 219 unsigned available = 1; |
| 220 gl_->GetQueryObjectuivEXT( |
| 221 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); |
| 222 if (!available) |
| 223 return false; |
| 224 |
| 225 ProcessResult(); |
| 226 return true; |
| 227 } |
| 228 void Wait() override { |
| 229 // ProcessResult() will wait for result to become available. |
| 230 ProcessResult(); |
| 231 } |
| 232 |
| 233 private: |
| 234 ~CopyTextureFence() override {} |
| 235 |
| 236 void ProcessResult() { |
| 237 unsigned time_elapsed_us = 0; |
| 238 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_EXT, &time_elapsed_us); |
| 239 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.CopyTextureLatency", time_elapsed_us, |
| 240 0, 256000, 50); |
| 241 } |
| 242 |
| 243 gpu::gles2::GLES2Interface* gl_; |
| 244 unsigned query_id_; |
| 245 |
| 246 DISALLOW_COPY_AND_ASSIGN(CopyTextureFence); |
| 247 }; |
| 248 |
189 } // namespace | 249 } // namespace |
190 | 250 |
191 ResourceProvider::Resource::~Resource() {} | 251 ResourceProvider::Resource::~Resource() {} |
192 | 252 |
193 ResourceProvider::Resource::Resource(GLuint texture_id, | 253 ResourceProvider::Resource::Resource(GLuint texture_id, |
194 const gfx::Size& size, | 254 const gfx::Size& size, |
195 Origin origin, | 255 Origin origin, |
196 GLenum target, | 256 GLenum target, |
197 GLenum filter, | 257 GLenum filter, |
198 GLenum texture_pool, | 258 GLenum texture_pool, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 ResourceProvider::Child::~Child() {} | 390 ResourceProvider::Child::~Child() {} |
331 | 391 |
332 scoped_ptr<ResourceProvider> ResourceProvider::Create( | 392 scoped_ptr<ResourceProvider> ResourceProvider::Create( |
333 OutputSurface* output_surface, | 393 OutputSurface* output_surface, |
334 SharedBitmapManager* shared_bitmap_manager, | 394 SharedBitmapManager* shared_bitmap_manager, |
335 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 395 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
336 BlockingTaskRunner* blocking_main_thread_task_runner, | 396 BlockingTaskRunner* blocking_main_thread_task_runner, |
337 int highp_threshold_min, | 397 int highp_threshold_min, |
338 bool use_rgba_4444_texture_format, | 398 bool use_rgba_4444_texture_format, |
339 size_t id_allocation_chunk_size, | 399 size_t id_allocation_chunk_size, |
| 400 bool use_persistent_map_for_gpu_memory_buffers, |
340 const std::vector<unsigned>& use_image_texture_targets) { | 401 const std::vector<unsigned>& use_image_texture_targets) { |
341 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( | 402 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( |
342 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, | 403 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, |
343 blocking_main_thread_task_runner, highp_threshold_min, | 404 blocking_main_thread_task_runner, highp_threshold_min, |
344 use_rgba_4444_texture_format, id_allocation_chunk_size, | 405 use_rgba_4444_texture_format, id_allocation_chunk_size, |
345 use_image_texture_targets)); | 406 use_persistent_map_for_gpu_memory_buffers, use_image_texture_targets)); |
346 resource_provider->Initialize(); | 407 resource_provider->Initialize(); |
347 return resource_provider; | 408 return resource_provider; |
348 } | 409 } |
349 | 410 |
350 ResourceProvider::~ResourceProvider() { | 411 ResourceProvider::~ResourceProvider() { |
351 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 412 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
352 this); | 413 this); |
353 | 414 |
354 while (!children_.empty()) | 415 while (!children_.empty()) |
355 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); | 416 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 987 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
927 // Read lock fences are required to ensure that we're not trying to map a | 988 // Read lock fences are required to ensure that we're not trying to map a |
928 // buffer that is currently in-use by the GPU. | 989 // buffer that is currently in-use by the GPU. |
929 resource_->read_lock_fences_enabled = true; | 990 resource_->read_lock_fences_enabled = true; |
930 } | 991 } |
931 | 992 |
932 gfx::GpuMemoryBuffer* | 993 gfx::GpuMemoryBuffer* |
933 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { | 994 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { |
934 if (gpu_memory_buffer_) | 995 if (gpu_memory_buffer_) |
935 return gpu_memory_buffer_; | 996 return gpu_memory_buffer_; |
| 997 gfx::BufferUsage usage = |
| 998 resource_provider_->use_persistent_map_for_gpu_memory_buffers() |
| 999 ? gfx::BufferUsage::PERSISTENT_MAP |
| 1000 : gfx::BufferUsage::MAP; |
936 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = | 1001 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = |
937 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 1002 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
938 size_, BufferFormat(format_), gfx::BufferUsage::MAP); | 1003 size_, ToGpuMemoryBufferFormat(format_), usage); |
939 gpu_memory_buffer_ = gpu_memory_buffer.release(); | 1004 gpu_memory_buffer_ = gpu_memory_buffer.release(); |
940 return gpu_memory_buffer_; | 1005 return gpu_memory_buffer_; |
941 } | 1006 } |
942 | 1007 |
943 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( | 1008 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( |
944 ResourceProvider* resource_provider, | 1009 ResourceProvider* resource_provider, |
945 ResourceId resource_id) | 1010 ResourceId resource_id) |
946 : resource_provider_(resource_provider), | 1011 : resource_provider_(resource_provider), |
947 resource_(resource_provider->LockForWrite(resource_id)) { | 1012 resource_(resource_provider->LockForWrite(resource_id)) { |
948 DCHECK(thread_checker_.CalledOnValidThread()); | 1013 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 } | 1085 } |
1021 | 1086 |
1022 ResourceProvider::ResourceProvider( | 1087 ResourceProvider::ResourceProvider( |
1023 OutputSurface* output_surface, | 1088 OutputSurface* output_surface, |
1024 SharedBitmapManager* shared_bitmap_manager, | 1089 SharedBitmapManager* shared_bitmap_manager, |
1025 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 1090 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
1026 BlockingTaskRunner* blocking_main_thread_task_runner, | 1091 BlockingTaskRunner* blocking_main_thread_task_runner, |
1027 int highp_threshold_min, | 1092 int highp_threshold_min, |
1028 bool use_rgba_4444_texture_format, | 1093 bool use_rgba_4444_texture_format, |
1029 size_t id_allocation_chunk_size, | 1094 size_t id_allocation_chunk_size, |
| 1095 bool use_persistent_map_for_gpu_memory_buffers, |
1030 const std::vector<unsigned>& use_image_texture_targets) | 1096 const std::vector<unsigned>& use_image_texture_targets) |
1031 : output_surface_(output_surface), | 1097 : output_surface_(output_surface), |
1032 shared_bitmap_manager_(shared_bitmap_manager), | 1098 shared_bitmap_manager_(shared_bitmap_manager), |
1033 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 1099 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
1034 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 1100 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
1035 lost_output_surface_(false), | 1101 lost_output_surface_(false), |
1036 highp_threshold_min_(highp_threshold_min), | 1102 highp_threshold_min_(highp_threshold_min), |
1037 next_id_(1), | 1103 next_id_(1), |
1038 next_child_(1), | 1104 next_child_(1), |
1039 default_resource_type_(RESOURCE_TYPE_BITMAP), | 1105 default_resource_type_(RESOURCE_TYPE_BITMAP), |
1040 use_texture_storage_ext_(false), | 1106 use_texture_storage_ext_(false), |
1041 use_texture_format_bgra_(false), | 1107 use_texture_format_bgra_(false), |
1042 use_texture_usage_hint_(false), | 1108 use_texture_usage_hint_(false), |
1043 use_compressed_texture_etc1_(false), | 1109 use_compressed_texture_etc1_(false), |
1044 yuv_resource_format_(LUMINANCE_8), | 1110 yuv_resource_format_(LUMINANCE_8), |
1045 max_texture_size_(0), | 1111 max_texture_size_(0), |
1046 best_texture_format_(RGBA_8888), | 1112 best_texture_format_(RGBA_8888), |
1047 best_render_buffer_format_(RGBA_8888), | 1113 best_render_buffer_format_(RGBA_8888), |
1048 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), | 1114 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), |
1049 id_allocation_chunk_size_(id_allocation_chunk_size), | 1115 id_allocation_chunk_size_(id_allocation_chunk_size), |
| 1116 use_sync_query_(false), |
| 1117 use_persistent_map_for_gpu_memory_buffers_( |
| 1118 use_persistent_map_for_gpu_memory_buffers), |
1050 use_image_texture_targets_(use_image_texture_targets) { | 1119 use_image_texture_targets_(use_image_texture_targets) { |
1051 DCHECK(output_surface_->HasClient()); | 1120 DCHECK(output_surface_->HasClient()); |
1052 DCHECK(id_allocation_chunk_size_); | 1121 DCHECK(id_allocation_chunk_size_); |
1053 } | 1122 } |
1054 | 1123 |
1055 void ResourceProvider::Initialize() { | 1124 void ResourceProvider::Initialize() { |
1056 DCHECK(thread_checker_.CalledOnValidThread()); | 1125 DCHECK(thread_checker_.CalledOnValidThread()); |
1057 | 1126 |
1058 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). | 1127 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). |
1059 // Don't register a dump provider in these cases. | 1128 // Don't register a dump provider in these cases. |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 DCHECK(resource->image_id); | 1843 DCHECK(resource->image_id); |
1775 | 1844 |
1776 // Release image currently bound to texture. | 1845 // Release image currently bound to texture. |
1777 if (resource->bound_image_id) | 1846 if (resource->bound_image_id) |
1778 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); | 1847 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); |
1779 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); | 1848 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); |
1780 resource->bound_image_id = resource->image_id; | 1849 resource->bound_image_id = resource->image_id; |
1781 resource->dirty_image = false; | 1850 resource->dirty_image = false; |
1782 } | 1851 } |
1783 | 1852 |
| 1853 void ResourceProvider::CopyResource(ResourceId source_id, |
| 1854 ResourceId dest_id, |
| 1855 const gfx::Rect& rect) { |
| 1856 TRACE_EVENT0("cc", "ResourceProvider::CopyResource"); |
| 1857 |
| 1858 Resource* source_resource = GetResource(source_id); |
| 1859 DCHECK(!source_resource->lock_for_read_count); |
| 1860 DCHECK(source_resource->origin == Resource::INTERNAL); |
| 1861 DCHECK_EQ(source_resource->exported_count, 0); |
| 1862 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, source_resource->type); |
| 1863 LazyAllocate(source_resource); |
| 1864 |
| 1865 Resource* dest_resource = GetResource(dest_id); |
| 1866 DCHECK(!dest_resource->locked_for_write); |
| 1867 DCHECK(!dest_resource->lock_for_read_count); |
| 1868 DCHECK(dest_resource->origin == Resource::INTERNAL); |
| 1869 DCHECK_EQ(dest_resource->exported_count, 0); |
| 1870 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, dest_resource->type); |
| 1871 LazyAllocate(dest_resource); |
| 1872 |
| 1873 DCHECK_EQ(source_resource->type, dest_resource->type); |
| 1874 DCHECK_EQ(source_resource->format, dest_resource->format); |
| 1875 DCHECK(source_resource->size == dest_resource->size); |
| 1876 DCHECK(gfx::Rect(dest_resource->size).Contains(rect)); |
| 1877 |
| 1878 GLES2Interface* gl = ContextGL(); |
| 1879 DCHECK(gl); |
| 1880 if (source_resource->image_id && source_resource->dirty_image) { |
| 1881 gl->BindTexture(source_resource->target, source_resource->gl_id); |
| 1882 BindImageForSampling(source_resource); |
| 1883 } |
| 1884 if (use_sync_query_) { |
| 1885 if (!source_resource->gl_read_lock_query_id) |
| 1886 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); |
| 1887 #if defined(OS_CHROMEOS) |
| 1888 // TODO(reveman): This avoids a performance problem on some ChromeOS |
| 1889 // devices. This needs to be removed to support native GpuMemoryBuffer |
| 1890 // implementations. crbug.com/436314 |
| 1891 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, |
| 1892 source_resource->gl_read_lock_query_id); |
| 1893 #else |
| 1894 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, |
| 1895 source_resource->gl_read_lock_query_id); |
| 1896 #endif |
| 1897 } |
| 1898 DCHECK(!dest_resource->image_id); |
| 1899 dest_resource->allocated = true; |
| 1900 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, |
| 1901 dest_resource->gl_id, rect.x(), rect.y(), rect.x(), |
| 1902 rect.y(), rect.width(), rect.height(), |
| 1903 false, false, false); |
| 1904 if (source_resource->gl_read_lock_query_id) { |
| 1905 // End query and create a read lock fence that will prevent access to |
| 1906 // source resource until CopySubTextureCHROMIUM command has completed. |
| 1907 #if defined(OS_CHROMEOS) |
| 1908 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); |
| 1909 #else |
| 1910 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 1911 #endif |
| 1912 source_resource->read_lock_fence = make_scoped_refptr( |
| 1913 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); |
| 1914 } else { |
| 1915 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. |
| 1916 // Try to use one synchronous fence for as many CopyResource operations as |
| 1917 // possible as that reduce the number of times we have to synchronize with |
| 1918 // the GL. |
| 1919 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) |
| 1920 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); |
| 1921 source_resource->read_lock_fence = synchronous_fence_; |
| 1922 source_resource->read_lock_fence->Set(); |
| 1923 } |
| 1924 } |
| 1925 |
1784 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { | 1926 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { |
1785 Resource* resource = GetResource(id); | 1927 Resource* resource = GetResource(id); |
1786 DCHECK_EQ(resource->exported_count, 0); | 1928 DCHECK_EQ(resource->exported_count, 0); |
1787 DCHECK(resource->allocated); | 1929 DCHECK(resource->allocated); |
1788 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) | 1930 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) |
1789 return; | 1931 return; |
1790 if (!resource->mailbox.sync_point()) | 1932 if (!resource->mailbox.sync_point()) |
1791 return; | 1933 return; |
1792 DCHECK(resource->mailbox.IsValid()); | 1934 DCHECK(resource->mailbox.IsValid()); |
1793 GLES2Interface* gl = ContextGL(); | 1935 GLES2Interface* gl = ContextGL(); |
1794 DCHECK(gl); | 1936 DCHECK(gl); |
1795 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); | 1937 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); |
1796 resource->mailbox.set_sync_point(0); | 1938 resource->mailbox.set_sync_point(0); |
1797 } | 1939 } |
1798 | 1940 |
| 1941 void ResourceProvider::WaitReadLockIfNeeded(ResourceId id) { |
| 1942 Resource* resource = GetResource(id); |
| 1943 DCHECK_EQ(resource->exported_count, 0); |
| 1944 if (!resource->read_lock_fence.get()) |
| 1945 return; |
| 1946 |
| 1947 resource->read_lock_fence->Wait(); |
| 1948 } |
| 1949 |
1799 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 1950 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
1800 GLint active_unit = 0; | 1951 GLint active_unit = 0; |
1801 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1952 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1802 return active_unit; | 1953 return active_unit; |
1803 } | 1954 } |
1804 | 1955 |
1805 GLenum ResourceProvider::GetImageTextureTarget(ResourceFormat format) { | 1956 GLenum ResourceProvider::GetImageTextureTarget(ResourceFormat format) { |
1806 gfx::BufferFormat buffer_format = BufferFormat(format); | 1957 gfx::BufferFormat buffer_format = ToGpuMemoryBufferFormat(format); |
1807 DCHECK_GT(use_image_texture_targets_.size(), | 1958 DCHECK_GT(use_image_texture_targets_.size(), |
1808 static_cast<size_t>(buffer_format)); | 1959 static_cast<size_t>(buffer_format)); |
1809 return use_image_texture_targets_[static_cast<size_t>(buffer_format)]; | 1960 return use_image_texture_targets_[static_cast<size_t>(buffer_format)]; |
1810 } | 1961 } |
1811 | 1962 |
1812 void ResourceProvider::ValidateResource(ResourceId id) const { | 1963 void ResourceProvider::ValidateResource(ResourceId id) const { |
1813 DCHECK(thread_checker_.CalledOnValidThread()); | 1964 DCHECK(thread_checker_.CalledOnValidThread()); |
1814 DCHECK(id); | 1965 DCHECK(id); |
1815 DCHECK(resources_.find(id) != resources_.end()); | 1966 DCHECK(resources_.find(id) != resources_.end()); |
1816 } | 1967 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 const int kImportance = 2; | 2020 const int kImportance = 2; |
1870 pmd->CreateSharedGlobalAllocatorDump(guid); | 2021 pmd->CreateSharedGlobalAllocatorDump(guid); |
1871 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2022 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1872 } | 2023 } |
1873 } | 2024 } |
1874 | 2025 |
1875 return true; | 2026 return true; |
1876 } | 2027 } |
1877 | 2028 |
1878 } // namespace cc | 2029 } // namespace cc |
OLD | NEW |