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