| 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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; | 1239 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; |
| 1214 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8; | 1240 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8; |
| 1215 yuv_highbit_resource_format_ = yuv_resource_format_; | 1241 yuv_highbit_resource_format_ = yuv_resource_format_; |
| 1216 if (caps.gpu.texture_half_float_linear) | 1242 if (caps.gpu.texture_half_float_linear) |
| 1217 yuv_highbit_resource_format_ = LUMINANCE_F16; | 1243 yuv_highbit_resource_format_ = LUMINANCE_F16; |
| 1218 use_sync_query_ = caps.gpu.sync_query; | 1244 use_sync_query_ = caps.gpu.sync_query; |
| 1219 | 1245 |
| 1220 max_texture_size_ = 0; // Context expects cleared value. | 1246 max_texture_size_ = 0; // Context expects cleared value. |
| 1221 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); | 1247 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
| 1222 best_texture_format_ = | 1248 best_texture_format_ = |
| 1223 PlatformColor::BestTextureFormat(use_texture_format_bgra_); | 1249 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); |
| 1224 | 1250 |
| 1225 best_render_buffer_format_ = | 1251 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( |
| 1226 PlatformColor::BestTextureFormat(caps.gpu.render_buffer_format_bgra8888); | 1252 caps.gpu.render_buffer_format_bgra8888); |
| 1227 | 1253 |
| 1228 texture_id_allocator_.reset( | 1254 texture_id_allocator_.reset( |
| 1229 new TextureIdAllocator(gl, id_allocation_chunk_size_)); | 1255 new TextureIdAllocator(gl, id_allocation_chunk_size_)); |
| 1230 buffer_id_allocator_.reset( | 1256 buffer_id_allocator_.reset( |
| 1231 new BufferIdAllocator(gl, id_allocation_chunk_size_)); | 1257 new BufferIdAllocator(gl, id_allocation_chunk_size_)); |
| 1232 } | 1258 } |
| 1233 | 1259 |
| 1234 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { | 1260 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { |
| 1235 DCHECK(thread_checker_.CalledOnValidThread()); | 1261 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1236 | 1262 |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 | 1920 |
| 1895 const int kImportance = 2; | 1921 const int kImportance = 2; |
| 1896 pmd->CreateSharedGlobalAllocatorDump(guid); | 1922 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 1897 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1923 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 1898 } | 1924 } |
| 1899 | 1925 |
| 1900 return true; | 1926 return true; |
| 1901 } | 1927 } |
| 1902 | 1928 |
| 1903 } // namespace cc | 1929 } // namespace cc |
| OLD | NEW |