| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 DCHECK(!texture_id_allocator_); | 438 DCHECK(!texture_id_allocator_); |
| 439 DCHECK(!buffer_id_allocator_); | 439 DCHECK(!buffer_id_allocator_); |
| 440 | 440 |
| 441 const auto& caps = compositor_context_provider_->ContextCapabilities(); | 441 const auto& caps = compositor_context_provider_->ContextCapabilities(); |
| 442 | 442 |
| 443 DCHECK(IsGpuResourceType(default_resource_type_)); | 443 DCHECK(IsGpuResourceType(default_resource_type_)); |
| 444 use_texture_storage_ext_ = caps.texture_storage; | 444 use_texture_storage_ext_ = caps.texture_storage; |
| 445 use_texture_format_bgra_ = caps.texture_format_bgra8888; | 445 use_texture_format_bgra_ = caps.texture_format_bgra8888; |
| 446 use_texture_usage_hint_ = caps.texture_usage; | 446 use_texture_usage_hint_ = caps.texture_usage; |
| 447 use_compressed_texture_etc1_ = caps.texture_format_etc1; | 447 use_compressed_texture_etc1_ = caps.texture_format_etc1; |
| 448 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; | 448 |
| 449 yuv_highbit_resource_format_ = yuv_resource_format_; | 449 if (caps.disable_one_component_textures) { |
| 450 if (caps.texture_half_float_linear) | 450 yuv_resource_format_ = yuv_highbit_resource_format_ = RGBA_8888; |
| 451 yuv_highbit_resource_format_ = LUMINANCE_F16; | 451 } else { |
| 452 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; |
| 453 yuv_highbit_resource_format_ = |
| 454 caps.texture_half_float_linear ? LUMINANCE_F16 : yuv_resource_format_; |
| 455 } |
| 456 |
| 452 use_sync_query_ = caps.sync_query; | 457 use_sync_query_ = caps.sync_query; |
| 453 | 458 |
| 454 GLES2Interface* gl = ContextGL(); | 459 GLES2Interface* gl = ContextGL(); |
| 455 | 460 |
| 456 max_texture_size_ = 0; // Context expects cleared value. | 461 max_texture_size_ = 0; // Context expects cleared value. |
| 457 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); | 462 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
| 458 best_texture_format_ = | 463 best_texture_format_ = |
| 459 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); | 464 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); |
| 460 | 465 |
| 461 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( | 466 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 | 814 |
| 810 ResourceProvider::ResourceType ResourceProvider::GetResourceType( | 815 ResourceProvider::ResourceType ResourceProvider::GetResourceType( |
| 811 ResourceId id) { | 816 ResourceId id) { |
| 812 return GetResource(id)->type; | 817 return GetResource(id)->type; |
| 813 } | 818 } |
| 814 | 819 |
| 815 GLenum ResourceProvider::GetResourceTextureTarget(ResourceId id) { | 820 GLenum ResourceProvider::GetResourceTextureTarget(ResourceId id) { |
| 816 return GetResource(id)->target; | 821 return GetResource(id)->target; |
| 817 } | 822 } |
| 818 | 823 |
| 824 bool ResourceProvider::IsImmutable(ResourceId id) { |
| 825 if (IsGpuResourceType(default_resource_type_)) { |
| 826 return GetTextureHint(id) == TEXTURE_HINT_IMMUTABLE; |
| 827 } else { |
| 828 // Software resources are immutable; they cannot change format or be |
| 829 // resized. |
| 830 return true; |
| 831 } |
| 832 } |
| 833 |
| 819 ResourceProvider::TextureHint ResourceProvider::GetTextureHint(ResourceId id) { | 834 ResourceProvider::TextureHint ResourceProvider::GetTextureHint(ResourceId id) { |
| 820 return GetResource(id)->hint; | 835 return GetResource(id)->hint; |
| 821 } | 836 } |
| 822 | 837 |
| 823 static sk_sp<SkColorSpace> ColorSpaceToSkColorSpace( | 838 static sk_sp<SkColorSpace> ColorSpaceToSkColorSpace( |
| 824 const gfx::ColorSpace& color_space) { | 839 const gfx::ColorSpace& color_space) { |
| 825 // TODO(crbug.com/634102): Implement conversion for skia-based compositing to | 840 // TODO(crbug.com/634102): Implement conversion for skia-based compositing to |
| 826 // be color-managed | 841 // be color-managed |
| 827 return nullptr; | 842 return nullptr; |
| 828 } | 843 } |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 | 2042 |
| 2028 const int kImportance = 2; | 2043 const int kImportance = 2; |
| 2029 pmd->CreateSharedGlobalAllocatorDump(guid); | 2044 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 2030 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2045 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 2031 } | 2046 } |
| 2032 | 2047 |
| 2033 return true; | 2048 return true; |
| 2034 } | 2049 } |
| 2035 | 2050 |
| 2036 } // namespace cc | 2051 } // namespace cc |
| OLD | NEW |