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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 case BGRA_8888: | 84 case BGRA_8888: |
85 storage_format = GL_BGRA8_EXT; | 85 storage_format = GL_BGRA8_EXT; |
86 break; | 86 break; |
87 case RGBA_4444: | 87 case RGBA_4444: |
88 case ALPHA_8: | 88 case ALPHA_8: |
89 case LUMINANCE_8: | 89 case LUMINANCE_8: |
90 case RGB_565: | 90 case RGB_565: |
91 case ETC1: | 91 case ETC1: |
92 case RED_8: | 92 case RED_8: |
93 case LUMINANCE_F16: | 93 case LUMINANCE_F16: |
| 94 case RG_88: |
94 NOTREACHED(); | 95 NOTREACHED(); |
95 break; | 96 break; |
96 } | 97 } |
97 | 98 |
98 return storage_format; | 99 return storage_format; |
99 } | 100 } |
100 | 101 |
101 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { | 102 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { |
102 switch (format) { | 103 switch (format) { |
103 case RGBA_8888: | 104 case RGBA_8888: |
104 return true; | 105 return true; |
105 case BGRA_8888: | 106 case BGRA_8888: |
106 return use_bgra; | 107 return use_bgra; |
107 case RGBA_4444: | 108 case RGBA_4444: |
108 case ALPHA_8: | 109 case ALPHA_8: |
109 case LUMINANCE_8: | 110 case LUMINANCE_8: |
110 case RGB_565: | 111 case RGB_565: |
111 case ETC1: | 112 case ETC1: |
112 case RED_8: | 113 case RED_8: |
113 case LUMINANCE_F16: | 114 case LUMINANCE_F16: |
| 115 case RG_88: |
114 return false; | 116 return false; |
115 } | 117 } |
116 return false; | 118 return false; |
117 } | 119 } |
118 | 120 |
119 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { | 121 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { |
120 switch (format) { | 122 switch (format) { |
121 case RGBA_8888: | 123 case RGBA_8888: |
122 return kRGBA_8888_GrPixelConfig; | 124 return kRGBA_8888_GrPixelConfig; |
123 case BGRA_8888: | 125 case BGRA_8888: |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 DCHECK(!buffer_id_allocator_); | 442 DCHECK(!buffer_id_allocator_); |
441 | 443 |
442 const auto& caps = compositor_context_provider_->ContextCapabilities(); | 444 const auto& caps = compositor_context_provider_->ContextCapabilities(); |
443 | 445 |
444 DCHECK(IsGpuResourceType(default_resource_type_)); | 446 DCHECK(IsGpuResourceType(default_resource_type_)); |
445 use_texture_storage_ext_ = caps.texture_storage; | 447 use_texture_storage_ext_ = caps.texture_storage; |
446 use_texture_format_bgra_ = caps.texture_format_bgra8888; | 448 use_texture_format_bgra_ = caps.texture_format_bgra8888; |
447 use_texture_usage_hint_ = caps.texture_usage; | 449 use_texture_usage_hint_ = caps.texture_usage; |
448 use_compressed_texture_etc1_ = caps.texture_format_etc1; | 450 use_compressed_texture_etc1_ = caps.texture_format_etc1; |
449 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; | 451 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; |
| 452 y16_resource_format_ = caps.texture_rg ? RG_88 : LUMINANCE_8; |
450 yuv_highbit_resource_format_ = yuv_resource_format_; | 453 yuv_highbit_resource_format_ = yuv_resource_format_; |
451 if (caps.texture_half_float_linear) | 454 if (caps.texture_half_float_linear) |
452 yuv_highbit_resource_format_ = LUMINANCE_F16; | 455 yuv_highbit_resource_format_ = LUMINANCE_F16; |
453 use_sync_query_ = caps.sync_query; | 456 use_sync_query_ = caps.sync_query; |
454 | 457 |
455 GLES2Interface* gl = ContextGL(); | 458 GLES2Interface* gl = ContextGL(); |
456 | 459 |
457 max_texture_size_ = 0; // Context expects cleared value. | 460 max_texture_size_ = 0; // Context expects cleared value. |
458 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); | 461 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
459 best_texture_format_ = | 462 best_texture_format_ = |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 } | 545 } |
543 | 546 |
544 ResourceFormat ResourceProvider::YuvResourceFormat(int bits) const { | 547 ResourceFormat ResourceProvider::YuvResourceFormat(int bits) const { |
545 if (bits > 8) { | 548 if (bits > 8) { |
546 return yuv_highbit_resource_format_; | 549 return yuv_highbit_resource_format_; |
547 } else { | 550 } else { |
548 return yuv_resource_format_; | 551 return yuv_resource_format_; |
549 } | 552 } |
550 } | 553 } |
551 | 554 |
| 555 ResourceFormat ResourceProvider::Y16ResourceFormat(int bits) const { |
| 556 if (bits > 8) { |
| 557 return y16_resource_format_; |
| 558 } else { |
| 559 return yuv_resource_format_; |
| 560 } |
| 561 } |
| 562 |
552 ResourceId ResourceProvider::CreateResource(const gfx::Size& size, | 563 ResourceId ResourceProvider::CreateResource(const gfx::Size& size, |
553 TextureHint hint, | 564 TextureHint hint, |
554 ResourceFormat format) { | 565 ResourceFormat format) { |
555 DCHECK(!size.IsEmpty()); | 566 DCHECK(!size.IsEmpty()); |
556 switch (default_resource_type_) { | 567 switch (default_resource_type_) { |
557 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: | 568 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: |
558 // GPU memory buffers don't support LUMINANCE_F16. | 569 // GPU memory buffers don't support LUMINANCE_F16. |
559 if (format != LUMINANCE_F16) { | 570 if (format != LUMINANCE_F16) { |
560 return CreateGLTexture(size, hint, RESOURCE_TYPE_GPU_MEMORY_BUFFER, | 571 return CreateGLTexture(size, hint, RESOURCE_TYPE_GPU_MEMORY_BUFFER, |
561 format); | 572 format); |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 | 1920 |
1910 const int kImportance = 2; | 1921 const int kImportance = 2; |
1911 pmd->CreateSharedGlobalAllocatorDump(guid); | 1922 pmd->CreateSharedGlobalAllocatorDump(guid); |
1912 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1923 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
1913 } | 1924 } |
1914 | 1925 |
1915 return true; | 1926 return true; |
1916 } | 1927 } |
1917 | 1928 |
1918 } // namespace cc | 1929 } // namespace cc |
OLD | NEW |