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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 389 |
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 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( | 401 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( |
341 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, | 402 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, |
342 blocking_main_thread_task_runner, highp_threshold_min, | 403 blocking_main_thread_task_runner, highp_threshold_min, |
343 use_rgba_4444_texture_format, id_allocation_chunk_size)); | 404 use_rgba_4444_texture_format, id_allocation_chunk_size, |
| 405 use_persistent_map_for_gpu_memory_buffers)); |
344 resource_provider->Initialize(); | 406 resource_provider->Initialize(); |
345 return resource_provider; | 407 return resource_provider; |
346 } | 408 } |
347 | 409 |
348 ResourceProvider::~ResourceProvider() { | 410 ResourceProvider::~ResourceProvider() { |
349 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 411 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
350 this); | 412 this); |
351 | 413 |
352 while (!children_.empty()) | 414 while (!children_.empty()) |
353 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); | 415 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 986 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
925 // Read lock fences are required to ensure that we're not trying to map a | 987 // Read lock fences are required to ensure that we're not trying to map a |
926 // buffer that is currently in-use by the GPU. | 988 // buffer that is currently in-use by the GPU. |
927 resource_->read_lock_fences_enabled = true; | 989 resource_->read_lock_fences_enabled = true; |
928 } | 990 } |
929 | 991 |
930 gfx::GpuMemoryBuffer* | 992 gfx::GpuMemoryBuffer* |
931 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { | 993 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { |
932 if (gpu_memory_buffer_) | 994 if (gpu_memory_buffer_) |
933 return gpu_memory_buffer_; | 995 return gpu_memory_buffer_; |
| 996 gfx::BufferUsage usage = |
| 997 resource_provider_->use_persistent_map_for_gpu_memory_buffers() |
| 998 ? gfx::BufferUsage::PERSISTENT_MAP |
| 999 : gfx::BufferUsage::MAP; |
934 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = | 1000 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = |
935 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 1001 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
936 size_, BufferFormat(format_), gfx::BufferUsage::MAP); | 1002 size_, ToGpuMemoryBufferFormat(format_), usage); |
937 gpu_memory_buffer_ = gpu_memory_buffer.release(); | 1003 gpu_memory_buffer_ = gpu_memory_buffer.release(); |
938 return gpu_memory_buffer_; | 1004 return gpu_memory_buffer_; |
939 } | 1005 } |
940 | 1006 |
941 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( | 1007 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( |
942 ResourceProvider* resource_provider, | 1008 ResourceProvider* resource_provider, |
943 ResourceId resource_id) | 1009 ResourceId resource_id) |
944 : resource_provider_(resource_provider), | 1010 : resource_provider_(resource_provider), |
945 resource_(resource_provider->LockForWrite(resource_id)) { | 1011 resource_(resource_provider->LockForWrite(resource_id)) { |
946 DCHECK(thread_checker_.CalledOnValidThread()); | 1012 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 gl_->Finish(); | 1083 gl_->Finish(); |
1018 } | 1084 } |
1019 | 1085 |
1020 ResourceProvider::ResourceProvider( | 1086 ResourceProvider::ResourceProvider( |
1021 OutputSurface* output_surface, | 1087 OutputSurface* output_surface, |
1022 SharedBitmapManager* shared_bitmap_manager, | 1088 SharedBitmapManager* shared_bitmap_manager, |
1023 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 1089 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
1024 BlockingTaskRunner* blocking_main_thread_task_runner, | 1090 BlockingTaskRunner* blocking_main_thread_task_runner, |
1025 int highp_threshold_min, | 1091 int highp_threshold_min, |
1026 bool use_rgba_4444_texture_format, | 1092 bool use_rgba_4444_texture_format, |
1027 size_t id_allocation_chunk_size) | 1093 size_t id_allocation_chunk_size, |
| 1094 bool use_persistent_map_for_gpu_memory_buffers) |
1028 : output_surface_(output_surface), | 1095 : output_surface_(output_surface), |
1029 shared_bitmap_manager_(shared_bitmap_manager), | 1096 shared_bitmap_manager_(shared_bitmap_manager), |
1030 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 1097 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
1031 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 1098 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
1032 lost_output_surface_(false), | 1099 lost_output_surface_(false), |
1033 highp_threshold_min_(highp_threshold_min), | 1100 highp_threshold_min_(highp_threshold_min), |
1034 next_id_(1), | 1101 next_id_(1), |
1035 next_child_(1), | 1102 next_child_(1), |
1036 default_resource_type_(RESOURCE_TYPE_BITMAP), | 1103 default_resource_type_(RESOURCE_TYPE_BITMAP), |
1037 use_texture_storage_ext_(false), | 1104 use_texture_storage_ext_(false), |
1038 use_texture_format_bgra_(false), | 1105 use_texture_format_bgra_(false), |
1039 use_texture_usage_hint_(false), | 1106 use_texture_usage_hint_(false), |
1040 use_compressed_texture_etc1_(false), | 1107 use_compressed_texture_etc1_(false), |
1041 yuv_resource_format_(LUMINANCE_8), | 1108 yuv_resource_format_(LUMINANCE_8), |
1042 max_texture_size_(0), | 1109 max_texture_size_(0), |
1043 best_texture_format_(RGBA_8888), | 1110 best_texture_format_(RGBA_8888), |
1044 best_render_buffer_format_(RGBA_8888), | 1111 best_render_buffer_format_(RGBA_8888), |
1045 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), | 1112 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), |
1046 id_allocation_chunk_size_(id_allocation_chunk_size) { | 1113 id_allocation_chunk_size_(id_allocation_chunk_size), |
| 1114 use_sync_query_(false), |
| 1115 use_persistent_map_for_gpu_memory_buffers_( |
| 1116 use_persistent_map_for_gpu_memory_buffers) { |
1047 DCHECK(output_surface_->HasClient()); | 1117 DCHECK(output_surface_->HasClient()); |
1048 DCHECK(id_allocation_chunk_size_); | 1118 DCHECK(id_allocation_chunk_size_); |
1049 } | 1119 } |
1050 | 1120 |
1051 void ResourceProvider::Initialize() { | 1121 void ResourceProvider::Initialize() { |
1052 DCHECK(thread_checker_.CalledOnValidThread()); | 1122 DCHECK(thread_checker_.CalledOnValidThread()); |
1053 | 1123 |
1054 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). | 1124 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). |
1055 // Don't register a dump provider in these cases. | 1125 // Don't register a dump provider in these cases. |
1056 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 | 1126 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 DCHECK(resource->image_id); | 1840 DCHECK(resource->image_id); |
1771 | 1841 |
1772 // Release image currently bound to texture. | 1842 // Release image currently bound to texture. |
1773 if (resource->bound_image_id) | 1843 if (resource->bound_image_id) |
1774 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); | 1844 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); |
1775 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); | 1845 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); |
1776 resource->bound_image_id = resource->image_id; | 1846 resource->bound_image_id = resource->image_id; |
1777 resource->dirty_image = false; | 1847 resource->dirty_image = false; |
1778 } | 1848 } |
1779 | 1849 |
| 1850 void ResourceProvider::CopyResource(ResourceId source_id, |
| 1851 ResourceId dest_id, |
| 1852 const gfx::Rect& rect) { |
| 1853 TRACE_EVENT0("cc", "ResourceProvider::CopyResource"); |
| 1854 |
| 1855 Resource* source_resource = GetResource(source_id); |
| 1856 DCHECK(!source_resource->lock_for_read_count); |
| 1857 DCHECK(source_resource->origin == Resource::INTERNAL); |
| 1858 DCHECK_EQ(source_resource->exported_count, 0); |
| 1859 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, source_resource->type); |
| 1860 LazyAllocate(source_resource); |
| 1861 |
| 1862 Resource* dest_resource = GetResource(dest_id); |
| 1863 DCHECK(!dest_resource->locked_for_write); |
| 1864 DCHECK(!dest_resource->lock_for_read_count); |
| 1865 DCHECK(dest_resource->origin == Resource::INTERNAL); |
| 1866 DCHECK_EQ(dest_resource->exported_count, 0); |
| 1867 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, dest_resource->type); |
| 1868 LazyAllocate(dest_resource); |
| 1869 |
| 1870 DCHECK_EQ(source_resource->type, dest_resource->type); |
| 1871 DCHECK_EQ(source_resource->format, dest_resource->format); |
| 1872 DCHECK(source_resource->size == dest_resource->size); |
| 1873 DCHECK(gfx::Rect(dest_resource->size).Contains(rect)); |
| 1874 |
| 1875 GLES2Interface* gl = ContextGL(); |
| 1876 DCHECK(gl); |
| 1877 if (source_resource->image_id && source_resource->dirty_image) { |
| 1878 gl->BindTexture(source_resource->target, source_resource->gl_id); |
| 1879 BindImageForSampling(source_resource); |
| 1880 } |
| 1881 if (use_sync_query_) { |
| 1882 if (!source_resource->gl_read_lock_query_id) |
| 1883 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); |
| 1884 #if defined(OS_CHROMEOS) |
| 1885 // TODO(reveman): This avoids a performance problem on some ChromeOS |
| 1886 // devices. This needs to be removed to support native GpuMemoryBuffer |
| 1887 // implementations. crbug.com/436314 |
| 1888 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, |
| 1889 source_resource->gl_read_lock_query_id); |
| 1890 #else |
| 1891 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, |
| 1892 source_resource->gl_read_lock_query_id); |
| 1893 #endif |
| 1894 } |
| 1895 DCHECK(!dest_resource->image_id); |
| 1896 dest_resource->allocated = true; |
| 1897 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, |
| 1898 dest_resource->gl_id, rect.x(), rect.y(), rect.x(), |
| 1899 rect.y(), rect.width(), rect.height(), |
| 1900 false, false, false); |
| 1901 if (source_resource->gl_read_lock_query_id) { |
| 1902 // End query and create a read lock fence that will prevent access to |
| 1903 // source resource until CopySubTextureCHROMIUM command has completed. |
| 1904 #if defined(OS_CHROMEOS) |
| 1905 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); |
| 1906 #else |
| 1907 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 1908 #endif |
| 1909 source_resource->read_lock_fence = make_scoped_refptr( |
| 1910 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); |
| 1911 } else { |
| 1912 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. |
| 1913 // Try to use one synchronous fence for as many CopyResource operations as |
| 1914 // possible as that reduce the number of times we have to synchronize with |
| 1915 // the GL. |
| 1916 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) |
| 1917 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); |
| 1918 source_resource->read_lock_fence = synchronous_fence_; |
| 1919 source_resource->read_lock_fence->Set(); |
| 1920 } |
| 1921 } |
| 1922 |
1780 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { | 1923 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { |
1781 Resource* resource = GetResource(id); | 1924 Resource* resource = GetResource(id); |
1782 DCHECK_EQ(resource->exported_count, 0); | 1925 DCHECK_EQ(resource->exported_count, 0); |
1783 DCHECK(resource->allocated); | 1926 DCHECK(resource->allocated); |
1784 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) | 1927 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) |
1785 return; | 1928 return; |
1786 if (!resource->mailbox.sync_point()) | 1929 if (!resource->mailbox.sync_point()) |
1787 return; | 1930 return; |
1788 DCHECK(resource->mailbox.IsValid()); | 1931 DCHECK(resource->mailbox.IsValid()); |
1789 GLES2Interface* gl = ContextGL(); | 1932 GLES2Interface* gl = ContextGL(); |
1790 DCHECK(gl); | 1933 DCHECK(gl); |
1791 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); | 1934 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); |
1792 resource->mailbox.set_sync_point(0); | 1935 resource->mailbox.set_sync_point(0); |
1793 } | 1936 } |
1794 | 1937 |
| 1938 void ResourceProvider::WaitReadLockIfNeeded(ResourceId id) { |
| 1939 Resource* resource = GetResource(id); |
| 1940 DCHECK_EQ(resource->exported_count, 0); |
| 1941 if (!resource->read_lock_fence.get()) |
| 1942 return; |
| 1943 |
| 1944 resource->read_lock_fence->Wait(); |
| 1945 } |
| 1946 |
1795 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 1947 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
1796 GLint active_unit = 0; | 1948 GLint active_unit = 0; |
1797 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1949 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1798 return active_unit; | 1950 return active_unit; |
1799 } | 1951 } |
1800 | 1952 |
1801 void ResourceProvider::ValidateResource(ResourceId id) const { | 1953 void ResourceProvider::ValidateResource(ResourceId id) const { |
1802 DCHECK(thread_checker_.CalledOnValidThread()); | 1954 DCHECK(thread_checker_.CalledOnValidThread()); |
1803 DCHECK(id); | 1955 DCHECK(id); |
1804 DCHECK(resources_.find(id) != resources_.end()); | 1956 DCHECK(resources_.find(id) != resources_.end()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 const int kImportance = 2; | 2009 const int kImportance = 2; |
1858 pmd->CreateSharedGlobalAllocatorDump(guid); | 2010 pmd->CreateSharedGlobalAllocatorDump(guid); |
1859 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2011 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1860 } | 2012 } |
1861 } | 2013 } |
1862 | 2014 |
1863 return true; | 2015 return true; |
1864 } | 2016 } |
1865 | 2017 |
1866 } // namespace cc | 2018 } // namespace cc |
OLD | NEW |