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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 next_id_(1), | 404 next_id_(1), |
405 next_child_(1), | 405 next_child_(1), |
406 delegated_sync_points_required_(delegated_sync_points_required), | 406 delegated_sync_points_required_(delegated_sync_points_required), |
407 default_resource_type_(use_gpu_memory_buffer_resources | 407 default_resource_type_(use_gpu_memory_buffer_resources |
408 ? RESOURCE_TYPE_GPU_MEMORY_BUFFER | 408 ? RESOURCE_TYPE_GPU_MEMORY_BUFFER |
409 : RESOURCE_TYPE_GL_TEXTURE), | 409 : RESOURCE_TYPE_GL_TEXTURE), |
410 use_texture_storage_ext_(false), | 410 use_texture_storage_ext_(false), |
411 use_texture_format_bgra_(false), | 411 use_texture_format_bgra_(false), |
412 use_texture_usage_hint_(false), | 412 use_texture_usage_hint_(false), |
413 use_compressed_texture_etc1_(false), | 413 use_compressed_texture_etc1_(false), |
| 414 yuv_resource_format_(LUMINANCE_8), |
414 max_texture_size_(0), | 415 max_texture_size_(0), |
415 best_texture_format_(RGBA_8888), | 416 best_texture_format_(RGBA_8888), |
416 best_render_buffer_format_(RGBA_8888), | 417 best_render_buffer_format_(RGBA_8888), |
417 enable_color_correct_rendering_(enable_color_correct_rendering), | 418 enable_color_correct_rendering_(enable_color_correct_rendering), |
418 id_allocation_chunk_size_(id_allocation_chunk_size), | 419 id_allocation_chunk_size_(id_allocation_chunk_size), |
419 use_sync_query_(false), | 420 use_sync_query_(false), |
420 buffer_to_texture_target_map_(buffer_to_texture_target_map), | 421 buffer_to_texture_target_map_(buffer_to_texture_target_map), |
421 tracing_id_(g_next_resource_provider_tracing_id.GetNext()) { | 422 tracing_id_(g_next_resource_provider_tracing_id.GetNext()) { |
422 DCHECK(id_allocation_chunk_size_); | 423 DCHECK(id_allocation_chunk_size_); |
423 DCHECK(thread_checker_.CalledOnValidThread()); | 424 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 17 matching lines...) Expand all Loading... |
441 DCHECK(!texture_id_allocator_); | 442 DCHECK(!texture_id_allocator_); |
442 DCHECK(!buffer_id_allocator_); | 443 DCHECK(!buffer_id_allocator_); |
443 | 444 |
444 const auto& caps = compositor_context_provider_->ContextCapabilities(); | 445 const auto& caps = compositor_context_provider_->ContextCapabilities(); |
445 | 446 |
446 DCHECK(IsGpuResourceType(default_resource_type_)); | 447 DCHECK(IsGpuResourceType(default_resource_type_)); |
447 use_texture_storage_ext_ = caps.texture_storage; | 448 use_texture_storage_ext_ = caps.texture_storage; |
448 use_texture_format_bgra_ = caps.texture_format_bgra8888; | 449 use_texture_format_bgra_ = caps.texture_format_bgra8888; |
449 use_texture_usage_hint_ = caps.texture_usage; | 450 use_texture_usage_hint_ = caps.texture_usage; |
450 use_compressed_texture_etc1_ = caps.texture_format_etc1; | 451 use_compressed_texture_etc1_ = caps.texture_format_etc1; |
| 452 |
| 453 if (caps.disable_one_component_textures) { |
| 454 yuv_resource_format_ = yuv_highbit_resource_format_ = RGBA_8888; |
| 455 } else { |
| 456 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; |
| 457 yuv_highbit_resource_format_ = |
| 458 caps.texture_half_float_linear ? LUMINANCE_F16 : yuv_resource_format_; |
| 459 } |
| 460 |
451 use_sync_query_ = caps.sync_query; | 461 use_sync_query_ = caps.sync_query; |
452 | 462 |
453 GLES2Interface* gl = ContextGL(); | 463 GLES2Interface* gl = ContextGL(); |
454 | 464 |
455 max_texture_size_ = 0; // Context expects cleared value. | 465 max_texture_size_ = 0; // Context expects cleared value. |
456 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); | 466 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
457 best_texture_format_ = | 467 best_texture_format_ = |
458 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); | 468 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); |
459 | 469 |
460 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( | 470 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 Resource* resource = GetResource(id); | 542 Resource* resource = GetResource(id); |
533 return resource->lost; | 543 return resource->lost; |
534 } | 544 } |
535 | 545 |
536 void ResourceProvider::LoseResourceForTesting(ResourceId id) { | 546 void ResourceProvider::LoseResourceForTesting(ResourceId id) { |
537 Resource* resource = GetResource(id); | 547 Resource* resource = GetResource(id); |
538 DCHECK(resource); | 548 DCHECK(resource); |
539 resource->lost = true; | 549 resource->lost = true; |
540 } | 550 } |
541 | 551 |
| 552 ResourceFormat ResourceProvider::YuvResourceFormat(int bits) const { |
| 553 if (bits > 8) { |
| 554 return yuv_highbit_resource_format_; |
| 555 } else { |
| 556 return yuv_resource_format_; |
| 557 } |
| 558 } |
| 559 |
542 ResourceId ResourceProvider::CreateResource( | 560 ResourceId ResourceProvider::CreateResource( |
543 const gfx::Size& size, | 561 const gfx::Size& size, |
544 TextureHint hint, | 562 TextureHint hint, |
545 ResourceFormat format, | 563 ResourceFormat format, |
546 const gfx::ColorSpace& color_space) { | 564 const gfx::ColorSpace& color_space) { |
547 DCHECK(!size.IsEmpty()); | 565 DCHECK(!size.IsEmpty()); |
548 switch (default_resource_type_) { | 566 switch (default_resource_type_) { |
549 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: | 567 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: |
550 // GPU memory buffers don't support LUMINANCE_F16. | 568 // GPU memory buffers don't support LUMINANCE_F16. |
551 if (format != LUMINANCE_F16) { | 569 if (format != LUMINANCE_F16) { |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2041 | 2059 |
2042 const int kImportance = 2; | 2060 const int kImportance = 2; |
2043 pmd->CreateSharedGlobalAllocatorDump(guid); | 2061 pmd->CreateSharedGlobalAllocatorDump(guid); |
2044 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2062 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
2045 } | 2063 } |
2046 | 2064 |
2047 return true; | 2065 return true; |
2048 } | 2066 } |
2049 | 2067 |
2050 } // namespace cc | 2068 } // namespace cc |
OLD | NEW |