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 11 matching lines...) Expand all Loading... |
22 #include "gpu/GLES2/gl2extchromium.h" | 22 #include "gpu/GLES2/gl2extchromium.h" |
23 #include "gpu/command_buffer/client/gles2_interface.h" | 23 #include "gpu/command_buffer/client/gles2_interface.h" |
24 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 24 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
25 #include "third_party/khronos/GLES2/gl2.h" | 25 #include "third_party/khronos/GLES2/gl2.h" |
26 #include "third_party/khronos/GLES2/gl2ext.h" | 26 #include "third_party/khronos/GLES2/gl2ext.h" |
27 #include "third_party/skia/include/core/SkSurface.h" | 27 #include "third_party/skia/include/core/SkSurface.h" |
28 #include "third_party/skia/include/gpu/GrContext.h" | 28 #include "third_party/skia/include/gpu/GrContext.h" |
29 #include "third_party/skia/include/gpu/GrTextureProvider.h" | 29 #include "third_party/skia/include/gpu/GrTextureProvider.h" |
30 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
31 #include "ui/gfx/geometry/vector2d.h" | 31 #include "ui/gfx/geometry/vector2d.h" |
32 #include "ui/gfx/gpu_memory_buffer.h" | |
33 | 32 |
34 using gpu::gles2::GLES2Interface; | 33 using gpu::gles2::GLES2Interface; |
35 | 34 |
36 namespace cc { | 35 namespace cc { |
37 | 36 |
38 class IdAllocator { | 37 class IdAllocator { |
39 public: | 38 public: |
40 virtual ~IdAllocator() {} | 39 virtual ~IdAllocator() {} |
41 | 40 |
42 virtual GLuint NextId() = 0; | 41 virtual GLuint NextId() = 0; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return kBGRA_8888_GrPixelConfig; | 105 return kBGRA_8888_GrPixelConfig; |
107 case RGBA_4444: | 106 case RGBA_4444: |
108 return kRGBA_4444_GrPixelConfig; | 107 return kRGBA_4444_GrPixelConfig; |
109 default: | 108 default: |
110 break; | 109 break; |
111 } | 110 } |
112 DCHECK(false) << "Unsupported resource format."; | 111 DCHECK(false) << "Unsupported resource format."; |
113 return kSkia8888_GrPixelConfig; | 112 return kSkia8888_GrPixelConfig; |
114 } | 113 } |
115 | 114 |
116 gfx::GpuMemoryBuffer::Format ToGpuMemoryBufferFormat(ResourceFormat format) { | |
117 switch (format) { | |
118 case RGBA_8888: | |
119 return gfx::GpuMemoryBuffer::RGBA_8888; | |
120 case BGRA_8888: | |
121 return gfx::GpuMemoryBuffer::BGRA_8888; | |
122 case RGBA_4444: | |
123 return gfx::GpuMemoryBuffer::RGBA_4444; | |
124 case ALPHA_8: | |
125 case LUMINANCE_8: | |
126 case RGB_565: | |
127 case ETC1: | |
128 case RED_8: | |
129 break; | |
130 } | |
131 NOTREACHED(); | |
132 return gfx::GpuMemoryBuffer::RGBA_8888; | |
133 } | |
134 | |
135 class ScopedSetActiveTexture { | 115 class ScopedSetActiveTexture { |
136 public: | 116 public: |
137 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) | 117 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) |
138 : gl_(gl), unit_(unit) { | 118 : gl_(gl), unit_(unit) { |
139 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); | 119 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); |
140 | 120 |
141 if (unit_ != GL_TEXTURE0) | 121 if (unit_ != GL_TEXTURE0) |
142 gl_->ActiveTexture(unit_); | 122 gl_->ActiveTexture(unit_); |
143 } | 123 } |
144 | 124 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 next_id_index_ = 0; | 175 next_id_index_ = 0; |
196 } | 176 } |
197 | 177 |
198 return ids_[next_id_index_++]; | 178 return ids_[next_id_index_++]; |
199 } | 179 } |
200 | 180 |
201 private: | 181 private: |
202 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); | 182 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); |
203 }; | 183 }; |
204 | 184 |
205 // Query object based fence implementation used to detect completion of copy | |
206 // texture operations. Fence has passed when query result is available. | |
207 class CopyTextureFence : public ResourceProvider::Fence { | |
208 public: | |
209 CopyTextureFence(gpu::gles2::GLES2Interface* gl, unsigned query_id) | |
210 : gl_(gl), query_id_(query_id) {} | |
211 | |
212 // Overridden from ResourceProvider::Fence: | |
213 void Set() override {} | |
214 bool HasPassed() override { | |
215 unsigned available = 1; | |
216 gl_->GetQueryObjectuivEXT( | |
217 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); | |
218 if (!available) | |
219 return false; | |
220 | |
221 ProcessResult(); | |
222 return true; | |
223 } | |
224 void Wait() override { | |
225 // ProcessResult() will wait for result to become available. | |
226 ProcessResult(); | |
227 } | |
228 | |
229 private: | |
230 ~CopyTextureFence() override {} | |
231 | |
232 void ProcessResult() { | |
233 unsigned time_elapsed_us = 0; | |
234 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_EXT, &time_elapsed_us); | |
235 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.CopyTextureLatency", time_elapsed_us, | |
236 0, 256000, 50); | |
237 } | |
238 | |
239 gpu::gles2::GLES2Interface* gl_; | |
240 unsigned query_id_; | |
241 | |
242 DISALLOW_COPY_AND_ASSIGN(CopyTextureFence); | |
243 }; | |
244 | |
245 } // namespace | 185 } // namespace |
246 | 186 |
247 ResourceProvider::Resource::~Resource() {} | 187 ResourceProvider::Resource::~Resource() {} |
248 | 188 |
249 ResourceProvider::Resource::Resource(GLuint texture_id, | 189 ResourceProvider::Resource::Resource(GLuint texture_id, |
250 const gfx::Size& size, | 190 const gfx::Size& size, |
251 Origin origin, | 191 Origin origin, |
252 GLenum target, | 192 GLenum target, |
253 GLenum filter, | 193 GLenum filter, |
254 GLenum texture_pool, | 194 GLenum texture_pool, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 325 |
386 ResourceProvider::Child::~Child() {} | 326 ResourceProvider::Child::~Child() {} |
387 | 327 |
388 scoped_ptr<ResourceProvider> ResourceProvider::Create( | 328 scoped_ptr<ResourceProvider> ResourceProvider::Create( |
389 OutputSurface* output_surface, | 329 OutputSurface* output_surface, |
390 SharedBitmapManager* shared_bitmap_manager, | 330 SharedBitmapManager* shared_bitmap_manager, |
391 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 331 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
392 BlockingTaskRunner* blocking_main_thread_task_runner, | 332 BlockingTaskRunner* blocking_main_thread_task_runner, |
393 int highp_threshold_min, | 333 int highp_threshold_min, |
394 bool use_rgba_4444_texture_format, | 334 bool use_rgba_4444_texture_format, |
395 size_t id_allocation_chunk_size, | 335 size_t id_allocation_chunk_size) { |
396 bool use_persistent_map_for_gpu_memory_buffers) { | |
397 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( | 336 scoped_ptr<ResourceProvider> resource_provider(new ResourceProvider( |
398 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, | 337 output_surface, shared_bitmap_manager, gpu_memory_buffer_manager, |
399 blocking_main_thread_task_runner, highp_threshold_min, | 338 blocking_main_thread_task_runner, highp_threshold_min, |
400 use_rgba_4444_texture_format, id_allocation_chunk_size, | 339 use_rgba_4444_texture_format, id_allocation_chunk_size)); |
401 use_persistent_map_for_gpu_memory_buffers)); | |
402 resource_provider->Initialize(); | 340 resource_provider->Initialize(); |
403 return resource_provider; | 341 return resource_provider; |
404 } | 342 } |
405 | 343 |
406 ResourceProvider::~ResourceProvider() { | 344 ResourceProvider::~ResourceProvider() { |
407 while (!children_.empty()) | 345 while (!children_.empty()) |
408 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); | 346 DestroyChildInternal(children_.begin(), FOR_SHUTDOWN); |
409 while (!resources_.empty()) | 347 while (!resources_.empty()) |
410 DeleteResourceInternal(resources_.begin(), FOR_SHUTDOWN); | 348 DeleteResourceInternal(resources_.begin(), FOR_SHUTDOWN); |
411 | 349 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 917 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
980 // Read lock fences are required to ensure that we're not trying to map a | 918 // Read lock fences are required to ensure that we're not trying to map a |
981 // buffer that is currently in-use by the GPU. | 919 // buffer that is currently in-use by the GPU. |
982 resource_->read_lock_fences_enabled = true; | 920 resource_->read_lock_fences_enabled = true; |
983 } | 921 } |
984 | 922 |
985 gfx::GpuMemoryBuffer* | 923 gfx::GpuMemoryBuffer* |
986 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { | 924 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { |
987 if (gpu_memory_buffer_) | 925 if (gpu_memory_buffer_) |
988 return gpu_memory_buffer_; | 926 return gpu_memory_buffer_; |
989 gfx::GpuMemoryBuffer::Usage usage = | |
990 resource_provider_->use_persistent_map_for_gpu_memory_buffers() | |
991 ? gfx::GpuMemoryBuffer::PERSISTENT_MAP | |
992 : gfx::GpuMemoryBuffer::MAP; | |
993 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = | 927 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = |
994 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 928 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
995 size_, ToGpuMemoryBufferFormat(format_), usage); | 929 size_, GpuMemoryBufferFormat(format_), gfx::GpuMemoryBuffer::MAP); |
996 gpu_memory_buffer_ = gpu_memory_buffer.release(); | 930 gpu_memory_buffer_ = gpu_memory_buffer.release(); |
997 return gpu_memory_buffer_; | 931 return gpu_memory_buffer_; |
998 } | 932 } |
999 | 933 |
1000 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( | 934 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( |
1001 ResourceProvider* resource_provider, | 935 ResourceProvider* resource_provider, |
1002 ResourceId resource_id) | 936 ResourceId resource_id) |
1003 : resource_provider_(resource_provider), | 937 : resource_provider_(resource_provider), |
1004 resource_(resource_provider->LockForWrite(resource_id)) { | 938 resource_(resource_provider->LockForWrite(resource_id)) { |
1005 DCHECK(thread_checker_.CalledOnValidThread()); | 939 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 gl_->Finish(); | 1010 gl_->Finish(); |
1077 } | 1011 } |
1078 | 1012 |
1079 ResourceProvider::ResourceProvider( | 1013 ResourceProvider::ResourceProvider( |
1080 OutputSurface* output_surface, | 1014 OutputSurface* output_surface, |
1081 SharedBitmapManager* shared_bitmap_manager, | 1015 SharedBitmapManager* shared_bitmap_manager, |
1082 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 1016 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
1083 BlockingTaskRunner* blocking_main_thread_task_runner, | 1017 BlockingTaskRunner* blocking_main_thread_task_runner, |
1084 int highp_threshold_min, | 1018 int highp_threshold_min, |
1085 bool use_rgba_4444_texture_format, | 1019 bool use_rgba_4444_texture_format, |
1086 size_t id_allocation_chunk_size, | 1020 size_t id_allocation_chunk_size) |
1087 bool use_persistent_map_for_gpu_memory_buffers) | |
1088 : output_surface_(output_surface), | 1021 : output_surface_(output_surface), |
1089 shared_bitmap_manager_(shared_bitmap_manager), | 1022 shared_bitmap_manager_(shared_bitmap_manager), |
1090 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 1023 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
1091 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 1024 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
1092 lost_output_surface_(false), | 1025 lost_output_surface_(false), |
1093 highp_threshold_min_(highp_threshold_min), | 1026 highp_threshold_min_(highp_threshold_min), |
1094 next_id_(1), | 1027 next_id_(1), |
1095 next_child_(1), | 1028 next_child_(1), |
1096 default_resource_type_(RESOURCE_TYPE_BITMAP), | 1029 default_resource_type_(RESOURCE_TYPE_BITMAP), |
1097 use_texture_storage_ext_(false), | 1030 use_texture_storage_ext_(false), |
1098 use_texture_format_bgra_(false), | 1031 use_texture_format_bgra_(false), |
1099 use_texture_usage_hint_(false), | 1032 use_texture_usage_hint_(false), |
1100 use_compressed_texture_etc1_(false), | 1033 use_compressed_texture_etc1_(false), |
1101 yuv_resource_format_(LUMINANCE_8), | 1034 yuv_resource_format_(LUMINANCE_8), |
1102 max_texture_size_(0), | 1035 max_texture_size_(0), |
1103 best_texture_format_(RGBA_8888), | 1036 best_texture_format_(RGBA_8888), |
1104 best_render_buffer_format_(RGBA_8888), | 1037 best_render_buffer_format_(RGBA_8888), |
1105 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), | 1038 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), |
1106 id_allocation_chunk_size_(id_allocation_chunk_size), | 1039 id_allocation_chunk_size_(id_allocation_chunk_size) { |
1107 use_sync_query_(false), | |
1108 use_persistent_map_for_gpu_memory_buffers_( | |
1109 use_persistent_map_for_gpu_memory_buffers) { | |
1110 DCHECK(output_surface_->HasClient()); | 1040 DCHECK(output_surface_->HasClient()); |
1111 DCHECK(id_allocation_chunk_size_); | 1041 DCHECK(id_allocation_chunk_size_); |
1112 } | 1042 } |
1113 | 1043 |
1114 void ResourceProvider::Initialize() { | 1044 void ResourceProvider::Initialize() { |
1115 DCHECK(thread_checker_.CalledOnValidThread()); | 1045 DCHECK(thread_checker_.CalledOnValidThread()); |
1116 | 1046 |
1117 GLES2Interface* gl = ContextGL(); | 1047 GLES2Interface* gl = ContextGL(); |
1118 if (!gl) { | 1048 if (!gl) { |
1119 default_resource_type_ = RESOURCE_TYPE_BITMAP; | 1049 default_resource_type_ = RESOURCE_TYPE_BITMAP; |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 DCHECK(resource->image_id); | 1755 DCHECK(resource->image_id); |
1826 | 1756 |
1827 // Release image currently bound to texture. | 1757 // Release image currently bound to texture. |
1828 if (resource->bound_image_id) | 1758 if (resource->bound_image_id) |
1829 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); | 1759 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); |
1830 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); | 1760 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); |
1831 resource->bound_image_id = resource->image_id; | 1761 resource->bound_image_id = resource->image_id; |
1832 resource->dirty_image = false; | 1762 resource->dirty_image = false; |
1833 } | 1763 } |
1834 | 1764 |
1835 void ResourceProvider::CopyResource(ResourceId source_id, | |
1836 ResourceId dest_id, | |
1837 const gfx::Rect& rect) { | |
1838 TRACE_EVENT0("cc", "ResourceProvider::CopyResource"); | |
1839 | |
1840 Resource* source_resource = GetResource(source_id); | |
1841 DCHECK(!source_resource->lock_for_read_count); | |
1842 DCHECK(source_resource->origin == Resource::INTERNAL); | |
1843 DCHECK_EQ(source_resource->exported_count, 0); | |
1844 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, source_resource->type); | |
1845 LazyAllocate(source_resource); | |
1846 | |
1847 Resource* dest_resource = GetResource(dest_id); | |
1848 DCHECK(!dest_resource->locked_for_write); | |
1849 DCHECK(!dest_resource->lock_for_read_count); | |
1850 DCHECK(dest_resource->origin == Resource::INTERNAL); | |
1851 DCHECK_EQ(dest_resource->exported_count, 0); | |
1852 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, dest_resource->type); | |
1853 LazyAllocate(dest_resource); | |
1854 | |
1855 DCHECK_EQ(source_resource->type, dest_resource->type); | |
1856 DCHECK_EQ(source_resource->format, dest_resource->format); | |
1857 DCHECK(source_resource->size == dest_resource->size); | |
1858 DCHECK(gfx::Rect(dest_resource->size).Contains(rect)); | |
1859 | |
1860 GLES2Interface* gl = ContextGL(); | |
1861 DCHECK(gl); | |
1862 if (source_resource->image_id && source_resource->dirty_image) { | |
1863 gl->BindTexture(source_resource->target, source_resource->gl_id); | |
1864 BindImageForSampling(source_resource); | |
1865 } | |
1866 if (use_sync_query_) { | |
1867 if (!source_resource->gl_read_lock_query_id) | |
1868 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); | |
1869 #if defined(OS_CHROMEOS) | |
1870 // TODO(reveman): This avoids a performance problem on some ChromeOS | |
1871 // devices. This needs to be removed to support native GpuMemoryBuffer | |
1872 // implementations. crbug.com/436314 | |
1873 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, | |
1874 source_resource->gl_read_lock_query_id); | |
1875 #else | |
1876 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, | |
1877 source_resource->gl_read_lock_query_id); | |
1878 #endif | |
1879 } | |
1880 DCHECK(!dest_resource->image_id); | |
1881 dest_resource->allocated = true; | |
1882 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, | |
1883 dest_resource->gl_id, rect.x(), rect.y(), rect.x(), | |
1884 rect.y(), rect.width(), rect.height(), | |
1885 false, false, false); | |
1886 if (source_resource->gl_read_lock_query_id) { | |
1887 // End query and create a read lock fence that will prevent access to | |
1888 // source resource until CopySubTextureCHROMIUM command has completed. | |
1889 #if defined(OS_CHROMEOS) | |
1890 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); | |
1891 #else | |
1892 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | |
1893 #endif | |
1894 source_resource->read_lock_fence = make_scoped_refptr( | |
1895 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); | |
1896 } else { | |
1897 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. | |
1898 // 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 | |
1900 // the GL. | |
1901 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) | |
1902 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); | |
1903 source_resource->read_lock_fence = synchronous_fence_; | |
1904 source_resource->read_lock_fence->Set(); | |
1905 } | |
1906 } | |
1907 | |
1908 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { | 1765 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { |
1909 Resource* resource = GetResource(id); | 1766 Resource* resource = GetResource(id); |
1910 DCHECK_EQ(resource->exported_count, 0); | 1767 DCHECK_EQ(resource->exported_count, 0); |
1911 DCHECK(resource->allocated); | 1768 DCHECK(resource->allocated); |
1912 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) | 1769 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) |
1913 return; | 1770 return; |
1914 if (!resource->mailbox.sync_point()) | 1771 if (!resource->mailbox.sync_point()) |
1915 return; | 1772 return; |
1916 DCHECK(resource->mailbox.IsValid()); | 1773 DCHECK(resource->mailbox.IsValid()); |
1917 GLES2Interface* gl = ContextGL(); | 1774 GLES2Interface* gl = ContextGL(); |
1918 DCHECK(gl); | 1775 DCHECK(gl); |
1919 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); | 1776 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); |
1920 resource->mailbox.set_sync_point(0); | 1777 resource->mailbox.set_sync_point(0); |
1921 } | 1778 } |
1922 | 1779 |
1923 void ResourceProvider::WaitReadLockIfNeeded(ResourceId id) { | |
1924 Resource* resource = GetResource(id); | |
1925 DCHECK_EQ(resource->exported_count, 0); | |
1926 if (!resource->read_lock_fence.get()) | |
1927 return; | |
1928 | |
1929 resource->read_lock_fence->Wait(); | |
1930 } | |
1931 | |
1932 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 1780 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
1933 GLint active_unit = 0; | 1781 GLint active_unit = 0; |
1934 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1782 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1935 return active_unit; | 1783 return active_unit; |
1936 } | 1784 } |
1937 | 1785 |
1938 void ResourceProvider::ValidateResource(ResourceId id) const { | 1786 void ResourceProvider::ValidateResource(ResourceId id) const { |
1939 DCHECK(thread_checker_.CalledOnValidThread()); | 1787 DCHECK(thread_checker_.CalledOnValidThread()); |
1940 DCHECK(id); | 1788 DCHECK(id); |
1941 DCHECK(resources_.find(id) != resources_.end()); | 1789 DCHECK(resources_.find(id) != resources_.end()); |
1942 } | 1790 } |
1943 | 1791 |
1944 GLES2Interface* ResourceProvider::ContextGL() const { | 1792 GLES2Interface* ResourceProvider::ContextGL() const { |
1945 ContextProvider* context_provider = output_surface_->context_provider(); | 1793 ContextProvider* context_provider = output_surface_->context_provider(); |
1946 return context_provider ? context_provider->ContextGL() : NULL; | 1794 return context_provider ? context_provider->ContextGL() : NULL; |
1947 } | 1795 } |
1948 | 1796 |
1949 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 1797 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
1950 ContextProvider* context_provider = | 1798 ContextProvider* context_provider = |
1951 worker_context ? output_surface_->worker_context_provider() | 1799 worker_context ? output_surface_->worker_context_provider() |
1952 : output_surface_->context_provider(); | 1800 : output_surface_->context_provider(); |
1953 return context_provider ? context_provider->GrContext() : NULL; | 1801 return context_provider ? context_provider->GrContext() : NULL; |
1954 } | 1802 } |
1955 | 1803 |
1956 } // namespace cc | 1804 } // namespace cc |
OLD | NEW |