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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 // GpuMemoryBuffer provides direct access to the memory used by the GPU. | 914 // GpuMemoryBuffer provides direct access to the memory used by the GPU. |
977 // Read lock fences are required to ensure that we're not trying to map a | 915 // Read lock fences are required to ensure that we're not trying to map a |
978 // buffer that is currently in-use by the GPU. | 916 // buffer that is currently in-use by the GPU. |
979 resource_->read_lock_fences_enabled = true; | 917 resource_->read_lock_fences_enabled = true; |
980 } | 918 } |
981 | 919 |
982 gfx::GpuMemoryBuffer* | 920 gfx::GpuMemoryBuffer* |
983 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { | 921 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::GetGpuMemoryBuffer() { |
984 if (gpu_memory_buffer_) | 922 if (gpu_memory_buffer_) |
985 return gpu_memory_buffer_; | 923 return gpu_memory_buffer_; |
986 gfx::GpuMemoryBuffer::Usage usage = | |
987 resource_provider_->use_persistent_map_for_gpu_memory_buffers() | |
988 ? gfx::GpuMemoryBuffer::PERSISTENT_MAP | |
989 : gfx::GpuMemoryBuffer::MAP; | |
990 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = | 924 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer = |
991 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 925 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
992 size_, ToGpuMemoryBufferFormat(format_), usage); | 926 size_, ToGpuMemoryBufferFormat(format_), gfx::GpuMemoryBuffer::MAP); |
993 gpu_memory_buffer_ = gpu_memory_buffer.release(); | 927 gpu_memory_buffer_ = gpu_memory_buffer.release(); |
994 return gpu_memory_buffer_; | 928 return gpu_memory_buffer_; |
995 } | 929 } |
996 | 930 |
997 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( | 931 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( |
998 ResourceProvider* resource_provider, | 932 ResourceProvider* resource_provider, |
999 ResourceId resource_id) | 933 ResourceId resource_id) |
1000 : resource_provider_(resource_provider), | 934 : resource_provider_(resource_provider), |
1001 resource_(resource_provider->LockForWrite(resource_id)) { | 935 resource_(resource_provider->LockForWrite(resource_id)) { |
1002 DCHECK(thread_checker_.CalledOnValidThread()); | 936 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 gl_->Finish(); | 1007 gl_->Finish(); |
1074 } | 1008 } |
1075 | 1009 |
1076 ResourceProvider::ResourceProvider( | 1010 ResourceProvider::ResourceProvider( |
1077 OutputSurface* output_surface, | 1011 OutputSurface* output_surface, |
1078 SharedBitmapManager* shared_bitmap_manager, | 1012 SharedBitmapManager* shared_bitmap_manager, |
1079 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 1013 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
1080 BlockingTaskRunner* blocking_main_thread_task_runner, | 1014 BlockingTaskRunner* blocking_main_thread_task_runner, |
1081 int highp_threshold_min, | 1015 int highp_threshold_min, |
1082 bool use_rgba_4444_texture_format, | 1016 bool use_rgba_4444_texture_format, |
1083 size_t id_allocation_chunk_size, | 1017 size_t id_allocation_chunk_size) |
1084 bool use_persistent_map_for_gpu_memory_buffers) | |
1085 : output_surface_(output_surface), | 1018 : output_surface_(output_surface), |
1086 shared_bitmap_manager_(shared_bitmap_manager), | 1019 shared_bitmap_manager_(shared_bitmap_manager), |
1087 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 1020 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
1088 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), | 1021 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), |
1089 lost_output_surface_(false), | 1022 lost_output_surface_(false), |
1090 highp_threshold_min_(highp_threshold_min), | 1023 highp_threshold_min_(highp_threshold_min), |
1091 next_id_(1), | 1024 next_id_(1), |
1092 next_child_(1), | 1025 next_child_(1), |
1093 default_resource_type_(RESOURCE_TYPE_BITMAP), | 1026 default_resource_type_(RESOURCE_TYPE_BITMAP), |
1094 use_texture_storage_ext_(false), | 1027 use_texture_storage_ext_(false), |
1095 use_texture_format_bgra_(false), | 1028 use_texture_format_bgra_(false), |
1096 use_texture_usage_hint_(false), | 1029 use_texture_usage_hint_(false), |
1097 use_compressed_texture_etc1_(false), | 1030 use_compressed_texture_etc1_(false), |
1098 yuv_resource_format_(LUMINANCE_8), | 1031 yuv_resource_format_(LUMINANCE_8), |
1099 max_texture_size_(0), | 1032 max_texture_size_(0), |
1100 best_texture_format_(RGBA_8888), | 1033 best_texture_format_(RGBA_8888), |
1101 best_render_buffer_format_(RGBA_8888), | 1034 best_render_buffer_format_(RGBA_8888), |
1102 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), | 1035 use_rgba_4444_texture_format_(use_rgba_4444_texture_format), |
1103 id_allocation_chunk_size_(id_allocation_chunk_size), | 1036 id_allocation_chunk_size_(id_allocation_chunk_size) { |
1104 use_sync_query_(false), | |
1105 use_persistent_map_for_gpu_memory_buffers_( | |
1106 use_persistent_map_for_gpu_memory_buffers) { | |
1107 DCHECK(output_surface_->HasClient()); | 1037 DCHECK(output_surface_->HasClient()); |
1108 DCHECK(id_allocation_chunk_size_); | 1038 DCHECK(id_allocation_chunk_size_); |
1109 } | 1039 } |
1110 | 1040 |
1111 void ResourceProvider::Initialize() { | 1041 void ResourceProvider::Initialize() { |
1112 DCHECK(thread_checker_.CalledOnValidThread()); | 1042 DCHECK(thread_checker_.CalledOnValidThread()); |
1113 | 1043 |
1114 GLES2Interface* gl = ContextGL(); | 1044 GLES2Interface* gl = ContextGL(); |
1115 if (!gl) { | 1045 if (!gl) { |
1116 default_resource_type_ = RESOURCE_TYPE_BITMAP; | 1046 default_resource_type_ = RESOURCE_TYPE_BITMAP; |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 DCHECK(resource->image_id); | 1754 DCHECK(resource->image_id); |
1825 | 1755 |
1826 // Release image currently bound to texture. | 1756 // Release image currently bound to texture. |
1827 if (resource->bound_image_id) | 1757 if (resource->bound_image_id) |
1828 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); | 1758 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); |
1829 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); | 1759 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); |
1830 resource->bound_image_id = resource->image_id; | 1760 resource->bound_image_id = resource->image_id; |
1831 resource->dirty_image = false; | 1761 resource->dirty_image = false; |
1832 } | 1762 } |
1833 | 1763 |
1834 void ResourceProvider::CopyResource(ResourceId source_id, | |
1835 ResourceId dest_id, | |
1836 const gfx::Rect& rect) { | |
1837 TRACE_EVENT0("cc", "ResourceProvider::CopyResource"); | |
1838 | |
1839 Resource* source_resource = GetResource(source_id); | |
1840 DCHECK(!source_resource->lock_for_read_count); | |
1841 DCHECK(source_resource->origin == Resource::INTERNAL); | |
1842 DCHECK_EQ(source_resource->exported_count, 0); | |
1843 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, source_resource->type); | |
1844 LazyAllocate(source_resource); | |
1845 | |
1846 Resource* dest_resource = GetResource(dest_id); | |
1847 DCHECK(!dest_resource->locked_for_write); | |
1848 DCHECK(!dest_resource->lock_for_read_count); | |
1849 DCHECK(dest_resource->origin == Resource::INTERNAL); | |
1850 DCHECK_EQ(dest_resource->exported_count, 0); | |
1851 DCHECK_EQ(RESOURCE_TYPE_GL_TEXTURE, dest_resource->type); | |
1852 LazyAllocate(dest_resource); | |
1853 | |
1854 DCHECK_EQ(source_resource->type, dest_resource->type); | |
1855 DCHECK_EQ(source_resource->format, dest_resource->format); | |
1856 DCHECK(source_resource->size == dest_resource->size); | |
1857 DCHECK(gfx::Rect(dest_resource->size).Contains(rect)); | |
1858 | |
1859 GLES2Interface* gl = ContextGL(); | |
1860 DCHECK(gl); | |
1861 if (source_resource->image_id && source_resource->dirty_image) { | |
1862 gl->BindTexture(source_resource->target, source_resource->gl_id); | |
1863 BindImageForSampling(source_resource); | |
1864 } | |
1865 if (use_sync_query_) { | |
1866 if (!source_resource->gl_read_lock_query_id) | |
1867 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); | |
1868 #if defined(OS_CHROMEOS) | |
1869 // TODO(reveman): This avoids a performance problem on some ChromeOS | |
1870 // devices. This needs to be removed to support native GpuMemoryBuffer | |
1871 // implementations. crbug.com/436314 | |
1872 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, | |
1873 source_resource->gl_read_lock_query_id); | |
1874 #else | |
1875 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, | |
1876 source_resource->gl_read_lock_query_id); | |
1877 #endif | |
1878 } | |
1879 DCHECK(!dest_resource->image_id); | |
1880 dest_resource->allocated = true; | |
1881 gl->CopySubTextureCHROMIUM(dest_resource->target, source_resource->gl_id, | |
1882 dest_resource->gl_id, rect.x(), rect.y(), rect.x(), | |
1883 rect.y(), rect.width(), rect.height(), | |
1884 false, false, false); | |
1885 if (source_resource->gl_read_lock_query_id) { | |
1886 // End query and create a read lock fence that will prevent access to | |
1887 // source resource until CopySubTextureCHROMIUM command has completed. | |
1888 #if defined(OS_CHROMEOS) | |
1889 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); | |
1890 #else | |
1891 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | |
1892 #endif | |
1893 source_resource->read_lock_fence = make_scoped_refptr( | |
1894 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id)); | |
1895 } else { | |
1896 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. | |
1897 // Try to use one synchronous fence for as many CopyResource operations as | |
1898 // possible as that reduce the number of times we have to synchronize with | |
1899 // the GL. | |
1900 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) | |
1901 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); | |
1902 source_resource->read_lock_fence = synchronous_fence_; | |
1903 source_resource->read_lock_fence->Set(); | |
1904 } | |
1905 } | |
1906 | |
1907 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { | 1764 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { |
1908 Resource* resource = GetResource(id); | 1765 Resource* resource = GetResource(id); |
1909 DCHECK_EQ(resource->exported_count, 0); | 1766 DCHECK_EQ(resource->exported_count, 0); |
1910 DCHECK(resource->allocated); | 1767 DCHECK(resource->allocated); |
1911 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) | 1768 if (resource->type != RESOURCE_TYPE_GL_TEXTURE || resource->gl_id) |
1912 return; | 1769 return; |
1913 if (!resource->mailbox.sync_point()) | 1770 if (!resource->mailbox.sync_point()) |
1914 return; | 1771 return; |
1915 DCHECK(resource->mailbox.IsValid()); | 1772 DCHECK(resource->mailbox.IsValid()); |
1916 GLES2Interface* gl = ContextGL(); | 1773 GLES2Interface* gl = ContextGL(); |
1917 DCHECK(gl); | 1774 DCHECK(gl); |
1918 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); | 1775 gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()); |
1919 resource->mailbox.set_sync_point(0); | 1776 resource->mailbox.set_sync_point(0); |
1920 } | 1777 } |
1921 | 1778 |
1922 void ResourceProvider::WaitReadLockIfNeeded(ResourceId id) { | |
1923 Resource* resource = GetResource(id); | |
1924 DCHECK_EQ(resource->exported_count, 0); | |
1925 if (!resource->read_lock_fence.get()) | |
1926 return; | |
1927 | |
1928 resource->read_lock_fence->Wait(); | |
1929 } | |
1930 | |
1931 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { | 1779 GLint ResourceProvider::GetActiveTextureUnit(GLES2Interface* gl) { |
1932 GLint active_unit = 0; | 1780 GLint active_unit = 0; |
1933 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 1781 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
1934 return active_unit; | 1782 return active_unit; |
1935 } | 1783 } |
1936 | 1784 |
1937 void ResourceProvider::ValidateResource(ResourceId id) const { | 1785 void ResourceProvider::ValidateResource(ResourceId id) const { |
1938 DCHECK(thread_checker_.CalledOnValidThread()); | 1786 DCHECK(thread_checker_.CalledOnValidThread()); |
1939 DCHECK(id); | 1787 DCHECK(id); |
1940 DCHECK(resources_.find(id) != resources_.end()); | 1788 DCHECK(resources_.find(id) != resources_.end()); |
1941 } | 1789 } |
1942 | 1790 |
1943 GLES2Interface* ResourceProvider::ContextGL() const { | 1791 GLES2Interface* ResourceProvider::ContextGL() const { |
1944 ContextProvider* context_provider = output_surface_->context_provider(); | 1792 ContextProvider* context_provider = output_surface_->context_provider(); |
1945 return context_provider ? context_provider->ContextGL() : NULL; | 1793 return context_provider ? context_provider->ContextGL() : NULL; |
1946 } | 1794 } |
1947 | 1795 |
1948 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 1796 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
1949 ContextProvider* context_provider = | 1797 ContextProvider* context_provider = |
1950 worker_context ? output_surface_->worker_context_provider() | 1798 worker_context ? output_surface_->worker_context_provider() |
1951 : output_surface_->context_provider(); | 1799 : output_surface_->context_provider(); |
1952 return context_provider ? context_provider->GrContext() : NULL; | 1800 return context_provider ? context_provider->GrContext() : NULL; |
1953 } | 1801 } |
1954 | 1802 |
1955 } // namespace cc | 1803 } // namespace cc |
OLD | NEW |