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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 itr != resources_.end(); ++itr) { | 418 itr != resources_.end(); ++itr) { |
419 DCHECK(!IsGpuResourceType(itr->second.type)); | 419 DCHECK(!IsGpuResourceType(itr->second.type)); |
420 } | 420 } |
421 #endif // DCHECK_IS_ON() | 421 #endif // DCHECK_IS_ON() |
422 | 422 |
423 texture_id_allocator_ = nullptr; | 423 texture_id_allocator_ = nullptr; |
424 buffer_id_allocator_ = nullptr; | 424 buffer_id_allocator_ = nullptr; |
425 gl->Finish(); | 425 gl->Finish(); |
426 } | 426 } |
427 | 427 |
| 428 bool ResourceProvider::IsResourceFormatSupported(ResourceFormat format) const { |
| 429 ContextProvider::Capabilities caps; |
| 430 if (output_surface_->context_provider()) |
| 431 caps = output_surface_->context_provider()->ContextCapabilities(); |
| 432 |
| 433 switch (format) { |
| 434 case ALPHA_8: |
| 435 case RGBA_4444: |
| 436 case RGBA_8888: |
| 437 case RGB_565: |
| 438 case LUMINANCE_8: |
| 439 return true; |
| 440 case BGRA_8888: |
| 441 return caps.gpu.texture_format_bgra8888; |
| 442 case ETC1: |
| 443 return caps.gpu.texture_format_etc1; |
| 444 case RED_8: |
| 445 return caps.gpu.texture_rg; |
| 446 case LUMINANCE_F16: |
| 447 return caps.gpu.texture_half_float_linear; |
| 448 } |
| 449 |
| 450 NOTREACHED(); |
| 451 return false; |
| 452 } |
| 453 |
428 bool ResourceProvider::InUseByConsumer(ResourceId id) { | 454 bool ResourceProvider::InUseByConsumer(ResourceId id) { |
429 Resource* resource = GetResource(id); | 455 Resource* resource = GetResource(id); |
430 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || | 456 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || |
431 resource->lost || | 457 resource->lost || |
432 (resource->gpu_memory_buffer && | 458 (resource->gpu_memory_buffer && |
433 resource->gpu_memory_buffer->IsInUseByMacOSWindowServer()); | 459 resource->gpu_memory_buffer->IsInUseByMacOSWindowServer()); |
434 } | 460 } |
435 | 461 |
436 bool ResourceProvider::IsLost(ResourceId id) { | 462 bool ResourceProvider::IsLost(ResourceId id) { |
437 Resource* resource = GetResource(id); | 463 Resource* resource = GetResource(id); |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; | 1201 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; |
1176 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8; | 1202 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8; |
1177 yuv_highbit_resource_format_ = yuv_resource_format_; | 1203 yuv_highbit_resource_format_ = yuv_resource_format_; |
1178 if (caps.gpu.texture_half_float_linear) | 1204 if (caps.gpu.texture_half_float_linear) |
1179 yuv_highbit_resource_format_ = LUMINANCE_F16; | 1205 yuv_highbit_resource_format_ = LUMINANCE_F16; |
1180 use_sync_query_ = caps.gpu.sync_query; | 1206 use_sync_query_ = caps.gpu.sync_query; |
1181 | 1207 |
1182 max_texture_size_ = 0; // Context expects cleared value. | 1208 max_texture_size_ = 0; // Context expects cleared value. |
1183 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); | 1209 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
1184 best_texture_format_ = | 1210 best_texture_format_ = |
1185 PlatformColor::BestTextureFormat(use_texture_format_bgra_); | 1211 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); |
1186 | 1212 |
1187 best_render_buffer_format_ = | 1213 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( |
1188 PlatformColor::BestTextureFormat(caps.gpu.render_buffer_format_bgra8888); | 1214 caps.gpu.render_buffer_format_bgra8888); |
1189 | 1215 |
1190 texture_id_allocator_.reset( | 1216 texture_id_allocator_.reset( |
1191 new TextureIdAllocator(gl, id_allocation_chunk_size_)); | 1217 new TextureIdAllocator(gl, id_allocation_chunk_size_)); |
1192 buffer_id_allocator_.reset( | 1218 buffer_id_allocator_.reset( |
1193 new BufferIdAllocator(gl, id_allocation_chunk_size_)); | 1219 new BufferIdAllocator(gl, id_allocation_chunk_size_)); |
1194 } | 1220 } |
1195 | 1221 |
1196 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { | 1222 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { |
1197 DCHECK(thread_checker_.CalledOnValidThread()); | 1223 DCHECK(thread_checker_.CalledOnValidThread()); |
1198 | 1224 |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 | 1882 |
1857 const int kImportance = 2; | 1883 const int kImportance = 2; |
1858 pmd->CreateSharedGlobalAllocatorDump(guid); | 1884 pmd->CreateSharedGlobalAllocatorDump(guid); |
1859 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1885 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1860 } | 1886 } |
1861 | 1887 |
1862 return true; | 1888 return true; |
1863 } | 1889 } |
1864 | 1890 |
1865 } // namespace cc | 1891 } // namespace cc |
OLD | NEW |