Chromium Code Reviews| 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 LUMINANCE_F32: | |
| 95 case RG_88: | |
| 94 NOTREACHED(); | 96 NOTREACHED(); |
| 95 break; | 97 break; |
| 96 } | 98 } |
| 97 | 99 |
| 98 return storage_format; | 100 return storage_format; |
| 99 } | 101 } |
| 100 | 102 |
| 101 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { | 103 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { |
| 102 switch (format) { | 104 switch (format) { |
| 103 case RGBA_8888: | 105 case RGBA_8888: |
| 104 return true; | 106 return true; |
| 105 case BGRA_8888: | 107 case BGRA_8888: |
| 106 return use_bgra; | 108 return use_bgra; |
| 107 case RGBA_4444: | 109 case RGBA_4444: |
| 108 case ALPHA_8: | 110 case ALPHA_8: |
| 109 case LUMINANCE_8: | 111 case LUMINANCE_8: |
| 110 case RGB_565: | 112 case RGB_565: |
| 111 case ETC1: | 113 case ETC1: |
| 112 case RED_8: | 114 case RED_8: |
| 113 case LUMINANCE_F16: | 115 case LUMINANCE_F16: |
| 116 case LUMINANCE_F32: | |
| 117 case RG_88: | |
| 114 return false; | 118 return false; |
| 115 } | 119 } |
| 116 return false; | 120 return false; |
| 117 } | 121 } |
| 118 | 122 |
| 119 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { | 123 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { |
| 120 switch (format) { | 124 switch (format) { |
| 121 case RGBA_8888: | 125 case RGBA_8888: |
| 122 return kRGBA_8888_GrPixelConfig; | 126 return kRGBA_8888_GrPixelConfig; |
| 123 case BGRA_8888: | 127 case BGRA_8888: |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 DCHECK(!buffer_id_allocator_); | 442 DCHECK(!buffer_id_allocator_); |
| 439 | 443 |
| 440 const auto& caps = compositor_context_provider_->ContextCapabilities(); | 444 const auto& caps = compositor_context_provider_->ContextCapabilities(); |
| 441 | 445 |
| 442 DCHECK(IsGpuResourceType(default_resource_type_)); | 446 DCHECK(IsGpuResourceType(default_resource_type_)); |
| 443 use_texture_storage_ext_ = caps.texture_storage; | 447 use_texture_storage_ext_ = caps.texture_storage; |
| 444 use_texture_format_bgra_ = caps.texture_format_bgra8888; | 448 use_texture_format_bgra_ = caps.texture_format_bgra8888; |
| 445 use_texture_usage_hint_ = caps.texture_usage; | 449 use_texture_usage_hint_ = caps.texture_usage; |
| 446 use_compressed_texture_etc1_ = caps.texture_format_etc1; | 450 use_compressed_texture_etc1_ = caps.texture_format_etc1; |
| 447 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; | |
| 453 // TODO(astojilj): Temporary code for performance and power consumption | |
|
aleksandar.stojiljkovic
2016/07/15 12:29:06
Uncomment line bellow to measure F16 and F32.
| |
| 454 // measurement. | |
| 455 // Uncomment one of following lines to use F32 or F16 for Y16. | |
| 456 // y16_resource_format_ = caps.texture_half_float_linear ? LUMINANCE_F32 : | |
| 457 // LUMINANCE_8; | |
| 458 // y16_resource_format_ = caps.texture_half_float_linear ? LUMINANCE_F16 : | |
| 459 // LUMINANCE_8; | |
| 448 yuv_highbit_resource_format_ = yuv_resource_format_; | 460 yuv_highbit_resource_format_ = yuv_resource_format_; |
| 449 if (caps.texture_half_float_linear) | 461 if (caps.texture_half_float_linear) |
| 450 yuv_highbit_resource_format_ = LUMINANCE_F16; | 462 yuv_highbit_resource_format_ = LUMINANCE_F16; |
| 451 use_sync_query_ = caps.sync_query; | 463 use_sync_query_ = caps.sync_query; |
| 452 | 464 |
| 453 GLES2Interface* gl = ContextGL(); | 465 GLES2Interface* gl = ContextGL(); |
| 454 | 466 |
| 455 max_texture_size_ = 0; // Context expects cleared value. | 467 max_texture_size_ = 0; // Context expects cleared value. |
| 456 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); | 468 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
| 457 best_texture_format_ = | 469 best_texture_format_ = |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 } | 552 } |
| 541 | 553 |
| 542 ResourceFormat ResourceProvider::YuvResourceFormat(int bits) const { | 554 ResourceFormat ResourceProvider::YuvResourceFormat(int bits) const { |
| 543 if (bits > 8) { | 555 if (bits > 8) { |
| 544 return yuv_highbit_resource_format_; | 556 return yuv_highbit_resource_format_; |
| 545 } else { | 557 } else { |
| 546 return yuv_resource_format_; | 558 return yuv_resource_format_; |
| 547 } | 559 } |
| 548 } | 560 } |
| 549 | 561 |
| 562 ResourceFormat ResourceProvider::Y16ResourceFormat(int bits) const { | |
| 563 if (bits > 8) { | |
| 564 return y16_resource_format_; | |
| 565 } else { | |
| 566 return yuv_resource_format_; | |
| 567 } | |
| 568 } | |
| 569 | |
| 550 ResourceId ResourceProvider::CreateResource(const gfx::Size& size, | 570 ResourceId ResourceProvider::CreateResource(const gfx::Size& size, |
| 551 TextureHint hint, | 571 TextureHint hint, |
| 552 ResourceFormat format) { | 572 ResourceFormat format) { |
| 553 DCHECK(!size.IsEmpty()); | 573 DCHECK(!size.IsEmpty()); |
| 554 switch (default_resource_type_) { | 574 switch (default_resource_type_) { |
| 555 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: | 575 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: |
| 556 // GPU memory buffers don't support LUMINANCE_F16. | 576 // GPU memory buffers don't support LUMINANCE_F16. |
| 557 if (format != LUMINANCE_F16) { | 577 if (format != LUMINANCE_F16) { |
| 558 return CreateGLTexture(size, hint, RESOURCE_TYPE_GPU_MEMORY_BUFFER, | 578 return CreateGLTexture(size, hint, RESOURCE_TYPE_GPU_MEMORY_BUFFER, |
| 559 format); | 579 format); |
| (...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1987 | 2007 |
| 1988 const int kImportance = 2; | 2008 const int kImportance = 2; |
| 1989 pmd->CreateSharedGlobalAllocatorDump(guid); | 2009 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 1990 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2010 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 1991 } | 2011 } |
| 1992 | 2012 |
| 1993 return true; | 2013 return true; |
| 1994 } | 2014 } |
| 1995 | 2015 |
| 1996 } // namespace cc | 2016 } // namespace cc |
| OLD | NEW |